-
Notifications
You must be signed in to change notification settings - Fork 18
177 lines (153 loc) · 6.61 KB
/
release.yml
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Release
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Create Release PR or Release
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- name: Get Release Bot Token
id: get-release-bot-token
uses: peter-murray/workflow-application-token-action@v1
with:
application_id: ${{ secrets.RELEASE_BOT_ID }}
application_private_key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}
organization: "Lilypad-Tech"
# Create release PR or release
# - Release PRs are created or updated on user-facing changes (feat, fix, or any breaking changes).
# If a release PR exists, new user-facing changes are added to it.
# - Releases are created when release-please finds an unpublished release commit
# from one of its release PRs.
- name: Create Release PR or Release
id: release
uses: googleapis/release-please-action@v4
with:
token: ${{ steps.get-release-bot-token.outputs.token }}
outputs:
prs_created: ${{ steps.release.outputs.prs_created }}
releases_created: ${{ steps.release.outputs.releases_created }}
sha: ${{ steps.release.outputs.sha }}
tag_name: ${{ steps.release.outputs.tag_name }}
extend-notes:
if: needs.release.outputs.releases_created == 'true' && needs.release.outputs.prs_created == 'false'
name: Extend Release Notes
needs: release
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.tag_name }}
- name: Get Release Bot Token
id: get-release-bot-token
uses: peter-murray/workflow-application-token-action@v1
with:
application_id: ${{ secrets.RELEASE_BOT_ID }}
application_private_key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}
organization: "Lilypad-Tech"
- name: Extend Release Notes
env:
GH_TOKEN: ${{ steps.get-release-bot-token.outputs.token }}
run: |
BODY=$(gh release view ${{ needs.release.outputs.tag_name }} --json body | jq -r '.body')
EXTENSION=$(cat .github/releases/release_notes.md)
# Build up notes from BODY and EXTENSION separated by two newlines
# https://trstringer.com/github-actions-multiline-strings/#option-2---environment-variable
NOTES=$(cat << EOF
$BODY
$EXTENSION
EOF
)
echo "NOTES<<EOF" >> $GITHUB_ENV
echo "$NOTES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
gh release edit ${{ needs.release.outputs.tag_name }} --notes "$NOTES"
publish-binaries:
if: needs.release.outputs.releases_created == 'true' && needs.release.outputs.prs_created == 'false'
name: Build and Publish Binaries
needs: release
strategy:
matrix:
include:
- goos: linux
goarch: amd64
gpu: true
runner: ubuntu-latest
- goos: linux
goarch: arm64
gpu: true
runner: linux-arm64
- goos: darwin
goarch: amd64
gpu: false
runner: macos-13 # uses amd64
- goos: darwin
goarch: arm64
gpu: false
runner: macos-latest # uses M1
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.tag_name }}
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22"
- name: Build for ${{ matrix.goos }}/${{ matrix.goarch }} CPU-only
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 1
GH_TOKEN: ${{ github.token }}
run: |
echo "-------------- OS: ${GOOS} : Arch: ${GOARCH} ---------- start"
mkdir -p build
# Debug: Print environment variables for the build
echo "Building for ${GOOS}/${GOARCH} with GOOS=$GOOS, GOARCH=$GOARCH"
echo "Excluding CUDA. Use the 'cuda' build tag to include it."
go build -o "build/lilypad-${GOOS}-${GOARCH}-cpu" -v -ldflags="-X 'github.com/lilypad-tech/lilypad/pkg/system.Version=${{ needs.release.outputs.tag_name }}' -X 'github.com/lilypad-tech/lilypad/pkg/system.CommitSHA=${{ needs.release.outputs.sha }}'"
echo "-------------- OS: ${GOOS} : Arch: ${GOARCH} ---------- done"
# Upload binary to release
gh release upload ${{ needs.release.outputs.tag_name }} "build/lilypad-${GOOS}-${GOARCH}-cpu"
- name: Install NVIDIA CUDA Toolkit
if: ${{ matrix.gpu }}
run: |
sudo apt-get install -y gnupg2 curl
sudo mkdir -p /usr/share/keyrings
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/3bf863cc.pub | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-drivers.gpg
echo "deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/ /" | sudo tee /etc/apt/sources.list.d/nvidia-drivers.list
sudo apt-get update || true # Ignore errors from this command
sudo apt-get install -y nvidia-cuda-toolkit
export PATH=/usr/local/cuda/bin:$PATH
- name: Build for ${{ matrix.goos }}/${{ matrix.goarch }} GPU
if: ${{ matrix.gpu }}
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 1
CUDA_HOME: /usr/local/cuda
LD_LIBRARY_PATH: /usr/local/cuda/lib64:$LD_LIBRARY_PATH
GH_TOKEN: ${{ github.token }}
run: |
echo "-------------- OS: ${GOOS} : Arch: ${GOARCH} ---------- start"
mkdir -p build
# Debug: Print environment variables for the build
echo "Building for ${GOOS}/${GOARCH} with GOOS=$GOOS, GOARCH=$GOARCH"
echo "CUDA_HOME: $CUDA_HOME"
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
go build -o "build/lilypad-${GOOS}-${GOARCH}-gpu" -v -tags cuda -ldflags="-X 'github.com/lilypad-tech/lilypad/pkg/system.Version=${{ needs.release.outputs.tag_name }}' -X 'github.com/lilypad-tech/lilypad/pkg/system.CommitSHA=${{ needs.release.outputs.sha }}'"
echo "-------------- OS: ${GOOS} : Arch: ${GOARCH} ---------- done"
# Upload binary to release
gh release upload ${{ needs.release.outputs.tag_name }} "build/lilypad-${GOOS}-${GOARCH}-gpu"