name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g., v0.11.1)'
required: true
type: string
permissions:
contents: write
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
name: linux-amd64
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
name: linux-arm64
- os: windows-latest
target: x86_64-pc-windows-msvc
name: windows-amd64
ext: .exe
- os: macos-latest
target: x86_64-apple-darwin
name: darwin-amd64
- os: macos-latest
target: aarch64-apple-darwin
name: darwin-arm64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl-tools (Linux x86_64)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
# Install cross for ARM64 cross-compilation
cargo install cross --git https://github.com/cross-rs/cross
- name: Build (Linux x86_64)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: cargo build --release --target ${{ matrix.target }}
- name: Build (Linux ARM64 with cross)
if: matrix.target == 'aarch64-unknown-linux-musl'
run: cross build --release --target ${{ matrix.target }}
- name: Build (macOS/Windows)
if: matrix.os != 'ubuntu-latest'
run: cargo build --release --target ${{ matrix.target }}
- name: Rename binary
shell: bash
run: |
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp target/${{ matrix.target }}/release/deciduous.exe deciduous-${{ matrix.name }}.exe
else
cp target/${{ matrix.target }}/release/deciduous deciduous-${{ matrix.name }}
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: deciduous-${{ matrix.name }}
path: deciduous-${{ matrix.name }}${{ matrix.ext }}
release:
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure of downloaded files
run: ls -la artifacts/*/
- name: Create checksums
run: |
cd artifacts
for dir in */; do
for file in "$dir"*; do
if [ -f "$file" ]; then
sha256sum "$file" >> ../checksums.txt
fi
done
done
cd ..
cat checksums.txt
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ inputs.tag || github.ref_name }}
files: |
artifacts/deciduous-linux-amd64/deciduous-linux-amd64
artifacts/deciduous-linux-arm64/deciduous-linux-arm64
artifacts/deciduous-darwin-amd64/deciduous-darwin-amd64
artifacts/deciduous-darwin-arm64/deciduous-darwin-arm64
artifacts/deciduous-windows-amd64/deciduous-windows-amd64.exe
checksums.txt
generate_release_notes: true
publish-crate:
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
continue-on-error: true
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --no-verify