mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 10:08:30 +00:00
247 lines
8.1 KiB
YAML
247 lines
8.1 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: "Tag (or branch) to build"
|
|
required: true
|
|
run_notes:
|
|
description: "Generate release notes"
|
|
type: boolean
|
|
default: true
|
|
run_linux:
|
|
description: "Build Linux (x86_64 + aarch64 + musl)"
|
|
type: boolean
|
|
default: true
|
|
run_macos:
|
|
description: "Build macOS (x86_64 + aarch64)"
|
|
type: boolean
|
|
default: true
|
|
run_windows:
|
|
description: "Build Windows (MSVC + GNU)"
|
|
type: boolean
|
|
default: true
|
|
run_publish:
|
|
description: "Publish to crates.io"
|
|
type: boolean
|
|
default: false
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
notes:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.inputs.tag || github.ref }}
|
|
|
|
- name: Prepare Release Notes
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
|
tag="${{ github.event.inputs.tag }}"
|
|
tag="${tag#v}"
|
|
else
|
|
tag="${GITHUB_REF_NAME#v}"
|
|
fi
|
|
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
|
|
|
|
# ── Linux ──────────────────────────────────────────────────────────────────
|
|
build-linux:
|
|
if: ${{ github.event_name == 'push' || github.event.inputs.run_linux == 'true' }}
|
|
needs: notes
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- target: x86_64-unknown-linux-gnu
|
|
- target: aarch64-unknown-linux-gnu
|
|
- target: x86_64-unknown-linux-musl
|
|
- target: aarch64-unknown-linux-musl
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.inputs.tag || github.ref }}
|
|
|
|
- name: Download Release Notes
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: release-notes
|
|
path: .github
|
|
|
|
- name: Install cargo-zigbuild
|
|
run: |
|
|
pip install cargo-zigbuild
|
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
- name: Build
|
|
run: |
|
|
if [ "${{ matrix.target }}" != "x86_64-unknown-linux-gnu" ]; then
|
|
cargo zigbuild --release --target ${{ matrix.target }}
|
|
else
|
|
cargo build --release --target ${{ matrix.target }}
|
|
fi
|
|
|
|
- name: Derive version & asset name
|
|
run: |
|
|
RAW_TAG="${{ github.event.inputs.tag || github.ref_name }}"
|
|
echo "RELEASE_TAG=${RAW_TAG}" >> "$GITHUB_ENV"
|
|
echo "RELEASE_VERSION=${RAW_TAG#v}" >> "$GITHUB_ENV"
|
|
echo "ASSET_NAME=dcr-${{ matrix.target }}-${RAW_TAG#v}" >> "$GITHUB_ENV"
|
|
|
|
- name: Prepare Artifact
|
|
run: cp target/${{ matrix.target }}/release/dcr "$ASSET_NAME"
|
|
|
|
- name: Upload Release Asset
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ env.RELEASE_TAG }}
|
|
files: ${{ env.ASSET_NAME }}
|
|
body_path: .github/release-notes.md
|
|
prerelease: ${{ contains(env.RELEASE_TAG, '-') }}
|
|
|
|
# ── macOS ──────────────────────────────────────────────────────────────────
|
|
build-macos:
|
|
if: ${{ github.event_name == 'push' || github.event.inputs.run_macos == 'true' }}
|
|
needs: notes
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: macos-15-intel
|
|
target: x86_64-apple-darwin
|
|
- os: macos-latest
|
|
target: aarch64-apple-darwin
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.inputs.tag || github.ref }}
|
|
|
|
- name: Download Release Notes
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: release-notes
|
|
path: .github
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
- name: Build
|
|
run: cargo build --release --target ${{ matrix.target }}
|
|
|
|
- name: Derive version & asset name
|
|
run: |
|
|
RAW_TAG="${{ github.event.inputs.tag || github.ref_name }}"
|
|
echo "RELEASE_TAG=${RAW_TAG}" >> "$GITHUB_ENV"
|
|
echo "RELEASE_VERSION=${RAW_TAG#v}" >> "$GITHUB_ENV"
|
|
echo "ASSET_NAME=dcr-${{ matrix.target }}-${RAW_TAG#v}" >> "$GITHUB_ENV"
|
|
|
|
- name: Prepare Artifact
|
|
run: cp target/${{ matrix.target }}/release/dcr "$ASSET_NAME"
|
|
|
|
- name: Upload Release Asset
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ env.RELEASE_TAG }}
|
|
files: ${{ env.ASSET_NAME }}
|
|
body_path: .github/release-notes.md
|
|
prerelease: ${{ contains(env.RELEASE_TAG, '-') }}
|
|
|
|
# ── Windows ────────────────────────────────────────────────────────────────
|
|
build-windows:
|
|
if: ${{ github.event_name == 'push' || github.event.inputs.run_windows == 'true' }}
|
|
needs: notes
|
|
runs-on: windows-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- target: x86_64-pc-windows-msvc
|
|
- target: aarch64-pc-windows-msvc
|
|
- target: x86_64-pc-windows-gnu
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.inputs.tag || github.ref }}
|
|
|
|
- name: Download Release Notes
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: release-notes
|
|
path: .github
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
- name: Build
|
|
run: cargo build --release --target ${{ matrix.target }}
|
|
|
|
- name: Derive version & asset name
|
|
shell: pwsh
|
|
run: |
|
|
$raw = "${{ github.event.inputs.tag || github.ref_name }}"
|
|
$ver = $raw -replace '^v', ''
|
|
"RELEASE_TAG=$raw" >> $env:GITHUB_ENV
|
|
"RELEASE_VERSION=$ver" >> $env:GITHUB_ENV
|
|
"ASSET_NAME=dcr-${{ matrix.target }}-${ver}.exe" >> $env:GITHUB_ENV
|
|
|
|
- name: Prepare Artifact
|
|
shell: pwsh
|
|
run: Copy-Item "target/${{ matrix.target }}/release/dcr.exe" "$env:ASSET_NAME"
|
|
|
|
- name: Upload Release Asset
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ env.RELEASE_TAG }}
|
|
files: ${{ env.ASSET_NAME }}
|
|
body_path: .github/release-notes.md
|
|
prerelease: ${{ contains(env.RELEASE_TAG, '-') }}
|
|
|
|
# ── crates.io ──────────────────────────────────────────────────────────────
|
|
publish-crates:
|
|
if: ${{ (github.event_name == 'push' || github.event.inputs.run_publish == 'true') && !contains(github.event.inputs.tag || github.ref_name, '-') }}
|
|
needs: notes
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.inputs.tag || github.ref }}
|
|
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Publish to crates.io
|
|
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} |