Release #25
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 | |
permissions: | |
contents: write | |
env: | |
toolchain: stable | |
jobs: | |
details: | |
name: Release details | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
tag: ${{ steps.version.outputs.tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
# OS-specific | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('release/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Install dependencies | |
run: python -m pip install -r release/requirements.txt | |
shell: bash | |
- name: Version details | |
id: version | |
run: | | |
echo "::set-output name=version::`python -m release version`" | |
echo "::set-output name=tag::`python -m release version --tag`" | |
shell: bash | |
release: | |
name: GitHub release | |
needs: details | |
runs-on: ubuntu-latest | |
steps: | |
# Necessary to implicitly specify the repo to create the release for. | |
- uses: actions/checkout@v4 | |
- name: Create release | |
run: gh release create ${{ needs.details.outputs.tag }} --draft --generate-notes | |
shell: bash | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build: | |
name: Build ${{ matrix.target }} | |
needs: [details, release] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
# https://doc.rust-lang.org/stable/rustc/platform-support.html | |
# https://github.com/rust-embedded/cross#supported-targets | |
include: | |
- target: aarch64-apple-darwin | |
os: macos-11 | |
use-cross: false | |
- target: x86_64-apple-darwin | |
os: macos-latest | |
use-cross: false | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
use-cross: false | |
- target: aarch64-unknown-linux-gnu | |
os: ubuntu-latest | |
use-cross: true | |
- target: riscv64gc-unknown-linux-gnu | |
os: ubuntu-latest | |
use-cross: true | |
- target: x86_64-unknown-netbsd | |
os: ubuntu-latest | |
use-cross: true | |
steps: | |
- uses: actions/checkout@v4 | |
# OS-specific | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('release/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Install dependencies | |
run: python -m pip install -r release/requirements.txt | |
shell: bash | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ env.toolchain }} | |
target: ${{ matrix.target }} | |
override: true | |
profile: minimal | |
- name: Cargo build | |
uses: actions-rs/cargo@v1 | |
with: | |
toolchain: ${{ env.toolchain }} | |
use-cross: ${{ matrix.use-cross }} | |
command: build | |
args: --release --target ${{ matrix.target }} | |
- name: Create tarball | |
run: | | |
TARBALL_PATH=`python -m release tarball --target ${{ matrix.target }}` | |
du -h $TARBALL_PATH | |
tar -tvf $TARBALL_PATH | |
echo "tarball_path=$TARBALL_PATH" >> $GITHUB_ENV | |
shell: bash | |
- name: Upload tarball | |
run: gh release upload ${{ needs.details.outputs.tag }} ${{ env.tarball_path }} --clobber | |
shell: bash | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish: | |
name: Publish to crates.io | |
needs: release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ env.toolchain }} | |
override: true | |
profile: minimal | |
- name: Publish | |
run: cargo publish --locked | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |