Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
psomhorst committed Dec 18, 2024
2 parents ad0bbdb + 1dc4b3d commit 3c10308
Show file tree
Hide file tree
Showing 29 changed files with 281 additions and 306 deletions.
2 changes: 1 addition & 1 deletion .github/actions/install_eitprocessing/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ runs:
key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-[${{ inputs.dependencies }}]
- name: Install eitprocessing with [${{ inputs.dependencies }}] dependencies
if: steps.cache-python-env.outputs.cache-hit != 'true'
run: python3 -m pip install -e ".[${{ inputs.dependencies }}]"
run: python3 -m pip install ".[${{ inputs.dependencies }}]"
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/cffconvert.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Citation file
name: Citation File

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Linting
name: Lint

on:
push:
Expand Down
224 changes: 139 additions & 85 deletions .github/workflows/release_github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion .github/workflows/test_build_documentation.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test build documentation
name: Documentation

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run tests
name: Build and Test

on:
push:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ venv3

/site/
uv.lock

worktrees
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs/*
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"rewrap.wrappingColumn": 120,
"rewrap.autoWrap.enabled": true,
"editor.formatOnSave": true,
"files.trimTrailingWhitespace": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[ignore]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
Expand Down
6 changes: 3 additions & 3 deletions README.dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ We use [prettier](https://prettier.io/) for formatting most other files. If you

## Making a release

### Automated release workflow:
### Automated release workflow

0. **IMP0RTANT:** [Create a PR](#creating-a-pr) for the release branch (usually `develop`) and make sure that all checks pass!
- if everything goes well, this PR will automatically be closed after the draft release is created.
Expand All @@ -152,7 +152,7 @@ We use [prettier](https://prettier.io/) for formatting most other files. If you
8. Click green "Publish Release" button to convert the draft to a published release on GitHub.
- This will automatically trigger [another GitHub workflow](https://github.com/EIT-ALIVE/eitprocessing/actions/workflows/release.yml) that will take care of publishing the package on PyPi.

#### Updating the token:
#### Updating the token

NOTE: the current token (associated to @DaniBodor) allowing to bypass branch protection will expire on June 20th, 2025. To update the token do the following:

Expand All @@ -164,7 +164,7 @@ NOTE: the current token (associated to @DaniBodor) allowing to bypass branch pro
5. Navigate to the [secrets settings](https://github.com/EIT-ALIVE/eitprocessing/settings/secrets/actions).
6. Edit the `GH_PAT` key giving your access token as the new value.

### Manually create a release:
### Manually create a release

0. Make sure you have all required developers tools installed `pip install -e .'[dev]'`.
1. Create a `release` branch from `main` and merge the changes into this branch.
Expand Down
Loading

0 comments on commit 3c10308

Please sign in to comment.