-
Notifications
You must be signed in to change notification settings - Fork 9
273 lines (232 loc) · 8.85 KB
/
installer-release.yaml
File metadata and controls
273 lines (232 loc) · 8.85 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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
name: Installer Release
on:
workflow_dispatch:
inputs:
dry_run:
description: 'Perform a dry run (no actual release)'
type: boolean
default: false
required: false
env:
GO_VERSION: '1.24.2'
permissions:
contents: write
issues: write
pull-requests: write
jobs:
calculate-version:
name: Calculate Release Version
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./installer/go
outputs:
version: ${{ steps.semantic.outputs.new_release_version }}
new-release-published: ${{ steps.semantic.outputs.new_release_published }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24'
- name: Calculate next version
id: semantic
uses: cycjimmy/semantic-release-action@b12c8f6015dc215fe37bc154d4ad456dd3833c90 # v4.1.1
with:
semantic_version: 23.0.3
working_directory: ./installer/go
extra_plugins: |
@semantic-release/changelog@6.0.3
@semantic-release/github@10.0.7
dry_run: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-artifacts:
name: Build Multi-Platform Binaries
runs-on: ubuntu-latest
needs: calculate-version
if: needs.calculate-version.outputs.new-release-published == 'true' || github.event.inputs.dry_run == 'true'
defaults:
run:
working-directory: ./installer/go
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
output: flowfuse-device-installer-linux-amd64
- goos: linux
goarch: arm64
output: flowfuse-device-installer-linux-arm64
- goos: linux
goarch: arm
output: flowfuse-device-installer-linux-arm
- goos: windows
goarch: amd64
output: flowfuse-device-installer-windows-amd64.exe
- goos: darwin
goarch: amd64
output: flowfuse-device-installer-darwin-amd64
- goos: darwin
goarch: arm64
output: flowfuse-device-installer-darwin-arm64
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: "**/go.sum"
- name: Download dependencies
run: go mod download
- name: Build binary for ${{ matrix.goos }}/${{ matrix.goarch }}
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
VERSION: ${{ needs.calculate-version.outputs.version }}
CGO_ENABLED: 0
run: |
echo "Building ${{ matrix.output }} for ${{ matrix.goos }}/${{ matrix.goarch }}..."
echo "Using version: ${VERSION:-${{ github.sha }}}"
# Create output directory structure
mkdir -p artifacts
# Build with version from semantic-release
go build -ldflags "-X main.instVersion=${VERSION:-${{ github.sha }}} -s -w" -o artifacts/${{ matrix.output }} main.go
# Verify the binary was created
if [ ! -f "artifacts/${{ matrix.output }}" ]; then
echo "❌ Binary was not created: ${{ matrix.output }}"
exit 1
fi
echo "✅ Binary created: ${{ matrix.output }}"
ls -la artifacts/${{ matrix.output }}
# Test the version output (only for native builds to avoid cross-compilation issues)
if [[ "${{ matrix.goos }}" == "linux" && "${{ matrix.goarch }}" == "amd64" ]]; then
echo "Testing version output:"
./artifacts/${{ matrix.output }} --version || echo "Version test completed"
fi
- name: Upload build artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ matrix.output }}
path: installer/go/artifacts/${{ matrix.output }}
retention-days: 1
release:
name: Release
runs-on: ubuntu-latest
needs: [calculate-version, build-artifacts]
if: needs.calculate-version.outputs.new-release-published == 'true' && github.event.inputs.dry_run != 'true'
defaults:
run:
working-directory: ./installer/go
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0 # Required for semantic-release to analyze full commit history
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24'
- name: Download all artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: artifacts
pattern: flowfuse-device-installer-*
merge-multiple: true
- name: Prepare artifacts for release
run: |
echo "Preparing release artifacts..."
mkdir -p release-artifacts
# Move and verify all artifacts
find ../../artifacts -name "flowfuse-device-installer-*" -type f -exec cp {} release-artifacts/ \;
echo "Available artifacts:"
ls -la release-artifacts/
# Verify we have all expected binaries
expected_files=(
"flowfuse-device-installer-linux-amd64"
"flowfuse-device-installer-linux-arm64"
"flowfuse-device-installer-linux-arm"
"flowfuse-device-installer-windows-amd64.exe"
"flowfuse-device-installer-darwin-amd64"
"flowfuse-device-installer-darwin-arm64"
)
missing_files=()
for file in "${expected_files[@]}"; do
if [ ! -f "release-artifacts/$file" ]; then
missing_files+=("$file")
fi
done
if [ ${#missing_files[@]} -ne 0 ]; then
echo "❌ Missing expected artifacts:"
printf '%s\n' "${missing_files[@]}"
exit 1
fi
echo "✅ All expected artifacts are present"
- name: Perform release
uses: cycjimmy/semantic-release-action@b12c8f6015dc215fe37bc154d4ad456dd3833c90 # v4.1.1
with:
semantic_version: 23.0.3
working_directory: ./installer/go
extra_plugins: |
@semantic-release/changelog@6.0.3
@semantic-release/github@10.0.7
dry_run: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-installer-scripts:
name: Update Download Scripts
runs-on: ubuntu-latest
needs: [calculate-version, release]
if: needs.calculate-version.outputs.new-release-published == 'true' && github.event.inputs.dry_run != 'true'
steps:
- name: Generate a token
id: generate_token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
with:
app-id: ${{ secrets.GH_BOT_APP_ID }}
private-key: ${{ secrets.GH_BOT_APP_KEY }}
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
token: ${{ steps.generate_token.outputs.token }}
- name: Configure Git
run: |
git config user.name "$GitHub Actions Bot"
git config user.email "github.actions@users.noreply.github.com"
- name: Update scripts
run: |
VERSION="${{ needs.calculate-version.outputs.version }}"
echo "Updating installer scripts to version: $VERSION"
# Update scripts
sed -i "s/^RELEASE=.*/RELEASE=\"$VERSION\"/" ./installer/get.sh
sed -i "s/^\$RELEASE = .*/\$RELEASE = \"$VERSION\"/" ./installer/get.ps1
# Verify changes
echo "Updated get.sh:"
grep "^RELEASE=" ./installer/get.sh
echo "Updated get.ps1:"
grep "^\$RELEASE = " ./installer/get.ps1
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
VERSION="${{ needs.calculate-version.outputs.version }}"
# Ensure there are changes to commit
if git diff --quiet; then
echo "No changes to commit"
exit 0
fi
# Stage, commit, and push changes
git add ./installer/get.sh ./installer/get.ps1
git commit -m "chore: update installer scripts to version $VERSION"
git push origin main