| 1 |
name: Build and Publish Package |
| 2 |
|
| 3 |
on: |
| 4 |
pull_request: |
| 5 |
branches: |
| 6 |
- main |
| 7 |
types: |
| 8 |
- closed |
| 9 |
|
| 10 |
jobs: |
| 11 |
publish-package: |
| 12 |
if: ${{ github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v') }} |
| 13 |
runs-on: ubuntu-latest |
| 14 |
environment: publish |
| 15 |
permissions: |
| 16 |
id-token: write |
| 17 |
|
| 18 |
steps: |
| 19 |
- name: Check out repo main branch |
| 20 |
uses: actions/checkout@v5 |
| 21 |
with: |
| 22 |
ref: main |
| 23 |
|
| 24 |
- name: Set up Python 3.10 |
| 25 |
uses: actions/setup-python@v6 |
| 26 |
with: |
| 27 |
python-version-file: ".python-version" |
| 28 |
|
| 29 |
- name: Install uv |
| 30 |
uses: astral-sh/setup-uv@v6 |
| 31 |
with: |
| 32 |
version: "0.9.3" |
| 33 |
|
| 34 |
- name: Get project Version |
| 35 |
id: project_version |
| 36 |
run: echo "project_version=$(uv version --short)" >> $GITHUB_OUTPUT |
| 37 |
|
| 38 |
- name: Build package |
| 39 |
run: uv build --all-packages |
| 40 |
|
| 41 |
- name: Publish package to PyPI |
| 42 |
uses: pypa/gh-action-pypi-publish@release/v1 |
| 43 |
|
| 44 |
- name: Create a Github Release |
| 45 |
uses: softprops/action-gh-release@v2 |
| 46 |
with: |
| 47 |
tag_name: v${{ steps.project_version.outputs.project_version }} |
| 48 |
target_commitish: main |
| 49 |
token: ${{ secrets.HARLEQUIN_PG_RELEASE_TOKEN }} |
| 50 |
body_path: CHANGELOG.md |
| 51 |
files: | |
| 52 |
LICENSE |
| 53 |
dist/**.whl |
| 54 |
dist/**.tar.gz |