-
Notifications
You must be signed in to change notification settings - Fork 103
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: build-release-binaries workflow #3484
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
af1b594
feat: add publishing of amd64 arm64 binaries
bussyjd 0eea705
feat: use pinend version of ubuntu
bussyjd 52a4d0b
feat: cleaner checksum.txt
bussyjd 672326e
ci: improve release workflow and binary builds
bussyjd 5ba012c
feat: reuse golang action for consistency
bussyjd 8dcf448
feat: reuse golang version
bussyjd 473e059
feat: Bump to go 1.23.5
bussyjd 7eb8b6c
Merge branch 'main' into ops/releases
bussyjd 281c764
feat: revert go1.23 for latest patch usage
bussyjd df7b811
feat: fix gh action validation
bussyjd 8a04836
chore: linting
bussyjd 089ac3e
Signed commit
bussyjd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
with: | ||
go-version: '1.23' | ||
|
||
- name: Verify setup | ||
shell: bash | ||
run: | | ||
echo "Go version: $(go version)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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 | ||
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Create dist directory if it doesn't exist | ||
mkdir -p dist | ||
|
||
# Build for linux/amd64 | ||
echo "Building for linux/amd64..." | ||
docker run --rm --platform linux/amd64 \ | ||
-v $(pwd):/workspace -w /workspace \ | ||
--platform linux/amd64 \ | ||
golang:1.23.4-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' -o dist/charon-linux-amd64" | ||
|
||
# Build for linux/arm64 | ||
echo "Building for linux/arm64..." | ||
docker run --rm --platform linux/amd64 \ | ||
-v $(pwd):/workspace -w /workspace \ | ||
--platform linux/amd64 \ | ||
golang:1.23.4-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' -o dist/charon-linux-arm64" | ||
|
||
# Create archives | ||
cd dist | ||
for binary in charon-*; do | ||
tar czf "${binary}.tar.gz" "$binary" | ||
done |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know for sure we don't need a build for Mac ARM? (I see this becomes very common in OSS)