release #15
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: | |
type: choice | |
required: true | |
description: 'Version number to bump' | |
options: | |
- patch | |
- minor | |
- major | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
jobs: | |
publish-dry-run: | |
name: "Runs cargo publish --dry-run" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: publish crate | |
run: cargo publish --dry-run | |
release: | |
name: Create Release | |
needs: publish-dry-run | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install `cargo-edit` | |
run: cargo install cargo-edit | |
- id: cargo-set-version | |
name: Set Version | |
run: cargo set-version --bump ${{ inputs.version }} | |
- name: Set Crate Version as Environment Variable | |
run: | | |
CARGO_TOML_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/[\"]/, "", $2); printf("%s",$2) }' Cargo.toml) | |
echo "CRATE_VERSION=$CARGO_TOML_VERSION" >> $GITHUB_ENV | |
- name: Create Commit | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git add . | |
git commit -m "chore: bump version to v$CRATE_VERSION" | |
git push origin main --follow-tags | |
- name: Login to Crates.io | |
run: cargo login ${CRATES_IO_TOKEN} | |
env: | |
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | |
- name: Publish crate | |
run: cargo publish | |
- name: Create Release | |
id: create_release | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
await github.request(`POST /repos/${{ github.repository }}/releases`, { | |
tag_name: "v${{ env.CRATE_VERSION }}", | |
generate_release_notes: true | |
}); | |
artifacts: | |
needs: release | |
name: Upload Artifacts ${{ matrix.name }} | |
runs-on: ${{ matrix.os }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
strategy: | |
matrix: | |
name: | |
- linux-x64-musl | |
- macos-x64 | |
- macos-aarch64 | |
include: | |
- name: linux-x64-musl | |
os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
exe: wait-on | |
- name: macos-x64 | |
os: macos-latest | |
target: x86_64-apple-darwin | |
exe: wait-on | |
- name: macos-aarch64 | |
os: macos-latest | |
target: aarch64-apple-darwin | |
exe: wait-on | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set Crate Version as Environment Variable | |
run: | | |
CARGO_TOML_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/[\"]/, "", $2); printf("%s",$2) }' Cargo.toml) | |
echo "CRATE_VERSION=$CARGO_TOML_VERSION" >> $GITHUB_ENV | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Install ${{ matrix.name }} System Dependencies | |
if: matrix.name == 'linux-x64-musl' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y musl-tools | |
- name: Build for Release | |
run: cargo build --release --target ${{ matrix.target }} | |
- name: Prepare Binary | |
shell: bash | |
run: | | |
chmod +x ./target/${{ matrix.target }}/release/${{ matrix.exe }} | |
cp ./target/${{ matrix.target }}/release/${{ matrix.exe }} ./wait-on-${{ matrix.target }} | |
- name: Attach Binary | |
uses: svenstaro/[email protected] | |
with: | |
asset_name: wait-on-${{ matrix.target }} | |
file: wait-on-${{ matrix.target }} | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
tag: "v${{ env.CRATE_VERSION }}" |