release #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: The version to release, without the leading `v`. | |
type: string | |
required: true | |
env: | |
name: changelogging | |
bot-name: nekit[bot] | |
bot-email: [email protected] | |
changelog: CHANGELOG-${{ inputs.version }}.md | |
jobs: | |
bootstrap: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Build changelog ${{ inputs.version }} | |
run: cargo run preview > ${{ env.changelog }} | |
- name: Upload changelog ${{ inputs.version }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: changelog | |
path: ${{ env.changelog }} | |
- name: Build changelog | |
run: cargo run build --stage --remove | |
- name: Setup bot user | |
run: | | |
git config --local user.name ${{ env.bot-name }} | |
git config --local user.email ${{ env.bot-email }} | |
- name: Commit and push | |
run: | | |
git commit -m "Add ${{ inputs.version }} to the changelog." | |
git push | |
tag: | |
runs-on: ubuntu-latest | |
needs: bootstrap | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup bot user | |
run: | | |
git config --local user.name ${{ env.bot-name }} | |
git config --local user.email ${{ env.bot-email }} | |
- name: Tag and push | |
run: | | |
git tag v${{ inputs.version }} | |
git push --tags | |
build-source: | |
runs-on: ubuntu-latest | |
needs: tag | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build source | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: sdist | |
args: --out dist | |
- name: Upload source | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-source | |
path: dist | |
build-macos: | |
runs-on: macos-latest | |
needs: tag | |
strategy: | |
matrix: | |
target: | |
- x86_64-apple-darwin | |
- aarch64-apple-darwin | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build wheel | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
args: --release --out dist | |
- name: Upload wheel | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ matrix.target }} | |
path: dist | |
- name: Archive binary | |
run: | | |
ARCHIVE=${{ env.name }}-${{ inputs.version }}-${{ matrix.target }}.tar.gz | |
tar -czvf $ARCHIVE -C target/${{ matrix.target }}/release ${{ env.name }} | |
shasum -a 256 $ARCHIVE > $ARCHIVE.sha256 | |
- name: Upload binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries-${{ matrix.target }} | |
path: | | |
*.tar.gz | |
*.sha256 | |
build-windows: | |
runs-on: windows-latest | |
needs: tag | |
strategy: | |
matrix: | |
target: | |
- x86_64-pc-windows-msvc | |
- i686-pc-windows-msvc | |
- aarch64-pc-windows-msvc | |
env: | |
XWIN_VERSION: 16 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build wheel | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
args: --release --out dist | |
- name: Upload wheel | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ matrix.target }} | |
path: dist | |
- name: Archive binary | |
shell: bash | |
run: | | |
ARCHIVE=${{ env.name }}-${{ inputs.version }}-${{ matrix.target }}.zip | |
7z a $ARCHIVE ./target/${{ matrix.target }}/release/${{ env.name }}.exe | |
sha256sum $ARCHIVE > $ARCHIVE.sha256 | |
- name: Upload binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries-${{ matrix.target }} | |
path: | | |
*.zip | |
*.sha256 | |
build-linux: | |
runs-on: ubuntu-latest | |
needs: tag | |
strategy: | |
matrix: | |
target: | |
- x86_64-unknown-linux-gnu | |
- i686-unknown-linux-gnu | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build wheel | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
manylinux: auto | |
args: --release --out dist | |
- name: Upload wheel | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ matrix.target }} | |
path: dist | |
- name: Archive binary | |
run: | | |
ARCHIVE=${{ env.name }}-${{ inputs.version }}-${{ matrix.target }}.tar.gz | |
tar -czvf $ARCHIVE -C target/${{ matrix.target }}/release ${{ env.name }} | |
shasum -a 256 $ARCHIVE > $ARCHIVE.sha256 | |
- name: Upload binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries-${{ matrix.target }} | |
path: | | |
*.tar.gz | |
*.sha256 | |
build-linux-cross: | |
runs-on: ubuntu-latest | |
needs: tag | |
strategy: | |
matrix: | |
target: | |
- aarch64-unknown-linux-gnu | |
- armv7-unknown-linux-gnueabihf | |
- s390x-unknown-linux-gnu | |
- powerpc64le-unknown-linux-gnu | |
- powerpc64-unknown-linux-gnu | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build wheel | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
manylinux: auto | |
args: --release --out dist | |
- name: Upload wheel | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ matrix.target }} | |
path: dist | |
- name: Archive binary | |
run: | | |
ARCHIVE=${{ env.name }}-${{ inputs.version }}-${{ matrix.target }}.tar.gz | |
tar -czvf $ARCHIVE -C target/${{ matrix.target }}/release ${{ env.name }} | |
shasum -a 256 $ARCHIVE > $ARCHIVE.sha256 | |
- name: Upload binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries-${{ matrix.target }} | |
path: | | |
*.tar.gz | |
*.sha256 | |
build-musl: | |
runs-on: ubuntu-latest | |
needs: tag | |
strategy: | |
matrix: | |
target: | |
- x86_64-unknown-linux-musl | |
- i686-unknown-linux-musl | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build wheel | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
manylinux: musllinux_1_2 | |
args: --release --out dist | |
- name: Upload wheel | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ matrix.target }} | |
path: dist | |
- name: Archive binary | |
run: | | |
ARCHIVE=${{ env.name }}-${{ inputs.version }}-${{ matrix.target }}.tar.gz | |
tar -czvf $ARCHIVE -C target/${{ matrix.target }}/release ${{ env.name }} | |
shasum -a 256 $ARCHIVE > $ARCHIVE.sha256 | |
- name: Upload binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries-${{ matrix.target }} | |
path: | | |
*.tar.gz | |
*.sha256 | |
build-musl-cross: | |
runs-on: ubuntu-latest | |
needs: tag | |
strategy: | |
matrix: | |
target: | |
- aarch64-unknown-linux-musl | |
- armv7-unknown-linux-musleabihf | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build wheel | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
manylinux: musllinux_1_2 | |
args: --release --out dist | |
- name: Upload wheel | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ matrix.target }} | |
path: dist | |
- name: Archive binary | |
run: | | |
ARCHIVE=${{ env.name }}-${{ inputs.version }}-${{ matrix.target }}.tar.gz | |
tar -czvf $ARCHIVE -C target/${{ matrix.target }}/release ${{ env.name }} | |
shasum -a 256 $ARCHIVE > $ARCHIVE.sha256 | |
- name: Upload binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries-${{ matrix.target }} | |
path: | | |
*.tar.gz | |
*.sha256 | |
publish-python: | |
runs-on: ubuntu-latest | |
needs: | |
- build-source | |
- build-macos | |
- build-windows | |
- build-linux | |
- build-linux-cross | |
- build-musl | |
- build-musl-cross | |
permissions: | |
id-token: write | |
steps: | |
- name: Download wheels | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: wheels-* | |
path: wheels | |
merge-multiple: true | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
skip-existing: true | |
packages-dir: wheels | |
publish-release: | |
needs: publish-python | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Download changelog | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: changelog | |
merge-multiple: true | |
- name: Download binaries | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: binaries-* | |
path: binaries | |
merge-multiple: true | |
- name: Publish to GitHub | |
uses: softprops/action-gh-release@v2 | |
with: | |
body_path: ${{ env.changelog }} | |
files: binaries/* | |
tag_name: v${{ inputs.version }} | |
token: ${{ secrets.BOT_TOKEN }} | |
publish-crate: | |
needs: publish-release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Publish crate | |
run: cargo publish --token ${{ secrets.CARGO_TOKEN }} |