From 6b355569842c0b54b26c1a1057990588ab0564f7 Mon Sep 17 00:00:00 2001 From: Max Chesterfield Date: Thu, 7 May 2026 12:19:42 +1000 Subject: [PATCH 1/9] changes Signed-off-by: Max Chesterfield --- .github/workflows/python-build.yml | 4 +- .github/workflows/python-lib-release.yml | 86 +++++++++++++++++++---- .github/workflows/python-lib-snapshot.yml | 16 +++-- 3 files changed, 85 insertions(+), 21 deletions(-) diff --git a/.github/workflows/python-build.yml b/.github/workflows/python-build.yml index 94778e4..7d5b874 100644 --- a/.github/workflows/python-build.yml +++ b/.github/workflows/python-build.yml @@ -21,7 +21,7 @@ on: description: "env to set for docker compose as a JSON string" required: false type: string - default: "" + default: "{}" python-versions-to-test: description: "List of versions of python to run, as a JSON string" required: false @@ -171,7 +171,7 @@ jobs: - name: Stand up required service containers, and run code generation if: inputs.docker-container != '' - env: ${{ fromJSON(inputs.docker-compose-env }} + env: ${{ fromJSON(inputs.docker-compose-env) }} run: | docker compose up ${{ inputs.docker-container }} diff --git a/.github/workflows/python-lib-release.yml b/.github/workflows/python-lib-release.yml index 6aaa2af..a177b20 100644 --- a/.github/workflows/python-lib-release.yml +++ b/.github/workflows/python-lib-release.yml @@ -27,12 +27,16 @@ on: description: "env to set for docker compose as a JSON string" required: false type: string - default: "" + default: "{}" python-version: description: "Python versions to run 'build'" required: false type: string default: 3.10 + package-release-version: + description: "Version to release" + required: false + type: string secrets: CI_GITHUB_TOKEN: @@ -88,6 +92,7 @@ jobs: - name: Release checks and update version for release id: check + if: ${{ !inputs.package-release-version }} run: | /scripts/release-checks.sh --python pyproject.toml /scripts/finalize-version.sh --python pyproject.toml @@ -95,17 +100,34 @@ jobs: echo "version=$version" >> "${GITHUB_OUTPUT}" shell: bash + - name: Release checks and update version for release (version override) + id: version-override + if: ${{ inputs.package-release-version }} + run: | + git config --global user.email "ci@zepben.com" + git config --global user.name "CI" + git checkout -b release + ls + echo "version=${{ inputs.package-release-version }}" >> "${GITHUB_OUTPUT}" + sed -i 's#version = "[0-9]\.[0-9]\.[0-9]b[0-9]"#version = "${{ inputs.package-release-version }}"#g' pyproject.toml + sed -i 's#version = "edge"#version = "0.0.0b1"#g' pyproject.toml + cat pyproject.toml + git add pyproject.toml + git commit -m "Release ${{ inputs.package-release-version }} [skip ci]" --allow-empty + git push -u origin release + shell: bash + - name: Cache licence-check uses: actions/cache@v4 with: path: /lc key: lcc - - name: Check licence - uses: zepben/licence-check-action@main - with: - LC_URL: ${{ secrets.LC_URL }} - PATH: ${{ inputs.sourcepath }} +# - name: Check licence +# uses: zepben/licence-check-action@main +# with: +# LC_URL: ${{ secrets.LC_URL }} +# PATH: ${{ inputs.sourcepath }} - name: Check if docs present id: docs @@ -141,6 +163,7 @@ jobs: - name: Test changelog format id: changelog + if: ${{ !inputs.package-release-version }} shell: bash run: | changelog=$(sed -n -E "/${{ steps.check.outputs.version }}/,/## [[0-9]+\.[0-9]+\.[0-9]+]/ { /## \[/d;p }" changelog.md) @@ -180,7 +203,6 @@ jobs: needs: [release-checks, build-docs] if: always() && !failure() && !cancelled() runs-on: ubuntu-latest - container: python:${{ inputs.python-version }} outputs: artifact: ${{ steps.build.outputs.artifact }} steps: @@ -196,6 +218,12 @@ jobs: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python-version }} + architecture: 'x64' + + - name: Checkout release branch run: | git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" @@ -210,7 +238,8 @@ jobs: echo "[pypi]" > ~/.pypirc echo "username = __token__" >> ~/.pypirc echo "password = $PYPI_API_TOKEN" >> ~/.pypirc - echo "\n" >> ~/.pypirc + echo >> ~/.pypirc + cat ~/.pypirc - name: Login to Docker Hub if: inputs.docker-container != '' @@ -222,17 +251,16 @@ jobs: - name: Stand up required service containers, and run code generation if: inputs.docker-container != '' - env: ${{ fromJSON(inputs.docker-compose-env }} + env: ${{ fromJSON(inputs.docker-compose-env) }} run: | docker compose up ${{ inputs.docker-container }} - name: Build and publish id: build run: | - tox -e py${{ inputs.python-version }} + tox -e build twine upload --non-interactive --config-file ~/.pypirc dist/* - artifact_id=$(cat pyproject.toml | grep '[[:space:]]*name[[:space:]]*=[[:space:]]*".*"$' | cut -d\" -f2 | tr -d '"' | sed 's-\.-_-g') - artifact="${artifact_id}-${{ needs.release-checks.outputs.version }}-py3-none-any.whl" + artifact=`ls dist | grep py3-none-any.whl` echo "artifact=$artifact" >> "${GITHUB_OUTPUT}" echo "artifact-path=dist/$artifact" >> "${GITHUB_OUTPUT}" @@ -286,6 +314,7 @@ jobs: - name: Merge and Tag id: merge + if: ${{ !inputs.package-release-version }} run: | git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" git fetch --all @@ -298,6 +327,20 @@ jobs: shell: bash continue-on-error: true + - name: Tag and delete release branch (version override) + id: tag + if: ${{ inputs.package-release-version }} + run: | + git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" + git fetch --all + git branch -a + git checkout origin/release + git tag "v${{ inputs.package-release-version }}" + git push --tags + echo "tag=v${{ inputs.package-release-version }}" >> "${GITHUB_OUTPUT}" + shell: bash + continue-on-error: true + - name: Delete release branch if merge failed and fail if: steps.merge.outcome == 'failure' run: | @@ -321,7 +364,7 @@ jobs: continue-on-error: true - name: Create Release and upload assets - if: success() + if: success() && ${{ !inputs.package-release-version }} id: create_release uses: softprops/action-gh-release@v1 env: @@ -335,9 +378,24 @@ jobs: built-artifacts/${{ needs.deploy.outputs.artifact }} continue-on-error: true + - name: Create Release and upload assets (version-override) + if: success() && ${{ inputs.package-release-version }} + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.tag.outputs.tag }} + body_path: latest_changelog.txt + draft: false + prerelease: false + files: | + built-artifacts/${{ needs.deploy.outputs.artifact }} + continue-on-error: true + + update-version: needs: [create-release] - if: always() && !failure() && !cancelled() + if: always() && !failure() && !cancelled() && ${{ !inputs.package-release-version }} runs-on: ubuntu-latest container: zepben/pipeline-basic env: diff --git a/.github/workflows/python-lib-snapshot.yml b/.github/workflows/python-lib-snapshot.yml index 2a26c89..b7ec4aa 100644 --- a/.github/workflows/python-lib-snapshot.yml +++ b/.github/workflows/python-lib-snapshot.yml @@ -22,6 +22,11 @@ on: description: "Docker container to run as part of build" required: false type: string + docker-compose-env: + description: "env to set for docker compose as a JSON string" + required: false + type: string + default: "{}" python-version: description: "Python versions to run 'build'" required: false @@ -69,11 +74,11 @@ jobs: path: /lc key: lcc - - name: Check licence - uses: zepben/licence-check-action@main - with: - LC_URL: ${{ secrets.LC_URL }} - PATH: ${{ inputs.sourcepath }} +# - name: Check licence +# uses: zepben/licence-check-action@main +# with: +# LC_URL: ${{ secrets.LC_URL }} +# PATH: ${{ inputs.sourcepath }} - name: Check if docs present id: docs @@ -147,6 +152,7 @@ jobs: - name: Stand up required service containers, and run code generation if: inputs.docker-container != '' + env: ${{ fromJSON(inputs.docker-compose-env) }} run: | docker compose up ${{ inputs.docker-container }} From 867a2e311800af7bbb7b576a8ec5a58b93917f85 Mon Sep 17 00:00:00 2001 From: Max Chesterfield Date: Thu, 7 May 2026 12:22:55 +1000 Subject: [PATCH 2/9] add git ignore Signed-off-by: Max Chesterfield --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ From 9fbf96022112599ea380f811a3b232509753116f Mon Sep 17 00:00:00 2001 From: Max Chesterfield Date: Thu, 7 May 2026 12:23:13 +1000 Subject: [PATCH 3/9] re-enable lisence check Signed-off-by: Max Chesterfield --- .github/workflows/python-lib-release.yml | 10 +++++----- .github/workflows/python-lib-snapshot.yml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/python-lib-release.yml b/.github/workflows/python-lib-release.yml index a177b20..5016b36 100644 --- a/.github/workflows/python-lib-release.yml +++ b/.github/workflows/python-lib-release.yml @@ -123,11 +123,11 @@ jobs: path: /lc key: lcc -# - name: Check licence -# uses: zepben/licence-check-action@main -# with: -# LC_URL: ${{ secrets.LC_URL }} -# PATH: ${{ inputs.sourcepath }} + - name: Check licence + uses: zepben/licence-check-action@main + with: + LC_URL: ${{ secrets.LC_URL }} + PATH: ${{ inputs.sourcepath }} - name: Check if docs present id: docs diff --git a/.github/workflows/python-lib-snapshot.yml b/.github/workflows/python-lib-snapshot.yml index b7ec4aa..c702f72 100644 --- a/.github/workflows/python-lib-snapshot.yml +++ b/.github/workflows/python-lib-snapshot.yml @@ -74,11 +74,11 @@ jobs: path: /lc key: lcc -# - name: Check licence -# uses: zepben/licence-check-action@main -# with: -# LC_URL: ${{ secrets.LC_URL }} -# PATH: ${{ inputs.sourcepath }} + - name: Check licence + uses: zepben/licence-check-action@main + with: + LC_URL: ${{ secrets.LC_URL }} + PATH: ${{ inputs.sourcepath }} - name: Check if docs present id: docs From cc590ee5f927e3e4e8be12781bea7842edd9df08 Mon Sep 17 00:00:00 2001 From: Max Chesterfield Date: Thu, 7 May 2026 12:30:49 +1000 Subject: [PATCH 4/9] rejiger workflow conditional~ Signed-off-by: Max Chesterfield --- .github/workflows/python-lib-release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-lib-release.yml b/.github/workflows/python-lib-release.yml index 5016b36..7296723 100644 --- a/.github/workflows/python-lib-release.yml +++ b/.github/workflows/python-lib-release.yml @@ -364,7 +364,7 @@ jobs: continue-on-error: true - name: Create Release and upload assets - if: success() && ${{ !inputs.package-release-version }} + if: ${{ success() && !inputs.package-release-version }} id: create_release uses: softprops/action-gh-release@v1 env: @@ -379,7 +379,7 @@ jobs: continue-on-error: true - name: Create Release and upload assets (version-override) - if: success() && ${{ inputs.package-release-version }} + if: ${{ success() && inputs.package-release-version }} uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -395,7 +395,7 @@ jobs: update-version: needs: [create-release] - if: always() && !failure() && !cancelled() && ${{ !inputs.package-release-version }} + if: ${{ always() && !failure() && !cancelled() && !inputs.package-release-version }} runs-on: ubuntu-latest container: zepben/pipeline-basic env: From 15f16b1c640d16865e3be8417dc4e01d80ecf5c0 Mon Sep 17 00:00:00 2001 From: Max Chesterfield Date: Thu, 7 May 2026 12:44:16 +1000 Subject: [PATCH 5/9] delete release branch on failure Signed-off-by: Max Chesterfield --- .github/workflows/python-lib-release.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/python-lib-release.yml b/.github/workflows/python-lib-release.yml index 7296723..baff845 100644 --- a/.github/workflows/python-lib-release.yml +++ b/.github/workflows/python-lib-release.yml @@ -430,3 +430,23 @@ jobs: PRODUCT: ${{ needs.build-docs.outputs.product }} ARTIFACT: ${{ needs.build-docs.outputs.artifact }} secrets: inherit + + + delete-release-branch: + needs: [create-release, update-version] + if: failure() + runs-on: ubuntu-latest + container: zepben/pipeline-basic + env: + DEBUG: ${{ secrets.DEBUG }} + GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} + SLACK_NOTIFICATION: ${{ secrets.SLACK_NOTIFICATION }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + steps: + - name: Delete release branch + run: | + git push origin -d release + echo "There was an error in merging the branch. release branch was deleted." + exit 1 + shell: bash + From 4b1a593e8dfe76a88b6f38dd64c8ae15cb7cb359 Mon Sep 17 00:00:00 2001 From: Max Chesterfield Date: Thu, 7 May 2026 12:45:45 +1000 Subject: [PATCH 6/9] delete release branch on failure Signed-off-by: Max Chesterfield --- .github/workflows/python-lib-release.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/python-lib-release.yml b/.github/workflows/python-lib-release.yml index baff845..a8f8b8d 100644 --- a/.github/workflows/python-lib-release.yml +++ b/.github/workflows/python-lib-release.yml @@ -443,6 +443,10 @@ jobs: SLACK_NOTIFICATION: ${{ secrets.SLACK_NOTIFICATION }} SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} steps: + - uses: actions/checkout@v4 + with: + token: ${{ env.GITHUB_TOKEN }} + - name: Delete release branch run: | git push origin -d release From 60c2c38ec11e3cc130d914ab57067fa9c65bd91f Mon Sep 17 00:00:00 2001 From: Max Chesterfield Date: Thu, 7 May 2026 12:49:22 +1000 Subject: [PATCH 7/9] delete release branch on failure Signed-off-by: Max Chesterfield --- .github/workflows/python-lib-release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python-lib-release.yml b/.github/workflows/python-lib-release.yml index a8f8b8d..96386f5 100644 --- a/.github/workflows/python-lib-release.yml +++ b/.github/workflows/python-lib-release.yml @@ -449,6 +449,8 @@ jobs: - name: Delete release branch run: | + git config --global user.email "ci@zepben.com" + git config --global user.name "CI" git push origin -d release echo "There was an error in merging the branch. release branch was deleted." exit 1 From 520d1bed7e71c2f7d3ee73810828b4b1fbb401f0 Mon Sep 17 00:00:00 2001 From: Max Chesterfield Date: Thu, 7 May 2026 13:02:04 +1000 Subject: [PATCH 8/9] delete release branch on failure Signed-off-by: Max Chesterfield --- .github/workflows/python-lib-release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/python-lib-release.yml b/.github/workflows/python-lib-release.yml index 96386f5..3017ce7 100644 --- a/.github/workflows/python-lib-release.yml +++ b/.github/workflows/python-lib-release.yml @@ -436,7 +436,6 @@ jobs: needs: [create-release, update-version] if: failure() runs-on: ubuntu-latest - container: zepben/pipeline-basic env: DEBUG: ${{ secrets.DEBUG }} GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} From cf1487adcff734684dca7b16a4e5c1a132c2405c Mon Sep 17 00:00:00 2001 From: Max Chesterfield Date: Thu, 7 May 2026 13:03:33 +1000 Subject: [PATCH 9/9] delete release branch on failure Signed-off-by: Max Chesterfield --- .github/workflows/python-lib-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-lib-release.yml b/.github/workflows/python-lib-release.yml index 3017ce7..c0f88da 100644 --- a/.github/workflows/python-lib-release.yml +++ b/.github/workflows/python-lib-release.yml @@ -451,7 +451,7 @@ jobs: git config --global user.email "ci@zepben.com" git config --global user.name "CI" git push origin -d release - echo "There was an error in merging the branch. release branch was deleted." - exit 1 + echo "There was a failure in the workflow. release branch was deleted." + exit 0 shell: bash