name: Release & Publish
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
github-release:
name: Build Release (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
artifact_name: woven
asset_name: woven-linux-amd64
target: x86_64-unknown-linux-musl
- os: windows-latest
artifact_name: woven.exe
asset_name: woven-windows-amd64.exe
- os: macos-latest
artifact_name: woven
asset_name: woven-macos-amd64
- os: macos-14
artifact_name: woven
asset_name: woven-macos-arm64
steps:
- uses: actions/checkout@v4
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Install musl tools (Linux)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get install -y musl-tools
- name: Build Release
run: cargo build --release --verbose ${{ matrix.target && format('--target {0}', matrix.target) || '' }}
shell: bash
- name: Extract Changelog
shell: bash
run: |
VERSION=${GITHUB_REF#refs/tags/v}
# Extract content between the version header and the next header
sed -n "/## \[$VERSION\]/,/## \[/p" CHANGELOG.md | sed '1d;$d' > release_notes.md
- name: Prepare Asset
shell: bash
run: |
RELEASE_DIR="target/${{ matrix.target && format('{0}/release', matrix.target) || 'release' }}"
mv "$RELEASE_DIR/${{ matrix.artifact_name }}" "$RELEASE_DIR/${{ matrix.asset_name }}"
echo "ASSET_PATH=$RELEASE_DIR/${{ matrix.asset_name }}" >> "$GITHUB_ENV"
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v1
with:
files: ${{ env.ASSET_PATH }}
body_path: release_notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
crates-io-publish:
name: Publish to Crates.io
needs: github-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Publish to Crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish