Skip to content

Commit

Permalink
Merge pull request #77 from qua-platform/release-pypi
Browse files Browse the repository at this point in the history
Add CI for publishing to PyPI (test) on publish release
  • Loading branch information
nulinspiratie authored Oct 10, 2024
2 parents 4d7435e + 5179751 commit a43938f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ on:
jobs:
build:
uses: qua-platform/quam/.github/workflows/reusable-build.yaml@main
with:
ref: ${{ env.GITHUB_REF_NAME }}
release:
runs-on: ubuntu-latest
needs:
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/release_pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release

on:
release:
types: [ published ]
workflow_dispatch:
inputs:
ref:
type: string
description: Ref to checkout
required: true
env:
# make sure the poetry creates the venv inside the workspace under .venv
POETRY_VIRTUALENVS_IN_PROJECT: true

jobs:
build-release:
name: Publish from release
if: github.event_name == 'release'
uses: qua-platform/quam/.github/workflows/reusable-build.yaml@main
build-manually:
name: Publish from manual trigger
if: github.event_name == 'workflow_dispatch'
uses: qua-platform/quam/.github/workflows/reusable-build.yaml@main
with:
ref: ${{inputs.ref}}

release:
name: Release package to PyPi
runs-on: ubuntu-latest
needs:
- build-release
- build-manually
if: | # TODO: remove when only release trigger be kept
always()
&& contains(needs.*.result, 'success')
&& !contains(needs.*.result, 'failure')
permissions:
id-token: write
contents: read
checks: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# This is necessary so that we have the tags.
fetch-depth: 0
ref: ${{inputs.ref}}

- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
pattern: python-package-*

- name: Publish distribution to PyPI
uses: pypa/[email protected]
with:
repository-url: https://test.pypi.org/legacy/
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# password: ${{ secrets.PYPI_API_TOKEN }}
8 changes: 6 additions & 2 deletions .github/workflows/reusable-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@

name: Build python package
on:
workflow_call
workflow_call:
inputs:
ref:
type: string
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}

- uses: actions/setup-python@v5
with:
python-version: "3.8"
cache: "pip"


- name: Install python deps
run: python -m pip install -e .[build]

Expand Down

0 comments on commit a43938f

Please sign in to comment.