Skip to content

Commit dbcdbe9

Browse files
Initialise release workflow (#85)
* Initialise release workflow * added comment * use v5 checkout * specify actions by hash
1 parent 3e53479 commit dbcdbe9

File tree

1 file changed

+174
-0
lines changed

1 file changed

+174
-0
lines changed

.github/workflows/release.yml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Release Workflow
2+
#
3+
# This workflow builds Go binaries for all platforms supported by obolup.sh and creates GitHub releases.
4+
#
5+
# Supported platforms:
6+
# - linux/amd64, linux/arm64
7+
# - darwin/amd64, darwin/arm64
8+
#
9+
# Binary naming convention (matches obolup.sh):
10+
# - obol_linux_amd64, obol_linux_arm64
11+
# - obol_darwin_amd64, obol_darwin_arm64
12+
#
13+
# How to use:
14+
#
15+
# 1. Create and push a release tag:
16+
# $ git tag v0.1.0
17+
# $ git push origin v0.1.0
18+
#
19+
# 2. The workflow automatically:
20+
# - Builds all 4 binaries with version information
21+
# - Creates a GitHub release
22+
# - Uploads binaries and SHA256SUMS checksums
23+
# - Generates release notes
24+
#
25+
# 3. Binaries are available at:
26+
# https://github.com/ObolNetwork/obol-stack/releases/download/v0.1.0/obol_linux_amd64
27+
#
28+
# 4. Manual trigger (optional):
29+
# - Go to Actions tab → Release workflow → Run workflow
30+
# - Enter a tag name (e.g., v0.1.0)
31+
#
32+
# The obolup.sh script uses these binaries for installation:
33+
# - download_release() function expects binaries at the URL format above
34+
# - Version information is injected via ldflags (matching obolup.sh build)
35+
36+
name: Release
37+
38+
on:
39+
push:
40+
tags:
41+
- 'v*'
42+
workflow_dispatch:
43+
inputs:
44+
tag:
45+
description: 'Tag to release'
46+
required: true
47+
type: string
48+
49+
permissions:
50+
contents: write
51+
52+
jobs:
53+
build:
54+
name: Build binaries
55+
runs-on: ubuntu-latest
56+
strategy:
57+
matrix:
58+
include:
59+
- goos: linux
60+
goarch: amd64
61+
- goos: linux
62+
goarch: arm64
63+
- goos: darwin
64+
goarch: amd64
65+
- goos: darwin
66+
goarch: arm64
67+
68+
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
71+
with:
72+
fetch-depth: 0
73+
74+
- name: Set up Go
75+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
76+
with:
77+
go-version-file: 'go.mod'
78+
79+
- name: Get version information
80+
id: version
81+
run: |
82+
# Get version from tag (remove 'v' prefix)
83+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
84+
TAG="${{ github.event.inputs.tag }}"
85+
else
86+
TAG="${{ github.ref_name }}"
87+
fi
88+
VERSION="${TAG#v}"
89+
90+
# Get git commit (short hash)
91+
GIT_COMMIT=$(git rev-parse --short HEAD)
92+
93+
# Get build time (YYYYMMDDHHMMSS format)
94+
BUILD_TIME=$(date -u +"%Y%m%d%H%M%S")
95+
96+
# Check if repo is dirty
97+
if ! git diff --quiet || ! git diff --cached --quiet; then
98+
GIT_DIRTY="true"
99+
else
100+
GIT_DIRTY="false"
101+
fi
102+
103+
echo "version=$VERSION" >> $GITHUB_OUTPUT
104+
echo "git_commit=$GIT_COMMIT" >> $GITHUB_OUTPUT
105+
echo "build_time=$BUILD_TIME" >> $GITHUB_OUTPUT
106+
echo "git_dirty=$GIT_DIRTY" >> $GITHUB_OUTPUT
107+
108+
- name: Build binary
109+
env:
110+
GOOS: ${{ matrix.goos }}
111+
GOARCH: ${{ matrix.goarch }}
112+
CGO_ENABLED: 0
113+
run: |
114+
# Build with ldflags (same as obolup.sh)
115+
LDFLAGS="-X github.com/ObolNetwork/obol-stack/internal/version.Version=${{ steps.version.outputs.version }}"
116+
LDFLAGS="$LDFLAGS -X github.com/ObolNetwork/obol-stack/internal/version.GitCommit=${{ steps.version.outputs.git_commit }}"
117+
LDFLAGS="$LDFLAGS -X github.com/ObolNetwork/obol-stack/internal/version.BuildTime=${{ steps.version.outputs.build_time }}"
118+
LDFLAGS="$LDFLAGS -X github.com/ObolNetwork/obol-stack/internal/version.GitDirty=${{ steps.version.outputs.git_dirty }}"
119+
120+
# Build binary with naming convention from obolup.sh
121+
OUTPUT="obol_${{ matrix.goos }}_${{ matrix.goarch }}"
122+
go build -ldflags "$LDFLAGS" -o "$OUTPUT" ./cmd/obol
123+
124+
# Make executable
125+
chmod +x "$OUTPUT"
126+
127+
- name: Upload artifact
128+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
129+
with:
130+
name: obol_${{ matrix.goos }}_${{ matrix.goarch }}
131+
path: obol_${{ matrix.goos }}_${{ matrix.goarch }}
132+
if-no-files-found: error
133+
134+
release:
135+
name: Create GitHub Release
136+
needs: build
137+
runs-on: ubuntu-latest
138+
139+
steps:
140+
- name: Checkout code
141+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
142+
143+
- name: Download all artifacts
144+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
145+
with:
146+
path: artifacts
147+
merge-multiple: true
148+
149+
- name: Get tag name
150+
id: tag
151+
run: |
152+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
153+
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
154+
else
155+
echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
156+
fi
157+
158+
- name: Generate checksums
159+
run: |
160+
cd artifacts
161+
sha256sum obol_* > SHA256SUMS
162+
cat SHA256SUMS
163+
164+
- name: Create Release
165+
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1
166+
with:
167+
tag_name: ${{ steps.tag.outputs.tag }}
168+
name: Release ${{ steps.tag.outputs.tag }}
169+
draft: true
170+
prerelease: false
171+
generate_release_notes: true
172+
files: |
173+
artifacts/obol_*
174+
artifacts/SHA256SUMS

0 commit comments

Comments
 (0)