name: Release
run-name: Release v${{ inputs.version }} with apply=${{ inputs.apply }}
on:
workflow_dispatch:
inputs:
version:
description: version. The next release version (without prefix v)
required: true
apply:
description: apply. Specify whether the actual release should be performed or not
type: boolean
permissions: {}
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
suffix: .tar.gz
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
suffix: .tar.gz
- target: x86_64-apple-darwin
os: macOS-latest
suffix: .tar.gz
- target: aarch64-apple-darwin
os: macOS-latest
suffix: .tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
suffix: .zip
- target: aarch64-pc-windows-msvc
os: windows-latest
suffix: .zip
runs-on: ${{ matrix.os }}
permissions:
contents: read
steps:
- run: sudo apt-get update --yes && sudo apt-get install --yes --no-install-recommends libx11-xcb-dev libxcb-shape0-dev libxcb-xfixes0-dev musl-tools
if: matrix.os == 'ubuntu-latest'
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
with:
toolchain: stable
target: ${{ matrix.target }}
- name: Install cross
if: matrix.os == 'ubuntu-latest'
run: cargo install cross
- name: Build with Cargo
if: matrix.os != 'ubuntu-latest'
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Build with Cross
if: matrix.os == 'ubuntu-latest'
run: cross build --release --locked --target ${{ matrix.target }}
- name: Bundle on Windows
run: 7z a ../../../thwack-${{ matrix.target }}${{ matrix.suffix }} thwack.exe
if: matrix.os == 'windows-latest'
working-directory: target/${{ matrix.target }}/release
- name: Bundle on -nix
run: tar cf ../../../thwack-${{ matrix.target }}${{ matrix.suffix }} thwack
if: matrix.os != 'windows-latest'
working-directory: target/${{ matrix.target }}/release
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f with:
name: Artifact-thwack-${{ matrix.target }}${{ matrix.suffix }}
path: thwack-${{ matrix.target }}${{ matrix.suffix }}
release:
runs-on: ubuntu-latest
needs: build
steps:
- run: sudo apt-get update --yes && sudo apt-get install --yes --no-install-recommends libx11-xcb-dev libxcb-shape0-dev libxcb-xfixes0-dev
- uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
token: ${{ steps.app-token.outputs.token }}
persist-credentials: true
- uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
with:
toolchain: stable
- name: Bump the package version
run: |
sed -i -e "s/^version = .*$/version = \"${INPUTS_VERSION}\"/" Cargo.toml
cargo build
env:
INPUTS_VERSION: ${{ inputs.version }}
- uses: yykamei/actions-git-push@8ae8cff5a3dc70f40645250bd9e59e2979a2543c
with:
commit-message: Bump to ${{ inputs.version }}
if: inputs.apply
- name: Create a GitHub release and publish the crate on crates.io
run: ./scripts/release.sh
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
VERSION: ${{ inputs.version }}
APPLY: ${{ inputs.apply }}
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
- name: Calculate checksums
run: |
mv Artifact-thwack-*/thwack-* .
for f in thwack-*; do sha256sum "$f" | awk '{print $1}' > "${f}.sha256"; done
- name: Upload assets to the release
if: inputs.apply
run: gh release upload "v${INPUTS_VERSION}" thwack-*
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
INPUTS_VERSION: ${{ inputs.version }}