mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 09:28:35 +00:00
202 lines
7.5 KiB
YAML
202 lines
7.5 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: "Tag to build and upload assets for (e.g. v0.6.5)"
|
|
required: true
|
|
|
|
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
|
|
|
|
build:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
# ── Linux GNU ──────────────────────────────────────────────────────
|
|
- os: ubuntu-latest
|
|
target: x86_64-unknown-linux-gnu
|
|
|
|
- os: ubuntu-latest
|
|
target: aarch64-unknown-linux-gnu
|
|
apt: gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
|
|
env_cc: CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
|
|
env_linker: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
|
|
|
|
# ── Linux Musl ─────────────────────────────────────────────────────
|
|
- os: ubuntu-latest
|
|
target: x86_64-unknown-linux-musl
|
|
apt: musl-tools
|
|
env_cc: CC_x86_64_unknown_linux_musl=musl-gcc
|
|
env_linker: CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc
|
|
|
|
- os: ubuntu-latest
|
|
target: aarch64-unknown-linux-musl
|
|
musl_cross: aarch64-linux-musl-cross
|
|
env_cc: CC_aarch64_unknown_linux_musl=aarch64-linux-musl-gcc
|
|
env_linker: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc
|
|
|
|
# ── macOS ──────────────────────────────────────────────────────────
|
|
- os: macos-15-intel
|
|
target: x86_64-apple-darwin
|
|
|
|
- os: macos-latest
|
|
target: aarch64-apple-darwin
|
|
|
|
# ── Windows MSVC ───────────────────────────────────────────────────
|
|
- os: windows-latest
|
|
target: x86_64-pc-windows-msvc
|
|
|
|
- os: windows-latest
|
|
target: aarch64-pc-windows-msvc
|
|
|
|
# ── Windows GNU ────────────────────────────────────────────────────
|
|
- os: windows-latest
|
|
target: x86_64-pc-windows-gnu
|
|
|
|
# gnullvm исключён: LLVM MinGW не предустановлен на GitHub Actions
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
needs: notes
|
|
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 apt packages
|
|
if: runner.os == 'Linux' && matrix.apt != ''
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu musl-tools
|
|
case "${{ matrix.target }}" in
|
|
aarch64-unknown-linux-gnu)
|
|
echo "CC_aarch64-unknown-linux-gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
|
|
echo "AR_aarch64-unknown-linux-gnu=aarch64-linux-gnu-ar" >> $GITHUB_ENV
|
|
;;
|
|
x86_64-unknown-linux-musl)
|
|
echo "CC_x86_64-unknown-linux-musl=x86_64-linux-musl-gcc" >> $GITHUB_ENV
|
|
;;
|
|
aarch64-unknown-linux-musl)
|
|
curl -L https://musl.cc/aarch64-linux-musl-cross.tgz -o /tmp/musl-aarch64.tgz
|
|
sudo tar xzf /tmp/musl-aarch64.tgz -C /opt
|
|
echo "/opt/aarch64-linux-musl-cross/bin" >> $GITHUB_PATH
|
|
echo "CC_aarch64-unknown-linux-musl=aarch64-linux-musl-gcc" >> $GITHUB_ENV
|
|
echo "AR_aarch64-unknown-linux-musl=aarch64-linux-musl-ar" >> $GITHUB_ENV
|
|
;;
|
|
esac
|
|
|
|
- name: Setup LLVM + MinGW (gnullvm)
|
|
if: contains(matrix.target, 'gnullvm')
|
|
shell: pwsh
|
|
run: |
|
|
choco install llvm mingw -y --no-progress
|
|
echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
- name: Build
|
|
shell: bash
|
|
env:
|
|
MATRIX_ENV_CC: ${{ matrix.env_cc }}
|
|
MATRIX_ENV_LINKER: ${{ matrix.env_linker }}
|
|
run: |
|
|
if [[ -n "${MATRIX_ENV_CC:-}" ]]; then
|
|
export "${MATRIX_ENV_CC?}"
|
|
fi
|
|
if [[ -n "${MATRIX_ENV_LINKER:-}" ]]; then
|
|
export "${MATRIX_ENV_LINKER?}"
|
|
fi
|
|
cargo build --release --target ${{ matrix.target }}
|
|
|
|
- name: Derive version string
|
|
shell: bash
|
|
run: |
|
|
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
|
RAW_TAG="${{ github.event.inputs.tag }}"
|
|
else
|
|
RAW_TAG="${GITHUB_REF_NAME}"
|
|
fi
|
|
echo "RELEASE_TAG=${RAW_TAG}" >> "$GITHUB_ENV"
|
|
echo "RELEASE_VERSION=${RAW_TAG#v}" >> "$GITHUB_ENV"
|
|
|
|
- name: Derive asset name (Unix)
|
|
if: runner.os != 'Windows'
|
|
shell: bash
|
|
run: |
|
|
echo "ASSET_NAME=dcr-${{ matrix.target }}-${RELEASE_VERSION}" >> "$GITHUB_ENV"
|
|
|
|
- name: Derive asset name (Windows)
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: |
|
|
"ASSET_NAME=dcr-${{ matrix.target }}-$($env:RELEASE_VERSION).exe" >> $env:GITHUB_ENV
|
|
|
|
- name: Prepare Artifact (Unix)
|
|
if: runner.os != 'Windows'
|
|
shell: bash
|
|
run: cp target/${{ matrix.target }}/release/dcr "$ASSET_NAME"
|
|
|
|
- name: Prepare Artifact (Windows)
|
|
if: runner.os == 'Windows'
|
|
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, '-') }} |