.github/workflows/publish.yml #33
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: Publish Release | |
on: | |
workflow_dispatch: | |
### TODO: Replace instances of './.github/actions/' with reference to the `dx-sdk-actions` repo is made public and this file is transferred over | |
### TODO: Also remove `get-prerelease`, `get-version`, `release-create`, `tag-create` and `tag-exists` actions from this repo's .github/actions folder once the repo is public. | |
permissions: | |
contents: write | |
id-token: write # Required for trusted publishing to PyPI | |
jobs: | |
publish-pypi: | |
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/')) | |
name: "PyPI" | |
runs-on: ubuntu-latest | |
environment: release | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
# Get the version from the branch name | |
- id: get_version | |
uses: ./.github/actions/get-version | |
# Get the prerelease flag from the branch name | |
- id: get_prerelease | |
uses: ./.github/actions/get-prerelease | |
with: | |
version: ${{ steps.get_version.outputs.version }} | |
# Get the release notes | |
# This will expose the release notes as env.RELEASE_NOTES | |
- id: get_release_notes | |
uses: ./.github/actions/get-release-notes | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
version: ${{ steps.get_version.outputs.version }} | |
repo_owner: ${{ github.repository_owner }} | |
repo_name: ${{ github.event.repository.name }} | |
# Create a release for the tag | |
- uses: ./.github/actions/release-create | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: ${{ steps.get_version.outputs.version }} | |
body: ${{ steps.get_release_notes.outputs.release-notes }} | |
tag: ${{ steps.get_version.outputs.version }} | |
commit: ${{ github.sha }} | |
prerelease: ${{ steps.get_prerelease.outputs.prerelease }} | |
- name: Configure Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.8" | |
- name: Configure dependencies | |
run: | | |
pip install --user --upgrade pip | |
pip install --user pipx | |
pipx ensurepath | |
pipx install poetry==1.4.2 | |
poetry config virtualenvs.in-project true | |
poetry install --with dev | |
poetry self add "poetry-dynamic-versioning[plugin]==1.1.1" | |
- name: Build release | |
run: | | |
poetry build | |
- name: Publish release | |
uses: pypa/gh-action-pypi-publish@release/v1 |