0.0.13 #13
Workflow file for this run
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: PyPI Publish | |
on: | |
release: | |
types: [published] | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
run-test: | |
uses: ./.github/workflows/run_test.yml | |
pypi-publish: | |
needs: run-test | |
runs-on: ubuntu-latest | |
environment: release | |
permissions: | |
id-token: write | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Extract release version | |
id: release-version | |
run: echo "::set-output name=version::${{ github.event.release.tag_name }}" | |
- name: Update and validate version in pyproject.toml | |
run: | | |
sed -i "s/version = \"0.0.0\"/version = \"${{ steps.release-version.outputs.version }}\"/" pyproject.toml | |
if ! echo "${{ steps.release-version.outputs.version }}" | grep -Pq '^\d+(\.\d+){2}(-rc\.\d+)?$'; then | |
echo "Invalid version format. Should be semantic versioning." | |
exit 1 | |
fi | |
- name: Install Poetry | |
uses: snok/install-poetry@v1.2 | |
- name: Build Python package | |
run: poetry build | |
- name: Publish to TestPyPI if release candidate | |
if: contains(steps.release-version.outputs.version, 'rc') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
- name: Publish to PyPI if not release candidate | |
if: "!contains(steps.release-version.outputs.version, 'rc')" | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
- name: Validate package on TestPyPI | |
if: contains(steps.release-version.outputs.version, 'rc') | |
run: | | |
PACKAGE_NAME="gull-api" | |
PACKAGE_VERSION="${{ steps.release-version.outputs.version }}" | |
curl --head --fail "https://test.pypi.org/project/${PACKAGE_NAME}/${PACKAGE_VERSION}/" | |
- name: Validate package on PyPI | |
if: "!contains(steps.release-version.outputs.version, 'rc')" | |
run: | | |
PACKAGE_NAME="gull-api" | |
PACKAGE_VERSION="${{ steps.release-version.outputs.version }}" | |
curl --head --fail "https://pypi.org/project/${PACKAGE_NAME}/${PACKAGE_VERSION}/" |