name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- runner: macos-latest
target: aarch64-apple-darwin
asset: guild-macos-arm64.tar.gz
- runner: ubuntu-22.04
target: x86_64-unknown-linux-gnu
asset: guild-linux-x86_64.tar.gz
steps:
- uses: actions/checkout@v4
- run: rustup show
- run: rustup target add ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Package
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../${{ matrix.asset }} guild
cd ../../..
shasum -a 256 ${{ matrix.asset }} > ${{ matrix.asset }}.sha256
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset }}
path: |
${{ matrix.asset }}
${{ matrix.asset }}.sha256
release:
name: Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
artifacts/*.tar.gz
artifacts/*.sha256
publish-crate:
name: Publish to crates.io
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup show
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
update-homebrew:
name: Update Homebrew formula
needs: release
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Read checksums
id: sha
run: |
echo "arm64=$(awk '{print $1}' artifacts/guild-macos-arm64.tar.gz.sha256)" >> "$GITHUB_OUTPUT"
echo "linux=$(awk '{print $1}' artifacts/guild-linux-x86_64.tar.gz.sha256)" >> "$GITHUB_OUTPUT"
- name: Checkout homebrew-tap
uses: actions/checkout@v4
with:
repository: sprouted-dev/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- name: Update formula
env:
VERSION: ${{ github.ref_name }}
SHA_ARM64: ${{ steps.sha.outputs.arm64 }}
SHA_LINUX: ${{ steps.sha.outputs.linux }}
run: |
VERSION="${VERSION#v}"
sed -i "s/version \".*\"/version \"${VERSION}\"/" Formula/guild.rb
sed -i "/macos-arm64/{ n; s/sha256 \".*\"/sha256 \"${SHA_ARM64}\"/ }" Formula/guild.rb
sed -i "/linux-x86_64/{ n; s/sha256 \".*\"/sha256 \"${SHA_LINUX}\"/ }" Formula/guild.rb
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/guild.rb
git commit -m "Update guild to ${GITHUB_REF_NAME}"
git push