Release #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Release | |
# Trigger this workflow manually or after testing (main branch only). | |
on: | |
workflow_dispatch: | |
workflow_run: | |
workflows: | |
- Test | |
branches: | |
- main | |
types: | |
- completed | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
release: | |
if: github.event.workflow_run.conclusion == 'success' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- uses: actions/cache/restore@v3 | |
with: | |
key: workdir-${{ github.sha }} | |
path: . | |
- id: release | |
uses: python-semantic-release/python-semantic-release@v8.3.0 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/cache/save@v3 | |
with: | |
key: release-${{ github.sha }} | |
path: . | |
outputs: | |
released: ${{ steps.release.outputs.released }} | |
tag: ${{ steps.release.outputs.tag }} | |
build: | |
needs: release | |
if: needs.release.outputs.released == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/cache/restore@v3 | |
with: | |
key: release-${{ github.sha }} | |
path: . | |
- run: pip install build && python -m build | |
- uses: actions/cache/save@v3 | |
with: | |
key: build-${{ github.sha }} | |
path: . | |
testpypi: | |
needs: | |
- release | |
- build | |
if: needs.release.outputs.released == 'true' | |
runs-on: ubuntu-latest | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/stuart | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/cache/restore@v3 | |
with: | |
key: build-${{ github.sha }} | |
path: . | |
- name: Publish package distributions to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
print-hash: true | |
repository-url: https://test.pypi.org/legacy/ | |
verbose: true | |
pypi: | |
needs: | |
- release | |
- build | |
- testpypi | |
if: needs.release.outputs.released == 'true' | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/stuart | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/cache/restore@v3 | |
with: | |
key: build-${{ github.sha }} | |
path: . | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
print-hash: true | |
verbose: true | |
github: | |
needs: | |
- release | |
- build | |
if: needs.release.outputs.released == 'true' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- uses: actions/cache/restore@v3 | |
with: | |
key: build-${{ github.sha }} | |
path: . | |
- name: Publish package distributions to GitHub Releases | |
uses: python-semantic-release/upload-to-gh-release@main | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ needs.release.outputs.tag }} |