name: Release
on:
push:
tags:
- 'v*'
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
artifact: guidebook-linux-x86_64.tar.gz
- os: macos-latest
target: x86_64-apple-darwin
artifact: guidebook-darwin-x86_64.tar.gz
- os: macos-latest
target: aarch64-apple-darwin
artifact: guidebook-darwin-arm64.tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact: guidebook-windows-x86_64.zip
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
run: rustup target add ${{ matrix.target }}
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}
- name: Create release archive (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar -czvf ../../../${{ matrix.artifact }} guidebook
- name: Create release archive (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
Compress-Archive -Path target/${{ matrix.target }}/release/guidebook.exe -DestinationPath ${{ matrix.artifact }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Generate SHA256 checksums
run: |
cd artifacts
# Each artifact is in its own subdirectory (actions/download-artifact@v4 behavior)
for dir in */; do
for file in "$dir"*; do
if [ -f "$file" ]; then
filename=$(basename "$file")
sha256sum "$file" | sed "s|${dir}||" >> ../checksums.txt
fi
done
done
echo "## SHA256 Checksums" > ../release_body.md
echo '```' >> ../release_body.md
cat ../checksums.txt >> ../release_body.md
echo '```' >> ../release_body.md
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/**/*
body_path: release_body.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}