name: Release Please
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
env:
CARGO_TERM_COLOR: always
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
build:
needs: release-please
if: ${{ needs.release-please.outputs.release_created }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
use_cross: true
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
use_cross: true
- target: x86_64-apple-darwin
os: macos-latest
use_cross: false
- target: aarch64-apple-darwin
os: macos-latest
use_cross: false
- target: x86_64-pc-windows-msvc
os: windows-latest
use_cross: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
if: matrix.use_cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build
run: |
if [ "${{ matrix.use_cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
shell: bash
- name: Package (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../gw-${{ matrix.target }}.tar.gz gw cw
cd ../../..
- name: Package (Windows)
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../gw-${{ matrix.target }}.zip gw.exe cw.exe
cd ../../..
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: gw-${{ matrix.target }}
path: gw-${{ matrix.target }}.*
upload-assets:
needs: [release-please, build]
if: ${{ needs.release-please.outputs.release_created }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: Generate SHA256 checksums
run: |
cd artifacts
sha256sum gw-*/* > ../SHA256SUMS.txt
cat ../SHA256SUMS.txt
- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.release-please.outputs.tag_name }}
files: |
artifacts/gw-*/*
SHA256SUMS.txt
publish-crate:
needs: release-please
if: ${{ needs.release-please.outputs.release_created }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}