Skip to content

Sync release workflows to match CI build matrix (add linux/arm64, exc… #11

Sync release workflows to match CI build matrix (add linux/arm64, exc…

Sync release workflows to match CI build matrix (add linux/arm64, exc… #11

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
id-token: write
jobs:
build:
name: Build Artifacts
strategy:
matrix:
include:
- build_id: sstart-linux-amd64
runner: ubuntu-latest
goos: linux
goarch: amd64
binary_name: sstart
- build_id: sstart-linux-arm64
runner: ubuntu-latest
goos: linux
goarch: arm64
binary_name: sstart
- build_id: sstart-darwin-amd64
runner: macos-latest
goos: darwin
goarch: amd64
binary_name: sstart
- build_id: sstart-darwin-arm64
runner: macos-latest
goos: darwin
goarch: arm64
binary_name: sstart
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install Linux ARM64 cross-compilation toolchain (Linux ARM64 only)
if: matrix.goos == 'linux' && matrix.goarch == 'arm64'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV
echo "AR=aarch64-linux-gnu-ar" >> $GITHUB_ENV
echo "AS=aarch64-linux-gnu-as" >> $GITHUB_ENV
- name: Calculate version
id: version
uses: actions/github-script@v7
with:
script: |
// Extract version from tag (remove 'v' prefix if present)
const tag = context.ref.replace('refs/tags/', '');
const version = tag.startsWith('v') ? tag.substring(1) : tag;
const buildDate = new Date().toISOString();
core.setOutput('version', version);
core.setOutput('tag', tag);
core.setOutput('date', buildDate);
console.log(`Version: ${version}`);
console.log(`Tag: ${tag}`);
console.log(`Build date: ${buildDate}`);
- name: Build binary
env:
CGO_ENABLED: 1
CGO_LDFLAGS: -lm
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
go build \
-ldflags="-s -w -X github.com/dirathea/sstart/internal/cli.version=${{ steps.version.outputs.version }} -X github.com/dirathea/sstart/internal/cli.commit=${{ github.sha }} -X github.com/dirathea/sstart/internal/cli.date=${{ steps.version.outputs.date }}" \
-o ${{ matrix.binary_name }} \
./cmd/sstart
- name: Prepare release archive
run: |
mkdir -p release
# Determine platform name (matching goreleaser naming convention)
OS_NAME="${{ matrix.goos == 'darwin' && 'Darwin' || 'Linux' }}"
ARCH_NAME="${{ matrix.goarch == 'amd64' && 'x86_64' || matrix.goarch }}"
PLATFORM_NAME="sstart_${OS_NAME}_${ARCH_NAME}"
# Create platform directory
mkdir -p "${PLATFORM_NAME}"
# Copy binary
cp ${{ matrix.binary_name }} "${PLATFORM_NAME}/sstart"
# Copy LICENSE and README
cp LICENSE README.md "${PLATFORM_NAME}/" 2>/dev/null || true
# Create archive (tar.gz for all platforms since we removed Windows)
tar -czf "release/${PLATFORM_NAME}.tar.gz" "${PLATFORM_NAME}"
# Clean up
rm -rf "${PLATFORM_NAME}"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.build_id }}
path: release/*
retention-days: 1
release:
name: Publish Release
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Calculate version
id: version
uses: actions/github-script@v7
with:
script: |
// Extract version from tag (remove 'v' prefix if present)
const tag = context.ref.replace('refs/tags/', '');
const version = tag.startsWith('v') ? tag.substring(1) : tag;
core.setOutput('version', version);
core.setOutput('tag', tag);
console.log(`Version: ${version}`);
console.log(`Tag: ${tag}`);
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release
# Copy all release archives from artifacts
for dir in artifacts/release-*/; do
if [ -d "$dir" ]; then
echo "Copying from $dir"
find "$dir" -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec cp {} release/ \;
fi
done
# Create checksums
cd release
sha256sum * > checksums.txt
echo "Release assets:"
ls -la
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: Release ${{ steps.version.outputs.version }}
body: |
Release ${{ steps.version.outputs.version }}
## Assets
- Pre-built binaries for Linux (amd64, arm64) and macOS (amd64, arm64)
- Checksums file for verification
files: release/*
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}