Skip to content

Commit

Permalink
update build-package workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
thunn committed Nov 12, 2024
1 parent 52fb00e commit 35d5347
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/build-package.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Build Package
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
jobs:
build:
Expand All @@ -16,10 +18,38 @@ jobs:
curl -sSL https://install.python-poetry.org | python3 -
- name: Install dependencies
run: poetry install --no-root
- name: Check version matches tag
if: startsWith(github.ref, 'refs/tags/')
run: |
# Extract tag without 'v' prefix
TAG_VERSION=${GITHUB_REF#refs/tags/v}
# Get package version from poetry
PACKAGE_VERSION=$(poetry version -s)
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
echo "Tag version ($TAG_VERSION) does not match package version ($PACKAGE_VERSION)"
exit 1
fi
- name: Build package
run: poetry build
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
publish:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Download built package
uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/

0 comments on commit 35d5347

Please sign in to comment.