Skip to content

Deploy a new version #6

Deploy a new version

Deploy a new version #6

Workflow file for this run

name: Deploy a new version
on:
workflow_dispatch:
inputs:
version_tag:
description: 'Version tag'
required: true
default: v0.1.0
dry_run:
type: boolean
description: 'Dry run'
default: false
jobs:
dry-run:
if: ${{ github.event.inputs.dry_run == 'true' }}
runs-on: ubuntu-latest
environment: mkdocs
steps:
- uses: actions/checkout@v4
- name: Push new version tag temporarily for changelog generation
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git tag -a ${{ github.event.inputs.version_tag }} -m ${{ github.event.inputs.version_tag }}
git push --tags
- name: Get CHANGELOG
id: changelog-dry-run
uses: requarks/changelog-action@v1.10.2
with:
includeInvalidCommits: true
excludeTypes: build,docs,style,other
token: ${{ github.token }}
tag: ${{ github.event.inputs.version_tag }}
- name: Display CHANGELOG
run: |
echo '${{ steps.changelog-dry-run.outputs.changes }}'
echo '${{ steps.changelog-dry-run.outputs.changes }}' > "$GITHUB_STEP_SUMMARY"
- name: Remove temporary version tag
run: |
git tag -d ${{ github.event.inputs.version_tag }}
git push origin --delete ${{ github.event.inputs.version_tag }}
deploy:
if: ${{ github.event.inputs.dry_run == 'false' }}
runs-on: ubuntu-latest
environment: mkdocs
steps:
- uses: actions/checkout@v4
- name: Push new version tag temporarily for changelog generation
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git tag -a ${{ github.event.inputs.version_tag }} -m ${{ github.event.inputs.version_tag }}
git push --tags
- name: Update CHANGELOG
id: changelog
uses: requarks/changelog-action@v1.10.2
with:
includeInvalidCommits: true
excludeTypes: build,docs,style,other
token: ${{ github.token }}
tag: ${{ github.event.inputs.version_tag }}
changelogFilePath: docs/CHANGELOG.md
- name: Commit docs/CHANGELOG.md and update tag
run: |
git tag -d ${{ github.event.inputs.version_tag }}
git push origin --delete ${{ github.event.inputs.version_tag }}
git add docs/CHANGELOG.md
git commit -m "docs: update docs/CHANGELOG.md for ${{ github.event.inputs.version_tag }} [skip ci]"
git tag -a ${{ github.event.inputs.version_tag }} -m ${{ github.event.inputs.version_tag }}
git push
git push --tags
- name: Create Release
uses: ncipollo/release-action@v1.14.0
with:
allowUpdates: true
draft: false
makeLatest: true
name: ${{ github.event.inputs.version_tag }}
tag: ${{ github.event.inputs.version_tag }}
body: ${{ steps.changelog.outputs.changes }}
# Below is generated by maturin
linux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: x86
- runner: ubuntu-latest
target: aarch64
- runner: ubuntu-latest
target: armv7
- runner: ubuntu-latest
target: s390x
- runner: ubuntu-latest
target: ppc64le
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Update version in Cargo.toml
run: |
pip3 install toml
python3 scripts/update_version_in_cargo_toml.py ${{ github.event.inputs.version_tag }}
- 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 }}
strategy:
matrix:
platform:
- runner: windows-latest
target: x64
- runner: windows-latest
target: x86
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: ${{ matrix.platform.target }}
- name: Update version in Cargo.toml
run: |
pip3 install toml
python3 scripts/update_version_in_cargo_toml.py ${{ github.event.inputs.version_tag }}
- 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 }}
strategy:
matrix:
platform:
- runner: macos-latest
target: x86_64
- runner: macos-14
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Update version in Cargo.toml
run: |
pip3 install toml
python3 scripts/update_version_in_cargo_toml.py ${{ github.event.inputs.version_tag }}
- 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
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Update version in Cargo.toml
run: |
pip3 install toml
python3 scripts/update_version_in_cargo_toml.py ${{ github.event.inputs.version_tag }}
- 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
release:
name: Release
if: ${{ github.event.inputs.dry_run == 'false' }}
runs-on: ubuntu-latest
needs: [linux, windows, macos, sdist]
steps:
- uses: actions/download-artifact@v4
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*