-
Notifications
You must be signed in to change notification settings - Fork 3
271 lines (237 loc) · 8.17 KB
/
release.yaml
File metadata and controls
271 lines (237 loc) · 8.17 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
env:
GO_VERSION: '1.25.4'
jobs:
compute-versions:
runs-on: ubuntu-latest
outputs:
tag_version: ${{ steps.versions.outputs.tag_version }}
artifact_version: ${{ steps.versions.outputs.artifact_version }}
steps:
- name: Compute versions
id: versions
run: |
tag="${GITHUB_REF_NAME#v}"
echo "tag_version=${tag}" >> "$GITHUB_OUTPUT"
if [[ "$tag" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)-rc([0-9]+)$ ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
patch="${BASH_REMATCH[3]}"
num="${BASH_REMATCH[4]}"
computed_patch=$((1000 * minor + 100 * patch + num))
echo "artifact_version=${major}.0.${computed_patch}" >> "$GITHUB_OUTPUT"
else
echo "artifact_version=${tag}" >> "$GITHUB_OUTPUT"
fi
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Set build variables
id: vars
run: |
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
echo "commit=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
echo "date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
- name: Build fn-hcl-tools binaries
working-directory: function-hcl
run: |
ldflags="-s -w -X main.Version=${{ steps.vars.outputs.version }} -X main.Commit=${{ steps.vars.outputs.commit }} -X main.BuildDate=${{ steps.vars.outputs.date }}"
platforms=(
"linux/amd64"
"linux/arm64"
"darwin/amd64"
"darwin/arm64"
"windows/amd64"
)
for platform in "${platforms[@]}"; do
os="${platform%/*}"
arch="${platform#*/}"
binary="fn-hcl-tools"
if [ "$os" = "windows" ]; then
binary="${binary}.exe"
fi
echo "Building ${os}/${arch}..."
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -trimpath -ldflags="$ldflags" -o "../dist/${binary}" ./cmd/fn-hcl-tools
chmod +x "../dist/${binary}"
cd ../dist
shasum -a 256 "${binary}" > checksums.txt
tar czf "fn-hcl-tools-${os}-${arch}.tar.gz" "${binary}" checksums.txt
rm "${binary}" checksums.txt
cd ../function-hcl
done
- name: Build function-hcl-ls binaries
working-directory: function-hcl-ls
run: |
platforms=(
"linux/amd64"
"linux/arm64"
"darwin/amd64"
"darwin/arm64"
"windows/amd64"
)
for platform in "${platforms[@]}"; do
os="${platform%/*}"
arch="${platform#*/}"
binary="function-hcl-ls"
if [ "$os" = "windows" ]; then
binary="${binary}.exe"
fi
echo "Building ${os}/${arch}..."
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -trimpath -o "../dist/${binary}" .
chmod +x "../dist/${binary}"
cd ../dist
shasum -a 256 "${binary}" > checksums.txt
tar czf "function-hcl-ls-${os}-${arch}.tar.gz" "${binary}" checksums.txt
rm "${binary}" checksums.txt
cd ../function-hcl-ls
done
- name: Create archive checksums
run: |
cd dist
shasum -a 256 *.tar.gz > checksums.txt
- name: Upload dist artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 7
vscode-package:
runs-on: ubuntu-latest
needs: [build, compute-versions]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
working-directory: vscode
run: npm ci --ignore-scripts
- name: Pin language server version
run: echo "${{ needs.compute-versions.outputs.tag_version }}" > vscode/language-server-version.txt
- name: Set extension version from tag
working-directory: vscode
run: npm version ${{ needs.compute-versions.outputs.artifact_version }} --no-git-tag-version
- name: Package extension
working-directory: vscode
run: |
npx @vscode/vsce package
version=${{ needs.compute-versions.outputs.artifact_version }}
mv function-hcl-${version}.vsix function-hcl-vscode-${version}.vsix
- name: Upload vsix artifact
uses: actions/upload-artifact@v4
with:
name: vsix
path: vscode/*.vsix
retention-days: 7
jetbrains-package:
runs-on: ubuntu-latest
needs: [build, compute-versions]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build plugin
working-directory: jetbrains
run: |
./gradlew buildPlugin -PpluginVersion=${{ needs.compute-versions.outputs.artifact_version }} -PlanguageServerVersion=${{ needs.compute-versions.outputs.tag_version }}
version=${{ needs.compute-versions.outputs.artifact_version }}
mv build/distributions/function-hcl-${version}.zip build/distributions/function-hcl-jetbrains-${version}.zip
- name: Upload plugin artifact
uses: actions/upload-artifact@v4
with:
name: jetbrains-plugin
path: jetbrains/build/distributions/*.zip
retention-days: 7
release:
runs-on: ubuntu-latest
needs:
- build
- vscode-package
- jetbrains-package
steps:
- name: Download dist artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Download vsix artifact
uses: actions/download-artifact@v4
with:
name: vsix
path: vsix/
- name: Download JetBrains plugin artifact
uses: actions/download-artifact@v4
with:
name: jetbrains-plugin
path: jetbrains-plugins/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
dist/*.tar.gz
dist/checksums.txt
vsix/*.vsix
jetbrains-plugins/*.zip
vscode-publish:
runs-on: ubuntu-latest
needs: release
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Download vsix artifact
uses: actions/download-artifact@v4
with:
name: vsix
path: vsix/
- name: Publish to VS Code Marketplace
run: |
for vsix in vsix/*.vsix; do
echo "Publishing ${vsix}..."
npx @vscode/vsce publish --packagePath "$vsix"
done
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
jetbrains-publish:
runs-on: ubuntu-latest
needs: [release, compute-versions]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Publish plugin to JetBrains Marketplace
working-directory: jetbrains
run: ./gradlew publishPlugin --no-configuration-cache -PpluginVersion=${{ needs.compute-versions.outputs.artifact_version }} -PlanguageServerVersion=${{ needs.compute-versions.outputs.tag_version }}
env:
PUBLISH_TOKEN: ${{ secrets.JETBRAINS_PUBLISH_TOKEN }}
CERTIFICATE_CHAIN: ${{ secrets.JETBRAINS_CERTIFICATE_CHAIN }}
PRIVATE_KEY: ${{ secrets.JETBRAINS_PRIVATE_KEY }}
PRIVATE_KEY_PASSWORD: ${{ secrets.JETBRAINS_PRIVATE_KEY_PASSWORD }}