Skip to content

ci: optimize release workflow — raw binaries + SHA-256 in release notes #16

ci: optimize release workflow — raw binaries + SHA-256 in release notes

ci: optimize release workflow — raw binaries + SHA-256 in release notes #16

Workflow file for this run

name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
artifact: east
asset_name: east-x86_64-unknown-linux-gnu
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
artifact: east
asset_name: east-aarch64-unknown-linux-gnu
cross: true
- target: x86_64-apple-darwin
os: macos-latest
artifact: east
asset_name: east-x86_64-apple-darwin
- target: aarch64-apple-darwin
os: macos-latest
artifact: east
asset_name: east-aarch64-apple-darwin
- target: x86_64-pc-windows-msvc
os: windows-latest
artifact: east.exe
asset_name: east-x86_64-pc-windows-msvc.exe
- target: aarch64-pc-windows-msvc
os: windows-latest
artifact: east.exe
asset_name: east-aarch64-pc-windows-msvc.exe
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.85.0"
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install cross
if: matrix.cross
run: cargo install cross --version 0.2.5 --locked
- name: Build (native)
if: "!matrix.cross"
run: cargo build --release --target ${{ matrix.target }}
- name: Build (cross)
if: matrix.cross
run: cross build --release --target ${{ matrix.target }}
- name: Rename artifact
shell: bash
run: cp target/${{ matrix.target }}/release/${{ matrix.artifact }} ${{ matrix.asset_name }}
- uses: actions/upload-artifact@v7
with:
name: ${{ matrix.asset_name }}
path: ${{ matrix.asset_name }}
macos-universal:
name: macOS Universal Binary
needs: build
runs-on: macos-latest
steps:
- uses: actions/download-artifact@v8
with:
name: east-x86_64-apple-darwin
- uses: actions/download-artifact@v8
with:
name: east-aarch64-apple-darwin
- name: Create universal binary
run: |
lipo -create east-x86_64-apple-darwin east-aarch64-apple-darwin -output east-universal-apple-darwin
chmod +x east-universal-apple-darwin
- uses: actions/upload-artifact@v7
with:
name: east-universal-apple-darwin
path: east-universal-apple-darwin
release:
name: GitHub Release
needs: [build, macos-universal]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/download-artifact@v8
with:
path: artifacts
- name: Collect release assets
run: |
mkdir -p release
find artifacts -type f -not -name '*.json' -exec cp {} release/ \;
ls -la release/
- name: Generate release notes
run: |
TAG_NAME="${GITHUB_REF#refs/tags/}"
# Find the previous tag
PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v' | sed -n '2p')
if [ -z "$PREV_TAG" ]; then
RANGE="$TAG_NAME"
else
RANGE="${PREV_TAG}..${TAG_NAME}"
fi
# Collect commits by category
FEATS=""
FIXES=""
DOCS=""
OTHERS=""
while IFS= read -r line; do
HASH=$(echo "$line" | cut -d' ' -f1)
MSG=$(echo "$line" | cut -d' ' -f2-)
case "$MSG" in
feat*) FEATS="${FEATS}- ${MSG} (\`${HASH}\`)"$'\n' ;;
fix*) FIXES="${FIXES}- ${MSG} (\`${HASH}\`)"$'\n' ;;
docs*) DOCS="${DOCS}- ${MSG} (\`${HASH}\`)"$'\n' ;;
chore*) ;;
*) OTHERS="${OTHERS}- ${MSG} (\`${HASH}\`)"$'\n' ;;
esac
done < <(git log --oneline "$RANGE")
# Compute SHA-256 checksums
cd release
SHA_LINUX_X64=$(sha256sum east-x86_64-unknown-linux-gnu 2>/dev/null | cut -d' ' -f1 || echo "N/A")
SHA_LINUX_ARM64=$(sha256sum east-aarch64-unknown-linux-gnu 2>/dev/null | cut -d' ' -f1 || echo "N/A")
SHA_MAC_X64=$(sha256sum east-x86_64-apple-darwin 2>/dev/null | cut -d' ' -f1 || echo "N/A")
SHA_MAC_ARM64=$(sha256sum east-aarch64-apple-darwin 2>/dev/null | cut -d' ' -f1 || echo "N/A")
SHA_MAC_UNIVERSAL=$(sha256sum east-universal-apple-darwin 2>/dev/null | cut -d' ' -f1 || echo "N/A")
SHA_WIN_X64=$(sha256sum east-x86_64-pc-windows-msvc.exe 2>/dev/null | cut -d' ' -f1 || echo "N/A")
SHA_WIN_ARM64=$(sha256sum east-aarch64-pc-windows-msvc.exe 2>/dev/null | cut -d' ' -f1 || echo "N/A")
cd ..
# Build release notes
{
echo "## What's Changed in ${TAG_NAME}"
echo ""
if [ -n "$FEATS" ]; then
echo "### New Features"
echo "$FEATS"
fi
if [ -n "$FIXES" ]; then
echo "### Bug Fixes"
echo "$FIXES"
fi
if [ -n "$DOCS" ]; then
echo "### Documentation"
echo "$DOCS"
fi
if [ -n "$OTHERS" ]; then
echo "### Other Changes"
echo "$OTHERS"
fi
echo "---"
echo ""
echo "### Installation"
echo ""
echo '```sh'
echo "cargo install east-cli"
echo '```'
echo ""
echo "Or download the binary for your platform:"
echo ""
echo "| Platform | Architecture | Asset | SHA-256 |"
echo "|----------|-------------|-------|---------|"
echo "| Linux | x64 | \`east-x86_64-unknown-linux-gnu\` | \`${SHA_LINUX_X64:0:16}...\` |"
echo "| Linux | ARM64 | \`east-aarch64-unknown-linux-gnu\` | \`${SHA_LINUX_ARM64:0:16}...\` |"
echo "| macOS | Intel | \`east-x86_64-apple-darwin\` | \`${SHA_MAC_X64:0:16}...\` |"
echo "| macOS | Apple Silicon | \`east-aarch64-apple-darwin\` | \`${SHA_MAC_ARM64:0:16}...\` |"
echo "| macOS | Universal | \`east-universal-apple-darwin\` | \`${SHA_MAC_UNIVERSAL:0:16}...\` |"
echo "| Windows | x64 | \`east-x86_64-pc-windows-msvc.exe\` | \`${SHA_WIN_X64:0:16}...\` |"
echo "| Windows | ARM64 | \`east-aarch64-pc-windows-msvc.exe\` | \`${SHA_WIN_ARM64:0:16}...\` |"
echo ""
echo "<details>"
echo "<summary>Full SHA-256 checksums</summary>"
echo ""
echo '```'
cat release/checksums-sha256.txt 2>/dev/null || (cd release && sha256sum * 2>/dev/null)
echo '```'
echo "</details>"
} > release_notes.md
# Also generate checksums file for asset upload
cd release
sha256sum * > checksums-sha256.txt
cd ..
- uses: softprops/action-gh-release@v2
with:
draft: false
body_path: release_notes.md
files: release/*
publish:
name: Publish to crates.io
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.85.0"
- name: Publish crates
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
LEAF_CRATES=(
east-manifest
east-vcs
east-config
east-workspace
east-runner
east-build-util
)
for crate in "${LEAF_CRATES[@]}"; do
echo "Publishing ${crate}..."
cargo publish -p "$crate" --no-verify || echo "Skipped ${crate} (already published or unchanged)"
sleep 15
done
echo "Publishing east-command..."
cargo publish -p east-command --no-verify || echo "Skipped east-command"
sleep 15
echo "Publishing east-cli..."
cargo publish -p east-cli --no-verify || echo "Skipped east-cli"