Skip to content

Fix github releases #17

Fix github releases

Fix github releases #17

Workflow file for this run

# .github/workflows/release.yml
name: Release Harmony
on:
push:
tags:
- '**' # match all tags, e.g. 1.0.0, release-1, beta, etc.
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
REGISTRY_GHCR: ghcr.io/aurabx/harmony
REGISTRY_DOCKERHUB: aurabox/harmony
IMAGE_NAME: harmony
jobs:
# ---------- 1. Build binaries ----------
build-binaries:
name: Build Harmony binaries (cross/native)
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
# Linux builds use cross
- name: Build Harmony (Linux cross)
if: runner.os == 'Linux'
shell: bash
run: |
cargo install cross --git https://github.com/cross-rs/cross
cross build --release --target ${{ matrix.target }}
# Non-Linux builds are native
- name: Build Harmony (native)
if: runner.os != 'Linux'
run: cargo build --release --target ${{ matrix.target }}
- name: Package artefacts
shell: bash
run: |
mkdir -p release
cp target/${{ matrix.target }}/release/harmony* release/ || true
cd release
tar czf harmony-${{ matrix.target }}.tar.gz harmony* || true
- name: Generate SHA256 (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Get-FileHash "release/harmony-${{ matrix.target }}.tar.gz" -Algorithm SHA256 |
ForEach-Object { $_.Hash } | Out-File "release/harmony-${{ matrix.target }}.sha256" -Encoding ascii
- name: Generate SHA256 (non-Windows)
if: runner.os != 'Windows'
shell: bash
run: |
shasum -a 256 release/harmony-${{ matrix.target }}.tar.gz > release/harmony-${{ matrix.target }}.sha256
- name: Upload artefacts
uses: actions/upload-artifact@v4
with:
name: harmony-${{ matrix.target }}
path: release/
# ---------- 2. Build and push Docker images ----------
docker:
name: Build and push multi-arch Docker images
runs-on: ubuntu-latest
needs: build-binaries
permissions:
contents: read
packages: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: ./binaries
- name: Prepare Linux binaries
run: |
mv binaries/harmony-x86_64-unknown-linux-musl/harmony harmony-amd64 || true
mv binaries/harmony-aarch64-unknown-linux-musl/harmony harmony-arm64 || true
- uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute image tags
id: meta
run: |
TAG=${GITHUB_REF_NAME}
echo "tags=${{ env.REGISTRY_DOCKERHUB }}:${TAG},${{ env.REGISTRY_DOCKERHUB }}:latest,${{ env.REGISTRY_GHCR }}:${TAG},${{ env.REGISTRY_GHCR }}:latest" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ---------- 3. Publish GitHub Release ----------
release:
name: Publish GitHub Release
runs-on: ubuntu-latest
needs: [build-binaries, docker]
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Download artefacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Generate combined checksums manifest
shell: bash
run: |
cd artifacts
find . -type f -name "*.sha256" -exec cat {} \; > checksums.txt
echo "Combined checksums:"
cat checksums.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Harmony ${{ github.ref_name }}
files: ./artifacts/**/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}