name: Release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-x86_64
os: ubuntu-latest
archive: tar
binary: cyber-rain
- name: macos
os: macos-latest
archive: tar
binary: cyber-rain
- name: windows-x86_64
os: windows-latest
archive: zip
binary: cyber-rain.exe
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --release --locked
- name: Package Unix
if: matrix.archive == 'tar'
shell: bash
run: |
set -euo pipefail
mkdir -p "dist/cyber-rain-${{ github.ref_name }}-${{ matrix.name }}"
cp "target/release/${{ matrix.binary }}" "dist/cyber-rain-${{ github.ref_name }}-${{ matrix.name }}/"
cp README.md CHANGELOG.md LICENSE-MIT LICENSE-APACHE "dist/cyber-rain-${{ github.ref_name }}-${{ matrix.name }}/"
tar -C dist -czf "dist/cyber-rain-${{ github.ref_name }}-${{ matrix.name }}.tar.gz" "cyber-rain-${{ github.ref_name }}-${{ matrix.name }}"
- name: Package Windows
if: matrix.archive == 'zip'
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$pkg = "cyber-rain-${{ github.ref_name }}-${{ matrix.name }}"
New-Item -ItemType Directory -Force -Path "dist/$pkg" | Out-Null
Copy-Item "target/release/${{ matrix.binary }}" "dist/$pkg/"
Copy-Item README.md,CHANGELOG.md,LICENSE-MIT,LICENSE-APACHE "dist/$pkg/"
Compress-Archive -Path "dist/$pkg" -DestinationPath "dist/$pkg.zip" -Force
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: cyber-rain-${{ github.ref_name }}-${{ matrix.name }}
path: |
dist/*.tar.gz
dist/*.zip
publish:
name: Publish GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true