Skip to content

Commit

Permalink
ci: Update wheel building CI (#78)
Browse files Browse the repository at this point in the history
Setups the CI to publish to pypi when a release tagged `quizx-py-*` is
created.

drive-by: Add random config file to gitignore
  • Loading branch information
ABorgna authored Oct 30, 2024
1 parent a7c3080 commit 7e49d13
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 43 deletions.
57 changes: 36 additions & 21 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
# This file is autogenerated by maturin v1.7.4
# This based on the one autogenerated by maturin v1.7.4
# To update, run
#
# maturin generate-ci github
# maturin generate-ci github > .github/workflows/python-wheels.yml
#
name: CI
# and merge in the changes.
#
name: Build wheels

on:
push:
branches:
- main
- master
tags:
- '*'
release:
types:
- published
workflow_dispatch:

permissions:
contents: read

jobs:
# Check if the tag matches the package name,
# or if the workflow is running on a non-release event.
check-tag:
name: Check tag
runs-on: ubuntu-latest
outputs:
run: ${{ steps.check-tag.outputs.run }}
steps:
- name: Check tag
id: check-tag
run: |
echo "run=$SHOULD_RUN" >> $GITHUB_OUTPUT
env:
SHOULD_RUN: ${{ github.event_name != 'release' || ( github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/quizx-py-v') ) }}

linux:
needs: check-tag
if: ${{ needs.check-tag.outputs.run == 'true' }}
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
Expand Down Expand Up @@ -54,6 +73,8 @@ jobs:
path: dist

musllinux:
needs: check-tag
if: ${{ needs.check-tag.outputs.run == 'true' }}
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
Expand All @@ -78,13 +99,16 @@ jobs:
args: --release --out dist --find-interpreter
sccache: 'true'
manylinux: musllinux_1_2
working-directory: ${{ env.MODULE_DIR }}
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-musllinux-${{ matrix.platform.target }}
path: dist

windows:
needs: check-tag
if: ${{ needs.check-tag.outputs.run == 'true' }}
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
Expand Down Expand Up @@ -112,6 +136,8 @@ jobs:
path: dist

macos:
needs: check-tag
if: ${{ needs.check-tag.outputs.run == 'true' }}
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
Expand All @@ -131,13 +157,16 @@ jobs:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
working-directory: ${{ env.MODULE_DIR }}
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.platform.target }}
path: dist

sdist:
needs: check-tag
if: ${{ needs.check-tag.outputs.run == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -155,25 +184,11 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' }}
if: ${{ (github.event_name == 'release' && github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/quizx-py-v') ) || (github.event_name == 'workflow_dispatch' && github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/quizx-py-v') ) }}
needs: [linux, musllinux, windows, macos, sdist]
permissions:
# Use to sign the release artifacts
id-token: write
# Used to upload release artifacts
contents: write
# Used to generate artifact attestation
attestations: write
steps:
- uses: actions/download-artifact@v4
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-path: 'wheels-*/*'
- name: Publish to PyPI
# TODO: Disabled until the package is ready for release
if: false
# if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ dist
data
quizx.egg-info
libquizx.egg-info
.vscode
22 changes: 0 additions & 22 deletions .vscode/settings.json

This file was deleted.

0 comments on commit 7e49d13

Please sign in to comment.