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
30 changes: 26 additions & 4 deletions .github/workflows/_release_and_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: >-
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
30 changes: 26 additions & 4 deletions workflows/_release_and_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: >-
Expand Down
Loading