From 59105a1d9d0717b69f5311a0331a6ef624ef2e31 Mon Sep 17 00:00:00 2001 From: Luca Cigarini Date: Mon, 6 Oct 2025 15:39:09 +0200 Subject: [PATCH 1/4] Python Packaging --- .github/workflows/_release_and_tag.yml | 45 +++++++++++++++++--------- .github/workflows/release.yml | 3 ++ workflows/_release_and_tag.yml | 45 +++++++++++++++++--------- workflows/release.yml | 3 ++ 4 files changed, 64 insertions(+), 32 deletions(-) diff --git a/.github/workflows/_release_and_tag.yml b/.github/workflows/_release_and_tag.yml index 92bf029..f0debf4 100644 --- a/.github/workflows/_release_and_tag.yml +++ b/.github/workflows/_release_and_tag.yml @@ -2,6 +2,16 @@ name: Reusable release and tag workflow on: workflow_call: inputs: + branches_that_trigger_release: + description: Branches that will trigger a check on the tag. Otherwise, no check will be made. + type: + + append_to_release: + description: Append project's wheel and tarball to newly created release + type: boolean + required: false + default: false + publish_on_pypi: description: Upload on pypi public index type: boolean @@ -72,12 +82,27 @@ jobs: - name: Check Tag id: check-tag - if: github.base_ref == 'master' || github.base_ref == 'main' + if: contains(fromJSON(inputs.branches_that_trigger_release), github.base_ref) run: | if [[ "${{ github.event.pull_request.title }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "match=true" >> $GITHUB_OUTPUT fi + - uses: actions/setup-python@v5 + if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) + with: + python-version: "3.x" + + - name: Install pypa/build + if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) + run: | + python -m pip install build --user + + - name: Build a binary wheel and a source tarball + if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) + run: | + python -m build --sdist --wheel --outdir dist/ + - name: Create Tag and Release id: create-release if: steps.check-tag.outputs.match == 'true' @@ -90,6 +115,9 @@ jobs: prerelease: false target_commitish: ${{ github.base_ref }} append_body: true + files: | + dist/*-${{ github.event.pull_request.title }}*.tar.gz + dist/*-${{ github.event.pull_request.title }}*.whl - name: Checkout created tag uses: actions/checkout@v4 @@ -97,21 +125,6 @@ jobs: with: fetch-depth: 0 # otherwise, you do not retrieve the tags - - uses: actions/setup-python@v5 - if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi) - with: - python-version: "3.x" - - - name: Install pypa/build - if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi) - run: | - python -m pip install build --user - - - name: Build a binary wheel and a source tarball - if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi) - run: | - python -m build --sdist --wheel --outdir dist/ - - name: Publish to test PyPi uses: pypa/gh-action-pypi-publish@release/v1 if: steps.check-tag.outputs.match == 'true' && inputs.publish_on_test_pypi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7288a8c..8040450 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,9 @@ jobs: publish_on_npm: false publish_on_twitter: false publish_on_ecr: false + append_to_release: false + branches_that_trigger_release: >- + ["master", "main", "prod"] repository: certego-test working_directory: .github/test/python_test dockerfiles: >- diff --git a/workflows/_release_and_tag.yml b/workflows/_release_and_tag.yml index 92bf029..f0debf4 100644 --- a/workflows/_release_and_tag.yml +++ b/workflows/_release_and_tag.yml @@ -2,6 +2,16 @@ name: Reusable release and tag workflow on: workflow_call: inputs: + branches_that_trigger_release: + description: Branches that will trigger a check on the tag. Otherwise, no check will be made. + type: + + append_to_release: + description: Append project's wheel and tarball to newly created release + type: boolean + required: false + default: false + publish_on_pypi: description: Upload on pypi public index type: boolean @@ -72,12 +82,27 @@ jobs: - name: Check Tag id: check-tag - if: github.base_ref == 'master' || github.base_ref == 'main' + if: contains(fromJSON(inputs.branches_that_trigger_release), github.base_ref) run: | if [[ "${{ github.event.pull_request.title }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "match=true" >> $GITHUB_OUTPUT fi + - uses: actions/setup-python@v5 + if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) + with: + python-version: "3.x" + + - name: Install pypa/build + if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) + run: | + python -m pip install build --user + + - name: Build a binary wheel and a source tarball + if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) + run: | + python -m build --sdist --wheel --outdir dist/ + - name: Create Tag and Release id: create-release if: steps.check-tag.outputs.match == 'true' @@ -90,6 +115,9 @@ jobs: prerelease: false target_commitish: ${{ github.base_ref }} append_body: true + files: | + dist/*-${{ github.event.pull_request.title }}*.tar.gz + dist/*-${{ github.event.pull_request.title }}*.whl - name: Checkout created tag uses: actions/checkout@v4 @@ -97,21 +125,6 @@ jobs: with: fetch-depth: 0 # otherwise, you do not retrieve the tags - - uses: actions/setup-python@v5 - if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi) - with: - python-version: "3.x" - - - name: Install pypa/build - if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi) - run: | - python -m pip install build --user - - - name: Build a binary wheel and a source tarball - if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi) - run: | - python -m build --sdist --wheel --outdir dist/ - - name: Publish to test PyPi uses: pypa/gh-action-pypi-publish@release/v1 if: steps.check-tag.outputs.match == 'true' && inputs.publish_on_test_pypi diff --git a/workflows/release.yml b/workflows/release.yml index 7288a8c..8040450 100644 --- a/workflows/release.yml +++ b/workflows/release.yml @@ -21,6 +21,9 @@ jobs: publish_on_npm: false publish_on_twitter: false publish_on_ecr: false + append_to_release: false + branches_that_trigger_release: >- + ["master", "main", "prod"] repository: certego-test working_directory: .github/test/python_test dockerfiles: >- From bd7f603ef65bad11442b6d049097429f0ade657b Mon Sep 17 00:00:00 2001 From: Luca Cigarini Date: Mon, 6 Oct 2025 15:40:41 +0200 Subject: [PATCH 2/4] fixed variable --- .github/workflows/_release_and_tag.yml | 3 ++- workflows/_release_and_tag.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_release_and_tag.yml b/.github/workflows/_release_and_tag.yml index f0debf4..4b331f8 100644 --- a/.github/workflows/_release_and_tag.yml +++ b/.github/workflows/_release_and_tag.yml @@ -4,7 +4,8 @@ on: inputs: branches_that_trigger_release: description: Branches that will trigger a check on the tag. Otherwise, no check will be made. - type: + type: string + required: true append_to_release: description: Append project's wheel and tarball to newly created release diff --git a/workflows/_release_and_tag.yml b/workflows/_release_and_tag.yml index f0debf4..4b331f8 100644 --- a/workflows/_release_and_tag.yml +++ b/workflows/_release_and_tag.yml @@ -4,7 +4,8 @@ on: inputs: branches_that_trigger_release: description: Branches that will trigger a check on the tag. Otherwise, no check will be made. - type: + type: string + required: true append_to_release: description: Append project's wheel and tarball to newly created release From 366276be468239a58b3065c8fa81e62f96ee4394 Mon Sep 17 00:00:00 2001 From: Luca Cigarini Date: Mon, 6 Oct 2025 15:46:18 +0200 Subject: [PATCH 3/4] fixed workflow --- .github/workflows/_release_and_tag.yml | 42 +++++++++++++++----------- workflows/_release_and_tag.yml | 42 +++++++++++++++----------- 2 files changed, 48 insertions(+), 36 deletions(-) diff --git a/.github/workflows/_release_and_tag.yml b/.github/workflows/_release_and_tag.yml index 4b331f8..cf45e72 100644 --- a/.github/workflows/_release_and_tag.yml +++ b/.github/workflows/_release_and_tag.yml @@ -89,21 +89,6 @@ jobs: echo "match=true" >> $GITHUB_OUTPUT fi - - uses: actions/setup-python@v5 - if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) - with: - python-version: "3.x" - - - name: Install pypa/build - if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) - run: | - python -m pip install build --user - - - name: Build a binary wheel and a source tarball - if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) - run: | - python -m build --sdist --wheel --outdir dist/ - - name: Create Tag and Release id: create-release if: steps.check-tag.outputs.match == 'true' @@ -116,9 +101,6 @@ jobs: prerelease: false target_commitish: ${{ github.base_ref }} append_body: true - files: | - dist/*-${{ github.event.pull_request.title }}*.tar.gz - dist/*-${{ github.event.pull_request.title }}*.whl - name: Checkout created tag uses: actions/checkout@v4 @@ -126,6 +108,30 @@ jobs: with: fetch-depth: 0 # otherwise, you do not retrieve the tags + - uses: actions/setup-python@v5 + if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) + with: + python-version: "3.x" + + - name: Install pypa/build + if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) + run: | + python -m pip install build --user + + - name: Build a binary wheel and a source tarball + if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) + run: | + python -m build --sdist --wheel --outdir dist/ + + - name: Update release with assets + id: update-release + if: steps.check-tag.outputs.match == 'true' && inputs.append_to_release + uses: softprops/action-gh-release@v2 + with: + files: | + dist/*-${{ github.ref_name }}*.tar.gz + dist/*-${{ github.ref_name }}*.whl + - name: Publish to test PyPi uses: pypa/gh-action-pypi-publish@release/v1 if: steps.check-tag.outputs.match == 'true' && inputs.publish_on_test_pypi diff --git a/workflows/_release_and_tag.yml b/workflows/_release_and_tag.yml index 4b331f8..cf45e72 100644 --- a/workflows/_release_and_tag.yml +++ b/workflows/_release_and_tag.yml @@ -89,21 +89,6 @@ jobs: echo "match=true" >> $GITHUB_OUTPUT fi - - uses: actions/setup-python@v5 - if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) - with: - python-version: "3.x" - - - name: Install pypa/build - if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) - run: | - python -m pip install build --user - - - name: Build a binary wheel and a source tarball - if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) - run: | - python -m build --sdist --wheel --outdir dist/ - - name: Create Tag and Release id: create-release if: steps.check-tag.outputs.match == 'true' @@ -116,9 +101,6 @@ jobs: prerelease: false target_commitish: ${{ github.base_ref }} append_body: true - files: | - dist/*-${{ github.event.pull_request.title }}*.tar.gz - dist/*-${{ github.event.pull_request.title }}*.whl - name: Checkout created tag uses: actions/checkout@v4 @@ -126,6 +108,30 @@ jobs: with: fetch-depth: 0 # otherwise, you do not retrieve the tags + - uses: actions/setup-python@v5 + if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) + with: + python-version: "3.x" + + - name: Install pypa/build + if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) + run: | + python -m pip install build --user + + - name: Build a binary wheel and a source tarball + if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi || inputs.append_to_release) + run: | + python -m build --sdist --wheel --outdir dist/ + + - name: Update release with assets + id: update-release + if: steps.check-tag.outputs.match == 'true' && inputs.append_to_release + uses: softprops/action-gh-release@v2 + with: + files: | + dist/*-${{ github.ref_name }}*.tar.gz + dist/*-${{ github.ref_name }}*.whl + - name: Publish to test PyPi uses: pypa/gh-action-pypi-publish@release/v1 if: steps.check-tag.outputs.match == 'true' && inputs.publish_on_test_pypi From 09072edea68ce12927d38e130c3c3c18ecb4c0ff Mon Sep 17 00:00:00 2001 From: Luca Cigarini Date: Tue, 7 Oct 2025 11:17:52 +0200 Subject: [PATCH 4/4] updated changelog --- .github/workflows/_release_and_tag.yml | 4 +++- CHANGELOG.md | 4 ++++ workflows/_release_and_tag.yml | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_release_and_tag.yml b/.github/workflows/_release_and_tag.yml index cf45e72..d4f97e2 100644 --- a/.github/workflows/_release_and_tag.yml +++ b/.github/workflows/_release_and_tag.yml @@ -5,7 +5,9 @@ on: branches_that_trigger_release: description: Branches that will trigger a check on the tag. Otherwise, no check will be made. type: string - required: true + required: false + default: >- + ["master", "main", "prod"] append_to_release: description: Append project's wheel and tarball to newly created release diff --git a/CHANGELOG.md b/CHANGELOG.md index d32056d..3a89140 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.1.x +### 2.1.0 +#### Features +* Build and append project assets to Github releases. ## 2.0.x ### 2.0.0 #### Features diff --git a/workflows/_release_and_tag.yml b/workflows/_release_and_tag.yml index cf45e72..d4f97e2 100644 --- a/workflows/_release_and_tag.yml +++ b/workflows/_release_and_tag.yml @@ -5,7 +5,9 @@ on: branches_that_trigger_release: description: Branches that will trigger a check on the tag. Otherwise, no check will be made. type: string - required: true + required: false + default: >- + ["master", "main", "prod"] append_to_release: description: Append project's wheel and tarball to newly created release