Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: arm64 releases #3493

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/actions/setup-go/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
name: Setup go

outputs:
go-version:
description: "The Go version that was set up"
value: ${{ steps.setup-go.outputs.go-version }}

runs:
using: 'composite'
steps:
- name: Setup go
id: setup-go
uses: actions/setup-go@v4
bussyjd marked this conversation as resolved.
Show resolved Hide resolved
with:
go-version: '1.23'

- name: Verify setup
shell: bash
run: |
echo "Go version: $(go version)"
102 changes: 102 additions & 0 deletions .github/workflows/build-release-binaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Build and Release Binaries

on:
workflow_run:
workflows: ["Publish Release"]
types:
- completed

jobs:
build-binaries:
# Only run if the triggering workflow succeeded and it was triggered by a tag
if: >
github.event.workflow_run.conclusion == 'success' &&
startsWith(github.event.workflow_run.head_branch, 'refs/tags/v')
runs-on: ubuntu-24.04
name: Build Cross-Platform Binaries
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: ./.github/actions/setup-go
id: setup-go

- name: Get app/version.Version from the code
if: github.ref_type == 'branch'
run: |
VERSION=$(grep 'var version' app/version/version.go | cut -d'"' -f2)
echo "APP_VERSION=$VERSION" >> $GITHUB_ENV
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV

- name: Set version from git tag
if: github.ref_type == 'tag'
run: |
echo "APP_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
echo "GO_BUILD_FLAG=-ldflags=-X github.com/obolnetwork/charon/app/version.version=${{ github.ref_name }}" >> $GITHUB_ENV

- name: Set build flags for branch
if: github.ref_type == 'branch'
run: |
echo "GO_BUILD_FLAG=-ldflags=-X github.com/obolnetwork/charon/app/version.version=${{ env.APP_VERSION }}" >> $GITHUB_ENV

- name: Install cross-compilation dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential gcc-aarch64-linux-gnu

- name: Build x86_64 binary
run: |
mkdir -p dist
docker run --rm --platform linux/amd64 \
-v $(pwd):/workspace -w /workspace \
golang:${{ steps.setup-go.outputs.go-version }}-bookworm \
bash -c "apt-get update && apt-get install -y build-essential && \
env CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \
go build -tags='netgo osusergo' ${{ env.GO_BUILD_FLAG }} \
-o dist/charon-${{ env.RELEASE_VERSION }}-linux-amd64"

- name: Build ARM64 binary
run: |
docker run --rm --platform linux/amd64 \
-v $(pwd):/workspace -w /workspace \
golang:${{ steps.setup-go.outputs.go-version }}-bookworm \
bash -c "apt-get update && apt-get install -y gcc-aarch64-linux-gnu && \
env CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc \
go build -tags='netgo osusergo' ${{ env.GO_BUILD_FLAG }} \
-o dist/charon-${{ env.RELEASE_VERSION }}-linux-arm64"

- name: Create release archives
run: |
cd dist
tar czf charon-${{ env.RELEASE_VERSION }}-linux-amd64.tar.gz charon-${{ env.RELEASE_VERSION }}-linux-amd64
tar czf charon-${{ env.RELEASE_VERSION }}-linux-arm64.tar.gz charon-${{ env.RELEASE_VERSION }}-linux-arm64
echo "# Linux AMD64 (x86_64)" > checksums.txt
sha256sum charon-${{ env.RELEASE_VERSION }}-linux-amd64.tar.gz >> checksums.txt
echo -e "\n# Linux ARM64 (aarch64)" >> checksums.txt
sha256sum charon-${{ env.RELEASE_VERSION }}-linux-arm64.tar.gz >> checksums.txt

- name: Upload artifacts
uses: actions/upload-artifact@v3
bussyjd marked this conversation as resolved.
Show resolved Hide resolved
with:
name: charon-${{ env.RELEASE_VERSION }}-binaries
path: |
dist/charon-${{ env.RELEASE_VERSION }}-linux-amd64
dist/charon-${{ env.RELEASE_VERSION }}-linux-arm64
dist/charon-${{ env.RELEASE_VERSION }}-linux-amd64.tar.gz
dist/charon-${{ env.RELEASE_VERSION }}-linux-arm64.tar.gz
dist/checksums.txt

- name: Attach to GitHub Release
if: github.event.workflow_run.conclusion == 'success'
uses: softprops/action-gh-release@v1
bussyjd marked this conversation as resolved.
Show resolved Hide resolved
with:
files: |
dist/charon-${{ env.RELEASE_VERSION }}-linux-amd64.tar.gz
dist/charon-${{ env.RELEASE_VERSION }}-linux-arm64.tar.gz
dist/checksums.txt
draft: true
tag_name: ${{ github.event.workflow_run.head_branch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading