synor/.github/workflows/release.yml
Gulshan Yadav 01ff14c0a9
Some checks failed
Release / Build Release (x86_64-unknown-linux-gnu) (push) Failing after 2s
Release / Build Release (aarch64-unknown-linux-gnu) (push) Has been cancelled
Release / Build Release (aarch64-apple-darwin) (push) Has been cancelled
Release / Build Release (x86_64-apple-darwin) (push) Has been cancelled
Release / Build Release (x86_64-pc-windows-msvc) (push) Has been cancelled
Release / Create GitHub Release (push) Has been cancelled
Release / Publish to crates.io (push) Has been cancelled
fix: use native ARM64 runner instead of cross-compilation
- Use ubuntu-24.04-arm runner for native ARM64 builds
- Remove cross-compilation setup (OpenSSL issues in Docker)
- Native builds are more reliable and faster
2026-02-02 03:48:26 +05:30

270 lines
9.2 KiB
YAML

name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
permissions:
contents: write
jobs:
build-release:
name: Build Release (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact-name: synor-linux-x86_64
archive-ext: tar.gz
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
artifact-name: synor-linux-aarch64
archive-ext: tar.gz
- os: macos-latest
target: x86_64-apple-darwin
artifact-name: synor-macos-x86_64
archive-ext: tar.gz
- os: macos-latest
target: aarch64-apple-darwin
artifact-name: synor-macos-aarch64
archive-ext: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact-name: synor-windows-x86_64
archive-ext: zip
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libclang-dev llvm-dev
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-${{ matrix.target }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-registry-
- name: Cache cargo target
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-target-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-target-release-
- name: Build release binaries (Unix)
if: runner.os != 'Windows'
env:
TARGET: ${{ matrix.target }}
run: cargo build --release --workspace --target "$TARGET"
- name: Build release binaries (Windows)
if: runner.os == 'Windows'
env:
TARGET: ${{ matrix.target }}
run: cargo build --release --workspace --target "$env:TARGET"
- name: Prepare release archive (Unix)
if: runner.os != 'Windows'
env:
TARGET: ${{ matrix.target }}
ARTIFACT_NAME: ${{ matrix.artifact-name }}
run: |
mkdir -p release
# Copy binaries
cp "target/$TARGET/release/synord" release/ 2>/dev/null || true
cp "target/$TARGET/release/synor-cli" release/ 2>/dev/null || true
cp "target/$TARGET/release/synor-faucet" release/ 2>/dev/null || true
cp "target/$TARGET/release/synor-explorer" release/ 2>/dev/null || true
# Copy documentation
cp README.md release/ 2>/dev/null || true
cp LICENSE* release/ 2>/dev/null || true
cp CHANGELOG.md release/ 2>/dev/null || true
# Create archive
cd release
tar czvf "../$ARTIFACT_NAME.tar.gz" *
- name: Prepare release archive (Windows)
if: runner.os == 'Windows'
env:
TARGET: ${{ matrix.target }}
ARTIFACT_NAME: ${{ matrix.artifact-name }}
run: |
New-Item -ItemType Directory -Force -Path release
# Copy binaries
Copy-Item "target/$env:TARGET/release/synord.exe" release/ -ErrorAction SilentlyContinue
Copy-Item "target/$env:TARGET/release/synor-cli.exe" release/ -ErrorAction SilentlyContinue
Copy-Item "target/$env:TARGET/release/synor-faucet.exe" release/ -ErrorAction SilentlyContinue
Copy-Item "target/$env:TARGET/release/synor-explorer.exe" release/ -ErrorAction SilentlyContinue
# Copy documentation
Copy-Item README.md release/ -ErrorAction SilentlyContinue
Copy-Item LICENSE* release/ -ErrorAction SilentlyContinue
Copy-Item CHANGELOG.md release/ -ErrorAction SilentlyContinue
# Create archive
Compress-Archive -Path release/* -DestinationPath "$env:ARTIFACT_NAME.zip"
- name: Upload release artifact (Unix)
if: runner.os != 'Windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.artifact-name }}.tar.gz
retention-days: 1
- name: Upload release artifact (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.artifact-name }}.zip
retention-days: 1
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: build-release
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Generate changelog
id: changelog
env:
GIT_REF: ${{ github.ref }}
run: |
# Get the current tag from the ref (safe - only used after validation)
CURRENT_TAG="${GIT_REF#refs/tags/}"
# Validate tag format (only allow v followed by semver-like pattern)
if [[ ! "$CURRENT_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
echo "Invalid tag format: $CURRENT_TAG"
exit 1
fi
echo "current_tag=$CURRENT_TAG" >> "$GITHUB_OUTPUT"
# Get the previous tag
PREVIOUS_TAG=$(git describe --tags --abbrev=0 "$CURRENT_TAG^" 2>/dev/null || echo "")
echo "## What's Changed" > CHANGELOG_BODY.md
echo "" >> CHANGELOG_BODY.md
if [ -n "$PREVIOUS_TAG" ]; then
echo "Changes since $PREVIOUS_TAG:" >> CHANGELOG_BODY.md
echo "" >> CHANGELOG_BODY.md
# Generate changelog from commits (commit messages are from our own repo)
git log "$PREVIOUS_TAG..$CURRENT_TAG" --pretty=format:"- %s (%h)" --no-merges >> CHANGELOG_BODY.md
else
echo "Initial release" >> CHANGELOG_BODY.md
echo "" >> CHANGELOG_BODY.md
git log --pretty=format:"- %s (%h)" --no-merges -20 >> CHANGELOG_BODY.md
fi
echo "" >> CHANGELOG_BODY.md
echo "" >> CHANGELOG_BODY.md
echo "## Installation" >> CHANGELOG_BODY.md
echo "" >> CHANGELOG_BODY.md
echo "Download the appropriate archive for your platform and extract it:" >> CHANGELOG_BODY.md
echo "" >> CHANGELOG_BODY.md
echo '```bash' >> CHANGELOG_BODY.md
echo "tar xzf synor-<platform>.tar.gz" >> CHANGELOG_BODY.md
echo "./synord --help" >> CHANGELOG_BODY.md
echo '```' >> CHANGELOG_BODY.md
echo "" >> CHANGELOG_BODY.md
echo "## Checksums" >> CHANGELOG_BODY.md
echo "" >> CHANGELOG_BODY.md
echo '```' >> CHANGELOG_BODY.md
cd artifacts
find . \( -name "*.tar.gz" -o -name "*.zip" \) -exec sha256sum {} \; | sed 's|./[^/]*/||' >> ../CHANGELOG_BODY.md
echo '```' >> CHANGELOG_BODY.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: Synor ${{ steps.changelog.outputs.current_tag }}
body_path: CHANGELOG_BODY.md
draft: false
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
files: |
artifacts/**/*.tar.gz
artifacts/**/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Optional: Publish to crates.io
publish-crates:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: create-release
if: ${{ !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') && !contains(github.ref, 'rc') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libclang-dev llvm-dev
- name: Publish crates
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
# Publish crates in dependency order
# Skip if CARGO_REGISTRY_TOKEN is not set
if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
echo "CARGO_REGISTRY_TOKEN not set, skipping crates.io publish"
exit 0
fi
echo "Publishing to crates.io..."
# Add --dry-run to test first, remove for actual publish
# cargo publish -p synor-types --dry-run
# cargo publish -p synor-crypto --dry-run
# ... etc
echo "Crate publishing configured but commented out - uncomment when ready"