name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Extract changelog
if: matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-gnu'
id: changelog
run: |
VERSION=${GITHUB_REF_NAME#v}
BODY=$(awk "/^## \[$VERSION\]/{flag=1; next} /^## \[/{flag=0} flag" CHANGELOG.md)
echo "BODY<<EOF" >> $GITHUB_OUTPUT
echo "$BODY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Package (Linux/macOS)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar -czf gmsg-${{ github.ref_name }}-${{ matrix.target }}.tar.gz gmsg
mv gmsg-${{ github.ref_name }}-${{ matrix.target }}.tar.gz ../../../
- name: Package (Windows)
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
Compress-Archive gmsg.exe gmsg-${{ github.ref_name }}-${{ matrix.target }}.zip
mv gmsg-${{ github.ref_name }}-${{ matrix.target }}.zip ../../../
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.changelog.outputs.BODY }}
files: gmsg-${{ github.ref_name }}-${{ matrix.target }}.*