-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
281 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Citation file | ||
name: Citation File | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Linting | ||
name: Lint | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,154 +4,208 @@ on: | |
workflow_dispatch: | ||
inputs: | ||
version_level: | ||
description: "Semantic version level increase." | ||
description: Semantic version level increase | ||
required: true | ||
type: choice | ||
default: patch | ||
options: | ||
- patch | ||
- minor | ||
- major | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
packages: read | ||
statuses: read | ||
checks: read | ||
pull-requests: write | ||
actions: read | ||
repository-projects: read | ||
|
||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GH_PAGER: cat | ||
|
||
jobs: | ||
checks: | ||
name: Check requirements | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Fail if main branch was selected | ||
if: ${{ github.ref_name == 'main' }} | ||
run: | | ||
echo "Cannot release from main branch, please select valid release branch." | ||
exit 1 | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check if PR exists | ||
run: gh pr view ${{ github.ref_name }} | ||
|
||
- name: Check if PR base is main | ||
run: gh pr view ${{ github.ref_name }} --json baseRefName -q 'if .baseRefName == "main" then "PR base is main" else error("PR base is not main") end' | ||
|
||
- name: Check if PR is mergeable | ||
run: gh pr view ${{ github.ref_name }} --json mergeable -q 'if .mergeable == "MERGEABLE" then "PR is mergeable" else error("PR is not mergeable") end' | ||
|
||
- name: Check whether PR checks pass(ed) | ||
# note that this assumed there are checks to be passed; this fails if there are no checks, which is no | ||
# relevant to this repo | ||
run: | | ||
gh pr checks ${{ github.ref_name }} --watch --fail-fast | ||
gh pr checks ${{ github.ref_name }} --json state -q 'if . | length == 0 then "No checks found." elif map(.state == "SUCCESS") | all then "All checks passed" else error("Not all checks passed") end' | ||
test_python_releases: | ||
needs: checks | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
matrix: | ||
os: ["ubuntu-latest"] | ||
python-version: ["3.10", "3.11", "3.12", "3.13"] | ||
name: Build for ${{ matrix.python-version }}, ${{ matrix.os }} | ||
env: | ||
env: | ||
EIT_PROCESSING_TEST_DATA: ${{ github.workspace }}/../eitprocessing_data/ | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/install_eitprocessing | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install eitprocessing | ||
uses: ./.github/actions/install_eitprocessing | ||
with: | ||
dependencies: testing | ||
extract-data: true | ||
python-version: ${{ matrix.python-version }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
data-directory: ${{ env.EIT_PROCESSING_TEST_DATA }} | ||
|
||
- name: Run pytest | ||
run: pytest -v | ||
- name: Install eitprocessing with dev dependencies | ||
|
||
- name: Install additional dependencies for building | ||
run: python3 -m pip install --upgrade ".[publishing]" | ||
|
||
- name: Build eitprocessing | ||
run: python3 -m build | ||
|
||
|
||
github_release: | ||
merge_and_bump: | ||
name: Merge the changes into main and bump the version | ||
needs: test_python_releases | ||
runs-on: "ubuntu-latest" | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
|
||
runs-on: ubuntu-latest | ||
outputs: | ||
new-version: ${{ steps.bump.outputs.current-version }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- name: Fail if main branch was selected | ||
if: ${{ github.ref_name == 'main' }} | ||
run: | | ||
echo "Cannot release from main branch, please select valid release branch." | ||
exit 1 | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.GH_PAT }} | ||
ref: main | ||
fetch-depth: 0 | ||
token: ${{ secrets.GH_PAT }} | ||
|
||
- name: Configure git | ||
run: | | ||
git config user.email "actions@github.com" | ||
git config user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" | ||
git config user.name "GitHub Actions" | ||
git pull | ||
git config -l | ||
- name: Merge changes into main | ||
- name: Merge branch into main | ||
run: | | ||
git switch main | ||
git branch ${{ github.ref_name }} origin/${{ github.ref_name }} | ||
git merge ${{ github.ref_name }} --no-ff --no-commit | ||
git commit --no-edit | ||
git branch -f ${{ github.ref_name }} origin/${{ github.ref_name }} | ||
git merge ${{ github.ref_name }} --no-ff --no-edit | ||
- name: Install Python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: "3.12" | ||
|
||
- name: Bump version | ||
- name: Install bump-my-version | ||
shell: bash | ||
run: | | ||
python3 -m pip install pyproject-deplister | ||
pyproject-deplister --extra dev --path pyproject.toml | grep bump-my-version | sed 's/ //g' | xargs -I{} python3 -m pip install "{}" | ||
- name: Pass Inputs to Shell | ||
id: bump | ||
shell: bash | ||
run: | | ||
echo "previous-version=$(bump-my-version show current_version)" >> $GITHUB_OUTPUT | ||
bump-my-version bump ${{ inputs.version_level }} --commit --tag | ||
([[ $? -gt 0 ]] && echo "bumped=false" || echo "bumped=true") >> $GITHUB_OUTPUT | ||
echo "current-version=$(bump-my-version show current_version)" >> $GITHUB_OUTPUT | ||
- name: Fail if bumping failes | ||
if: steps.bump.outputs.bumped == 'false' | ||
run: | | ||
echo "Bumping failed." | ||
git reset --hard HEAD^ | ||
exit 1 | ||
- name: Check new version number | ||
if: steps.bump.outputs.bumped == 'true' | ||
run: | | ||
echo "Version was bumped from ${{ steps.bump.outputs.previous-version }} to ${{ steps.bump.outputs.current-version }}!" | ||
- name: Merge main into develop | ||
run: | | ||
git checkout develop | ||
git merge main --no-ff --no-edit || { echo "Can't merge changes to develop. Manually merge PR and create GitHub release."; exit 1; } | ||
- name: Push changes to develop | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GH_PAT }} | ||
branch: develop | ||
force_with_lease: true | ||
|
||
- name: Checkout main | ||
run: | | ||
echo "-- install bump-my-version" | ||
python3 -m pip install bump-my-version | ||
echo "-- bump the version" | ||
bump-my-version bump ${{ github.event.inputs.version_level }} --commit --tag | ||
echo "-- push bumped version" | ||
echo "RELEASE_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT | ||
git push --tags -f | ||
git push | ||
git checkout main | ||
- name: Push changes to main | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GH_PAT }} | ||
branch: main | ||
force_with_lease: true | ||
|
||
github_release: | ||
name: Create a draft GitHub release | ||
needs: merge_and_bump | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
|
||
- name: Create GitHub Release | ||
id: create_release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release create ${{ steps.bump.outputs.RELEASE_TAG }} \ | ||
--title="Release ${{ steps.bump.outputs.RELEASE_TAG }}" \ | ||
gh release create v${{ needs.merge_and_bump.outputs.new-version }} \ | ||
--title="Release v${{ needs.merge_and_bump.outputs.new-version }}" \ | ||
--generate-notes \ | ||
--draft | ||
- name: Validate CITATION.cff | ||
id: validate_cff | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
uses: dieghernan/cff-validator@v3 | ||
|
||
tidy_workspace: | ||
# only run if action above succeeds | ||
remove_branch: | ||
name: Remove PR branch | ||
needs: github_release | ||
runs-on: "ubuntu-latest" | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
|
||
if: ${{ github.ref_name != 'develop' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.GH_PAT }} | ||
ref: develop | ||
fetch-depth: 0 | ||
|
||
- name: Configure git | ||
run: | | ||
git config user.email "[email protected]" | ||
git config user.name "GitHub Actions" | ||
git pull | ||
- name: Close PR | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
echo "-- searching for associated PR" | ||
pr_number=$(gh pr list --head ${{ github.ref_name }} --json number --jq '.[0].number') | ||
if [ -n "$pr_number" ]; then | ||
echo "-- closing PR #$pr_number" | ||
gh pr close $pr_number | ||
else | ||
echo "-- no open pull request found for branch $branch_name" | ||
fi | ||
- name: Merge updates into develop | ||
run: | | ||
git switch develop | ||
git merge --no-ff origin/main | ||
git push | ||
- name: Delete release branch other than main or develop | ||
run: | | ||
if [[ ${{ github.ref_name }} != "main" && ${{ github.ref_name }} != "develop" ]]; then | ||
echo "-- deleting branch '${{ github.ref_name }}'" | ||
git push origin -d ${{ github.ref_name }} | ||
else | ||
echo "-- branch '${{ github.ref_name }}' will not be deleted from remote" | ||
fi | ||
- name: Remove PR branch | ||
uses: dawidd6/action-delete-branch@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branches: ${{ github.ref_name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Test build documentation | ||
name: Documentation | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Run tests | ||
name: Build and Test | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,5 @@ venv3 | |
|
||
/site/ | ||
uv.lock | ||
|
||
worktrees |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docs/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.