-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (78 loc) · 2.56 KB
/
release.yml
File metadata and controls
95 lines (78 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Build and Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, darwin]
goarch: [amd64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.26'
- name: Get version info
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
COMMIT=$(git rev-parse --short HEAD)
DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "commit=$COMMIT" >> $GITHUB_OUTPUT
echo "date=$DATE" >> $GITHUB_OUTPUT
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
VERSION: ${{ steps.version.outputs.version }}
run: |
EXT=""
if [ "$GOOS" = "windows" ]; then
EXT=".exe"
fi
OUTPUT_NAME="bitcode-${VERSION}-${GOOS}-${GOARCH}${EXT}"
go build -ldflags="-s -w -X github.com/sazid/bitcode/internal/version.Version=${{ steps.version.outputs.version }} -X github.com/sazid/bitcode/internal/version.Commit=${{ steps.version.outputs.commit }} -X github.com/sazid/bitcode/internal/version.Date=${{ steps.version.outputs.date }} -X github.com/sazid/bitcode/internal/version.BuildType=release" \
-o "$OUTPUT_NAME" ./app
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bitcode-${{ matrix.goos }}-${{ matrix.goarch }}
path: bitcode-*
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create checksums
run: |
cd artifacts
find . -type f | sort | xargs sha256sum > checksums.txt
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=${GITHUB_REF#refs/tags/v}
# Create release and upload binaries
gh release create "v${VERSION}" \
--title "BitCode v${VERSION}" \
--generate-notes \
artifacts/bitcode-${VERSION}-* \
artifacts/checksums.txt