Files
dcr/.github/workflows/release.yml

148 lines
4.0 KiB
YAML

name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
notes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Prepare Release Notes
shell: bash
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME#v}"
notes_file=".github/release-notes.md"
if grep -q "^## \\[${tag}\\]" CHANGELOG.md; then
awk -v ver="$tag" '
$0 ~ "^## \\[" ver "\\]" {found=1; next}
found && $0 ~ "^## \\[" {exit}
found {print}
' CHANGELOG.md | sed -e '${/^$/d;}' > "$notes_file"
else
echo "No CHANGELOG section for $tag." > "$notes_file"
git log -1 --pretty=format:"%s%n%n%b" >> "$notes_file"
fi
- name: Upload Notes Artifact
uses: actions/upload-artifact@v4
with:
name: release-notes
path: .github/release-notes.md
build:
strategy:
fail-fast: false
matrix:
include:
# GNU/Linux
# x86_64
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
asset_name: dcr-x86_64-unknown-linux-gnu
# ARM64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
asset_name: dcr-aarch64-unknown-linux-gnu
# Musl/Linux
# x86_64
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
asset_name: dcr-x86_64-unknown-linux-musl
# ARM64
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
asset_name: dcr-aarch64-unknown-linux-musl
# MacOS
# x86_64 (Intel Mac, macOS 10.12+)
- os: macos-15-intel
target: x86_64-apple-darwin
asset_name: dcr-x86_64-apple-darwin
# ARM64 (Apple Silicon Mac, macOS 11+)
- os: macos-latest
target: aarch64-apple-darwin
asset_name: dcr-aarch64-apple-darwin
# Windows MSVC
# x86_64
- os: windows-latest
target: x86_64-pc-windows-msvc
asset_name: dcr-x86_64-pc-windows-msvc.exe
# ARM64
- os: windows-latest
target: aarch64-pc-windows-msvc
asset_name: dcr-aarch64-pc-windows-msvc.exe
# Windows GNU
# x86_64
- os: windows-latest
target: x86_64-pc-windows-gnu
asset_name: dcr-x86_64-pc-windows-gnu.exe
# Windows LLVM
# x86_64
- os: windows-latest
target: x86_64-pc-windows-gnullvm
asset_name: dcr-x86_64-pc-windows-gnullvm.exe
# ARM64
- os: windows-latest
target: aarch64-pc-windows-gnullvm
asset_name: dcr-aarch64-pc-windows-gnullvm.exe
runs-on: ${{ matrix.os }}
needs: notes
steps:
- uses: actions/checkout@v4
- name: Download Release Notes
uses: actions/download-artifact@v4
with:
name: release-notes
path: .github
- name: Install Linux Cross Compilation Tools
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu musl-tools
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Prepare Artifact (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
cp target/${{ matrix.target }}/release/dcr ${{ matrix.asset_name }}
- name: Prepare Artifact (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Copy-Item "target/${{ matrix.target }}/release/dcr.exe" "${{ matrix.asset_name }}"
- name: Upload Release Asset
uses: softprops/action-gh-release@v2
with:
files: ${{ matrix.asset_name }}
body_path: .github/release-notes.md