Skip to content

Implement envelope caching #39

Implement envelope caching

Implement envelope caching #39

Workflow file for this run

name: CI
on:
push:
branches:
- main
- alpha
- beta
pull_request:
branches:
- main
- alpha
- beta
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
PYTHON_VERSION: 3.12
jobs:
# Should run on every push and PR
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cargo build
run: cargo build --verbose
- name: Cargo test
run: cargo test --verbose
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install hatch
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Test
run: hatch run test:run
- name: Stubtest
run: hatch run stubcheck
# Should run on every push and PR, but only run semantic-release on push
release:
name: Run semantic-release
runs-on: ubuntu-latest
needs: test
permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Semantic Release
uses: codfish/semantic-release-action@v3
# Only run on push events
if: github.event_name == 'push'
id: semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
plugins: |
[
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
]
outputs:
version: ${{ steps.semantic-release.outputs.release-version || format('0.0.0-dev+{0}', github.sha) }}
published: ${{ steps.semantic-release.outputs.new-release-published || 'false' }}
linux:
runs-on: ${{ matrix.platform.runner }}
needs: release
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
steps:
- uses: actions/checkout@v4
- name: Replace version in Cargo.toml
shell: pwsh
run: (Get-Content -Path Cargo.toml -Raw) -replace 'version = ".*"', 'version = "${{ needs.release.outputs.version }}"' | Set-Content -Path Cargo.toml
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.platform.target }}
path: dist
windows:
runs-on: ${{ matrix.platform.runner }}
needs: release
strategy:
matrix:
platform:
- runner: windows-latest
target: x64
- runner: windows-latest
target: x86
steps:
- uses: actions/checkout@v4
- name: Replace version in Cargo.toml
shell: pwsh
run: (Get-Content -Path Cargo.toml -Raw) -replace 'version = ".*"', 'version = "${{ needs.release.outputs.version }}"' | Set-Content -Path Cargo.toml
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: ${{ matrix.platform.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-${{ matrix.platform.target }}
path: dist
macos:
runs-on: ${{ matrix.platform.runner }}
needs: release
strategy:
matrix:
platform:
- runner: macos-latest
target: x86_64
- runner: macos-14
target: aarch64
steps:
- uses: actions/checkout@v4
- name: Replace version in Cargo.toml
shell: pwsh
run: (Get-Content -Path Cargo.toml -Raw) -replace 'version = ".*"', 'version = "${{ needs.release.outputs.version }}"' | Set-Content -Path Cargo.toml
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.platform.target }}
path: dist
sdist:
runs-on: ubuntu-latest
needs: release
steps:
- uses: actions/checkout@v4
- name: Replace version in Cargo.toml
shell: pwsh
run: (Get-Content -Path Cargo.toml -Raw) -replace 'version = ".*"', 'version = "${{ needs.release.outputs.version }}"' | Set-Content -Path Cargo.toml
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist
# For branch protection rules
check:
if: always()
needs:
- linux
- windows
- macos
- sdist
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
# Should run only on push
publish:
name: Publish to PyPI
needs:
- check
- release
if: needs.release.outputs.published == 'true' && github.event_name == 'push'
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*