name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: linux-x86_64
- target: aarch64-apple-darwin
os: macos-latest name: macos-aarch64
- target: x86_64-pc-windows-msvc
os: windows-latest
name: windows-x86_64
ext: .exe
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
if: matrix.cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Build (cross)
if: matrix.cross
run: cross build --release --target ${{ matrix.target }}
- name: Build (native)
if: ${{ !matrix.cross }}
run: cargo build --release --target ${{ matrix.target }}
- name: Package (Unix)
if: runner.os != 'Windows'
run: |
cd target/${{ matrix.target }}/release
tar -czvf ../../../gitgrip-${{ matrix.name }}.tar.gz gr gitgrip
- name: Package (Windows)
if: runner.os == 'Windows'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../gitgrip-${{ matrix.name }}.zip gr.exe gitgrip.exe
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: gitgrip-${{ matrix.name }}
path: gitgrip-${{ matrix.name }}.*
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: List artifacts
run: find artifacts -type f
- name: Extract version
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Create checksums
run: |
cd artifacts
find . -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec sh -c 'sha256sum "$1" > "$1.sha256"' _ {} \;
cat */*.sha256
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
name: gitgrip v${{ steps.version.outputs.version }}
body: |
## Installation
### Download Binary
| Platform | Architecture | Download |
|----------|--------------|----------|
| Linux | x86_64 | [gitgrip-linux-x86_64.tar.gz](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gitgrip-linux-x86_64.tar.gz) |
| macOS | aarch64 (Apple Silicon) | [gitgrip-macos-aarch64.tar.gz](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gitgrip-macos-aarch64.tar.gz) |
| Windows | x86_64 | [gitgrip-windows-x86_64.zip](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gitgrip-windows-x86_64.zip) |
> **Note:** Intel Mac users can install via `cargo install gitgrip` or use Rosetta 2 with the Apple Silicon binary.
### From crates.io
```bash
cargo install gitgrip
```
### Verify Checksums
```bash
sha256sum -c gitgrip-*.sha256
```
files: |
artifacts/**/*.tar.gz
artifacts/**/*.zip
artifacts/**/*.sha256
generate_release_notes: true
publish-crates:
name: Publish to crates.io
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --no-verify --allow-dirty