name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: aarch64-apple-darwin
- os: macos-latest
target: x86_64-apple-darwin
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build release binary
run: cargo build --locked --release --target ${{ matrix.target }}
- name: Package tarball
shell: bash
run: |
mkdir -p dist staging
cp "target/${{ matrix.target }}/release/source-map-tauri" staging/
tar -czf "dist/source-map-tauri-${{ matrix.target }}.tar.gz" -C staging .
rm -rf staging
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.target }}
path: dist/*
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: binaries-*
merge-multiple: true
- name: Generate checksums
run: |
cd artifacts
sha256sum * > SHA256SUMS.txt
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.ref_name }}
run: |
gh release create "$TAG_NAME" \
--title "$TAG_NAME" \
--generate-notes \
artifacts/*
homebrew:
name: Update Homebrew Formula
needs: release
runs-on: ubuntu-latest
steps:
- name: Wait for release assets
run: sleep 10
- name: Download checksums
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.ref_name }}
run: |
gh release download "$TAG_NAME" \
--repo dickwu/source-map-tauri \
--pattern SHA256SUMS.txt
- name: Generate formula
env:
TAG_NAME: ${{ github.ref_name }}
run: |
VERSION="${TAG_NAME#v}"
sha_aarch64_darwin=$(grep 'source-map-tauri-aarch64-apple-darwin.tar.gz' SHA256SUMS.txt | awk '{print $1}')
sha_x86_64_darwin=$(grep 'source-map-tauri-x86_64-apple-darwin.tar.gz' SHA256SUMS.txt | awk '{print $1}')
sha_x86_64_linux=$(grep 'source-map-tauri-x86_64-unknown-linux-gnu.tar.gz' SHA256SUMS.txt | awk '{print $1}')
cat > source-map-tauri.rb << FORMULA
class SourceMapTauri < Formula
desc "Static Tauri app scanner that emits Meilisearch-ready NDJSON"
homepage "https://github.com/dickwu/source-map-tauri"
version "${VERSION}"
license "MIT"
on_macos do
on_arm do
url "https://github.com/dickwu/source-map-tauri/releases/download/v#{version}/source-map-tauri-aarch64-apple-darwin.tar.gz"
sha256 "${sha_aarch64_darwin}"
end
on_intel do
url "https://github.com/dickwu/source-map-tauri/releases/download/v#{version}/source-map-tauri-x86_64-apple-darwin.tar.gz"
sha256 "${sha_x86_64_darwin}"
end
end
on_linux do
on_intel do
url "https://github.com/dickwu/source-map-tauri/releases/download/v#{version}/source-map-tauri-x86_64-unknown-linux-gnu.tar.gz"
sha256 "${sha_x86_64_linux}"
end
end
def install
bin.install "source-map-tauri"
end
test do
assert_match version.to_s, shell_output("#{bin}/source-map-tauri --version")
end
end
FORMULA
sed -i 's/^ //' source-map-tauri.rb
- name: Push formula to homebrew-tap
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
run: |
VERSION="${TAG_NAME#v}"
EXISTING_SHA=$(gh api repos/dickwu/homebrew-tap/contents/Formula/source-map-tauri.rb --jq '.sha' 2>/dev/null || true)
if [ -n "$EXISTING_SHA" ]; then
gh api repos/dickwu/homebrew-tap/contents/Formula/source-map-tauri.rb \
--method PUT \
--field message="source-map-tauri ${VERSION}" \
--field content="$(base64 -w0 source-map-tauri.rb)" \
--field sha="$EXISTING_SHA"
else
gh api repos/dickwu/homebrew-tap/contents/Formula/source-map-tauri.rb \
--method PUT \
--field message="source-map-tauri ${VERSION}" \
--field content="$(base64 -w0 source-map-tauri.rb)"
fi