name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
id-token: write
env:
SCCACHE_GHA_ENABLED: "true"
SCCACHE_CACHE_SIZE: 2G
RUSTC_WRAPPER: "sccache"
jobs:
build-win:
runs-on: windows-latest
env:
FILE_NAME: target/release/preprintd-win-x86_64.zip
steps:
- uses: actions/checkout@v6
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v2
- uses: mozilla-actions/sccache-action@v0.0.9
- run: cargo build --release --quiet --locked
- run: sccache --show-stats || true
- name: Compress binary
run: |
powershell -Command "Compress-Archive -Path target/release/preprintd.exe -DestinationPath $env:FILE_NAME"
- name: Upload compressed binary to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.FILE_NAME }}
tag: ${{ github.ref }}
overwrite: true
build-unix:
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
suffix: linux-musl-x86_64
- os: macos-latest
target: aarch64-apple-darwin
suffix: macos-arm64
runs-on: ${{ matrix.os }}
env:
FILE_NAME: target/release/preprintd-${{ matrix.suffix }}.tar.gz
steps:
- uses: actions/checkout@v6
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
override: true
- uses: Swatinem/rust-cache@v2
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Install musl tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Build
run: cargo build --release --quiet --locked --target ${{ matrix.target }}
- run: sccache --show-stats || true
- name: Compress binary
run: |
tar -czf "${{ env.FILE_NAME }}" \
-C "target/${{ matrix.target }}/release" \
preprintd
- name: Upload compressed binary to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.FILE_NAME }}
tag: ${{ github.ref }}
overwrite: true
publish:
needs: [build-win, build-unix]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- uses: Swatinem/rust-cache@v2
- uses: mozilla-actions/sccache-action@v0.0.9
- run: sccache --show-stats || true
- uses: rust-lang/crates-io-auth-action@v1
id: auth
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
- name: Extract latest changelog
id: changelog
run: |
awk '/^### v/ { if (found) exit; found=1 } found' CHANGELOG.md > latest.md
echo "notes<<EOF" >> $GITHUB_OUTPUT
cat latest.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create release
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.changelog.outputs.notes }}