Skip to content

Fix actions folder

Fix actions folder #23

Workflow file for this run

name: Publish Release
on:
pull_request:
types:
- closed
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: read
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 }}
# Check if the tag already exists
- id: tag_exists
uses: ./.github/actions/tag-exists
with:
tag: ${{ steps.get_version.outputs.version }}
token: ${{ secrets.github-token }}
# If the tag already exists, exit with an error
- if: steps.tag_exists.outputs.exists == 'true'
run: exit 1
- 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
# 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 }}