name: Release
on:
workflow_dispatch:
inputs:
tag:
type: string
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist
sccache: 'true'
manylinux: auto
- name: Build archives
run: |
for dir in target/*/
do
TARGET_TRIPLE=$(basename $dir)
if [ "$TARGET_TRIPLE" == 'release' ]; then
continue
fi
ARCHIVE_FILE=nbwipers-${TARGET_TRIPLE}.tar.gz
echo $ARCHIVE_FILE
tar czvf $ARCHIVE_FILE -C ${dir}release nbwipers
shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
done
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.target }}-linux
path: dist
- name: "Upload binary"
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.target }}-linux
path: |
*.tar.gz
*.sha256
windows:
runs-on: windows-latest
strategy:
matrix:
target: [x64, x86] steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist
sccache: 'true'
- name: Build archives
shell: bash
run: |
for dir in target/*/
do
TARGET_TRIPLE=$(basename $dir)
if [ "$TARGET_TRIPLE" == 'release' ]; then
continue
fi
ARCHIVE_FILE=nbwipers-${TARGET_TRIPLE}.zip
echo $ARCHIVE_FILE
7z a $ARCHIVE_FILE ./${dir}release/nbwipers.exe
sha256sum $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
done
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.target }}-windows
path: dist
- name: "Upload binary"
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.target }}-windows
path: |
*.zip
*.sha256
macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist
sccache: 'true'
- name: Build archives
run: |
for dir in target/*/
do
TARGET_TRIPLE=$(basename $dir)
if [ "$TARGET_TRIPLE" == 'release' ]; then
continue
fi
ARCHIVE_FILE=nbwipers-${TARGET_TRIPLE}.tar.gz
echo $ARCHIVE_FILE
tar czvf $ARCHIVE_FILE -C ${dir}/release nbwipers
shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
done
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.target }}-macos
path: dist
- name: "Upload binary"
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.target }}-macos
path: |
*.tar.gz
*.sha256
sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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
check_tag:
runs-on: ubuntu-latest
if: ${{ inputs.tag }}
steps:
- uses: actions/checkout@v4
- name: Get package version
id: cargo-get
uses: nicolaiunrein/cargo-get@v1.1.0
with:
subcommand: package.version --pretty
- name: check matches
run: |
if [ "${{ steps.cargo-get.outputs.metadata }}" != "${{ inputs.tag }}" ]; then
echo "package version ${{ steps.cargo-get.outputs.metadata }} does not match tag ${{ inputs.tag }}" >&2
exit 1;
else
echo "Releasing ${{ inputs.tag }}"
fi
release_github:
name: Release
runs-on: ubuntu-latest
needs: [linux, windows, macos, sdist, check_tag]
permissions:
contents: write
environment: release
env:
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: wheels
- uses: actions/download-artifact@v4
with:
pattern: binaries-*
merge-multiple: true
path: binaries
- run: |
gh release create ${{ inputs.tag }} --generate-notes -d wheels/* binaries/*
release_pypi:
name: Release PyPI
runs-on: ubuntu-latest
needs: [release_github]
environment: release
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
- 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 *
release_crate:
name: Release crates
runs-on: ubuntu-latest
needs: [release_github]
environment: release
steps:
- uses: actions/checkout@v4
- run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}