name: Release
on:
push:
tags: ["v*"]
schedule:
- cron: "17 4 * * *"
workflow_dispatch:
permissions:
contents: write
jobs:
gate:
runs-on: ubuntu-latest
outputs:
proceed: ${{ steps.check.outputs.proceed }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Decide whether to build
id: check
run: |
if [ "${{ github.event_name }}" != "schedule" ]; then
echo "proceed=true" >> "$GITHUB_OUTPUT"
exit 0
fi
count="$(git rev-list --after='24 hours ago' --count HEAD)"
echo "commits in last 24h: $count"
if [ "$count" -gt 0 ]; then
echo "proceed=true" >> "$GITHUB_OUTPUT"
else
echo "proceed=false" >> "$GITHUB_OUTPUT"
fi
build:
needs: gate
if: needs.gate.outputs.proceed == 'true'
name: build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar.gz
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
archive: tar.gz
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
archive: tar.gz
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
archive: tar.gz
- os: macos-latest
target: aarch64-apple-darwin
archive: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: web/package-lock.json
- name: Install musl tools
if: endsWith(matrix.target, '-linux-musl')
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Package (unix)
if: matrix.archive == 'tar.gz'
shell: bash
run: |
staging="hprof-analyzer-${{ matrix.target }}"
mkdir "$staging"
cp "target/${{ matrix.target }}/release/hprof-analyzer" "$staging/"
cp LICENSE README.md "$staging/"
tar czf "$staging.tar.gz" "$staging"
echo "ASSET=$staging.tar.gz" >> "$GITHUB_ENV"
- name: Package (windows)
if: matrix.archive == 'zip'
shell: bash
run: |
staging="hprof-analyzer-${{ matrix.target }}"
mkdir "$staging"
cp "target/${{ matrix.target }}/release/hprof-analyzer.exe" "$staging/"
cp LICENSE README.md "$staging/"
7z a "$staging.zip" "$staging"
echo "ASSET=$staging.zip" >> "$GITHUB_ENV"
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: ${{ env.ASSET }}
release-tag:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Publish release
uses: softprops/action-gh-release@v2
with:
files: artifacts/*
generate_release_notes: true
release-nightly:
needs: build
if: github.event_name != 'push'
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Publish rolling nightly
uses: softprops/action-gh-release@v2
with:
tag_name: nightly
name: Nightly
prerelease: true
files: artifacts/*
body: "Rolling nightly build from the latest commit on main."