diff --git a/.github/workflows/_release_and_tag.yml b/.github/workflows/_release_and_tag.yml index 92bf029..d4f97e2 100644 --- a/.github/workflows/_release_and_tag.yml +++ b/.github/workflows/_release_and_tag.yml @@ -2,6 +2,19 @@ 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: string + required: false + default: >- + ["master", "main", "prod"] + + 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,7 +85,7 @@ 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 @@ -98,20 +111,29 @@ jobs: 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) + 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) + 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) + 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/.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/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 92bf029..d4f97e2 100644 --- a/workflows/_release_and_tag.yml +++ b/workflows/_release_and_tag.yml @@ -2,6 +2,19 @@ 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: string + required: false + default: >- + ["master", "main", "prod"] + + 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,7 +85,7 @@ 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 @@ -98,20 +111,29 @@ jobs: 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) + 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) + 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) + 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.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: >-