name: Release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
create-release:
runs-on: ubuntu-latest
name: Create GitHub release
permissions:
contents: write steps:
- name: Create release if needed
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.ref_name }}
REPOSITORY: ${{ github.repository }}
run: |
if ! gh release view "$TAG_NAME" --repo "$REPOSITORY" >/dev/null 2>&1; then
gh release create "$TAG_NAME" \
--repo "$REPOSITORY" \
--verify-tag \
--title "Agentree $TAG_NAME" \
--generate-notes
fi
build:
needs: create-release
name: ${{ matrix.os }} / release binary
runs-on: ${{ matrix.os }}
permissions:
contents: write strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
steps:
- name: Check out source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- name: Install Rust toolchain
run: rustup toolchain install stable --profile minimal
- name: Build release binary
run: cargo build --release --locked
- name: Package release binary
shell: bash
env:
TAG_NAME: ${{ github.ref_name }}
RUNNER_OS_NAME: ${{ runner.os }}
RUNNER_ARCH_NAME: ${{ runner.arch }}
run: |
set -euo pipefail
archive="agentree-${TAG_NAME}-${RUNNER_OS_NAME}-${RUNNER_ARCH_NAME}.tar.gz"
staging="$(mktemp -d)"
cp target/release/agentree "$staging/agentree"
cp LICENSE README.md "$staging/"
tar -C "$staging" -czf "$archive" agentree LICENSE README.md
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$archive" > "$archive.sha256"
else
shasum -a 256 "$archive" > "$archive.sha256"
fi
echo "RELEASE_ARCHIVE=$archive" >> "$GITHUB_ENV"
- name: Upload release assets
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.ref_name }}
REPOSITORY: ${{ github.repository }}
run: gh release upload "$TAG_NAME" "$RELEASE_ARCHIVE" "$RELEASE_ARCHIVE.sha256" --repo "$REPOSITORY" --clobber