Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}

Expand Down
101 changes: 92 additions & 9 deletions .github/workflows/python-lib-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -88,13 +92,31 @@ 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
version="$(cat pyproject.toml | grep 'version[[:space:]]*=[[:space:]]*"\?[0-9]\+\.[0-9]\+\.[0-9]\+\(b[0-9]\+\)\?"\?' | grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+\(b[0-9]\+\)\?")"
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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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/*"
Expand All @@ -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 != ''
Expand All @@ -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}"

Expand Down Expand Up @@ -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
Expand 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: |
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -372,3 +430,28 @@ 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
env:
DEBUG: ${{ secrets.DEBUG }}
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
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 config --global user.email "ci@zepben.com"
git config --global user.name "CI"
git push origin -d release
echo "There was a failure in the workflow. release branch was deleted."
exit 0
shell: bash

6 changes: 6 additions & 0 deletions .github/workflows/python-lib-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/