Skip to content

Commit 799943b

Browse files
mclasmeierMoritz Clasmeier
andauthored
Enable GitHub releases based on git tags (#54)
Co-authored-by: Moritz Clasmeier <mclasmeier@redhat.com>
1 parent 1e257ac commit 799943b

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build-and-release:
13+
name: Build and Release Binaries
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v6
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v6
24+
with:
25+
go-version-file: go.mod
26+
cache: true
27+
28+
- name: Get version information
29+
id: version
30+
run: |
31+
echo "version=$(make version)" >> $GITHUB_OUTPUT
32+
echo "git_commit=$(make get-commit-hash)" >> $GITHUB_OUTPUT
33+
echo "build_date=$(make get-build-date)" >> $GITHUB_OUTPUT
34+
35+
- name: Build binaries for multiple platforms
36+
env:
37+
VERSION: ${{ steps.version.outputs.version }}
38+
GIT_COMMIT: ${{ steps.version.outputs.git_commit }}
39+
BUILD_DATE: ${{ steps.version.outputs.build_date }}
40+
run: |
41+
LDFLAGS="-X main.version=${VERSION} -X main.gitCommit=${GIT_COMMIT} -X main.buildDate=${BUILD_DATE}"
42+
43+
# Linux amd64
44+
GOOS=linux GOARCH=amd64 go build -ldflags "${LDFLAGS}" -o roxie-linux-amd64 ./cmd
45+
46+
# Linux arm64
47+
GOOS=linux GOARCH=arm64 go build -ldflags "${LDFLAGS}" -o roxie-linux-arm64 ./cmd
48+
49+
# macOS amd64
50+
GOOS=darwin GOARCH=amd64 go build -ldflags "${LDFLAGS}" -o roxie-darwin-amd64 ./cmd
51+
52+
# macOS arm64
53+
GOOS=darwin GOARCH=arm64 go build -ldflags "${LDFLAGS}" -o roxie-darwin-arm64 ./cmd
54+
55+
# Generate checksums
56+
sha256sum roxie-* > checksums.txt
57+
58+
- name: Create GitHub Release
59+
uses: softprops/action-gh-release@v2
60+
with:
61+
name: Release ${{ steps.version.outputs.version }}
62+
draft: false
63+
prerelease: false
64+
generate_release_notes: true
65+
files: |
66+
roxie-linux-amd64
67+
roxie-linux-arm64
68+
roxie-darwin-amd64
69+
roxie-darwin-arm64
70+
checksums.txt

0 commit comments

Comments
 (0)