name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.get_version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Get version from tag
id: get_version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: AGIT ${{ steps.get_version.outputs.version }}
body: |
## AGIT ${{ steps.get_version.outputs.version }}
See [CHANGELOG.md](https://github.com/agit-stuff/agit/blob/main/CHANGELOG.md) for details.
### Installation
**macOS (Homebrew):**
```bash
brew tap agit-stuff/agit
brew install agit
```
**Windows (Scoop):**
```powershell
scoop bucket add agit https://github.com/agit-stuff/agit
scoop install agit
```
**Linux / macOS / CI:**
```bash
curl -fsSL https://raw.githubusercontent.com/agit-stuff/agit/main/install.sh | bash
```
**Cargo:**
```bash
cargo install agit
```
**Binary downloads:** See assets below for pre-built binaries.
draft: false
prerelease: ${{ contains(github.ref, '-') }}
build:
name: Build ${{ matrix.target }}
needs: create-release
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: agit-linux-x86_64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
name: agit-linux-aarch64
- target: x86_64-apple-darwin
os: macos-latest
name: agit-macos-x86_64
- target: aarch64-apple-darwin
os: macos-latest
name: agit-macos-aarch64
- target: x86_64-pc-windows-msvc
os: windows-latest
name: agit-windows-x86_64
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
if [ "${{ matrix.target }}" = "x86_64-unknown-linux-musl" ]; then
sudo apt-get install -y musl-tools
fi
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
sudo apt-get install -y gcc-aarch64-linux-gnu
fi
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --release --target ${{ matrix.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Package (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar -czvf ../../../${{ matrix.name }}.tar.gz agit
cd ../../..
sha256sum ${{ matrix.name }}.tar.gz > ${{ matrix.name }}.tar.gz.sha256
- name: Package (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
cd target/${{ matrix.target }}/release
Compress-Archive -Path agit.exe -DestinationPath ../../../${{ matrix.name }}.zip
cd ../../..
(Get-FileHash ${{ matrix.name }}.zip -Algorithm SHA256).Hash.ToLower() + " ${{ matrix.name }}.zip" | Out-File -Encoding utf8 ${{ matrix.name }}.zip.sha256
- name: Upload Release Asset (Unix)
if: matrix.os != 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./${{ matrix.name }}.tar.gz
asset_name: ${{ matrix.name }}.tar.gz
asset_content_type: application/gzip
- name: Upload Checksum (Unix)
if: matrix.os != 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./${{ matrix.name }}.tar.gz.sha256
asset_name: ${{ matrix.name }}.tar.gz.sha256
asset_content_type: text/plain
- name: Upload Release Asset (Windows)
if: matrix.os == 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./${{ matrix.name }}.zip
asset_name: ${{ matrix.name }}.zip
asset_content_type: application/zip
- name: Upload Checksum (Windows)
if: matrix.os == 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./${{ matrix.name }}.zip.sha256
asset_name: ${{ matrix.name }}.zip.sha256
asset_content_type: text/plain
upload-checksums:
name: Upload Checksums
needs: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
name: agit-linux-x86_64
ext: tar.gz
- os: ubuntu-latest
name: agit-linux-aarch64
ext: tar.gz
- os: macos-latest
name: agit-macos-x86_64
ext: tar.gz
- os: macos-latest
name: agit-macos-aarch64
ext: tar.gz
- os: windows-latest
name: agit-windows-x86_64
ext: zip
steps:
- name: Download checksum from release
run: |
curl -fsSL -o checksum.txt "https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/${{ matrix.name }}.${{ matrix.ext }}.sha256"
- name: Upload checksum artifact
uses: actions/upload-artifact@v4
with:
name: checksum-${{ matrix.name }}
path: checksum.txt
update-manifests:
name: Update Package Manifests
needs: [create-release, upload-checksums]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Download all checksum artifacts
uses: actions/download-artifact@v4
with:
path: checksums
pattern: checksum-*
- name: Consolidate checksums
run: |
echo "# AGIT ${{ needs.create-release.outputs.version }} Checksums" > checksums.txt
echo "" >> checksums.txt
for dir in checksums/checksum-*/; do
name=$(basename "$dir" | sed 's/checksum-//')
hash=$(cut -d' ' -f1 < "$dir/checksum.txt")
echo "$hash $name" >> checksums.txt
done
cat checksums.txt
- name: Upload consolidated checksums
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./checksums.txt
asset_name: checksums.txt
asset_content_type: text/plain
- name: Update Scoop manifest
run: |
VERSION="${{ needs.create-release.outputs.version }}"
HASH=$(grep "agit-windows-x86_64" checksums.txt | cut -d' ' -f1)
# Update version and hash in scoop manifest
jq --arg version "$VERSION" --arg hash "sha256:$HASH" \
'.version = $version | .architecture."64bit".hash = $hash | .architecture."64bit".url = "https://github.com/agit-stuff/agit/releases/download/v\($version)/agit-windows-x86_64.zip"' \
scoop/agit.json > scoop/agit.json.tmp
mv scoop/agit.json.tmp scoop/agit.json
cat scoop/agit.json
- name: Commit manifest updates
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add scoop/agit.json
git commit -m "chore: update package manifests for v${{ needs.create-release.outputs.version }}" || echo "No changes to commit"
git push
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: agit-stuff
repositories: homebrew-agit
- name: Trigger Homebrew formula update
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ steps.app-token.outputs.token }}
repository: agit-stuff/homebrew-agit
event-type: release
client-payload: '{"version": "${{ needs.create-release.outputs.version }}"}'
publish-crates:
name: Publish to crates.io
needs: [create-release, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}