8
8
DIST_DIR : dist
9
9
# The project's folder on Arduino's download server for uploading builds
10
10
AWS_PLUGIN_TARGET : /arduino-language-server/
11
- ARTIFACT_NAME : dist
11
+ AWS_REGION : " us-east-1"
12
+ ARTIFACT_PREFIX : dist-
12
13
13
14
on :
14
15
push :
@@ -22,15 +23,24 @@ jobs:
22
23
strategy :
23
24
matrix :
24
25
os :
25
- - Windows_32bit
26
- - Windows_64bit
27
- - Linux_32bit
28
- - Linux_64bit
29
- - Linux_ARMv6
30
- - Linux_ARMv7
31
- - Linux_ARM64
32
- - macOS_64bit
33
- - macOS_ARM64
26
+ - task : Windows_32bit
27
+ artifact-suffix : Windows_32bit
28
+ - task : Windows_64bit
29
+ artifact-suffix : Windows_64bit
30
+ - task : Linux_32bit
31
+ artifact-suffix : Linux_32bit
32
+ - task : Linux_64bit
33
+ artifact-suffix : Linux_64bit
34
+ - task : Linux_ARMv6
35
+ artifact-suffix : Linux_ARMv6
36
+ - task : Linux_ARMv7
37
+ artifact-suffix : Linux_ARMv7
38
+ - task : Linux_ARM64
39
+ artifact-suffix : Linux_ARM64
40
+ - task : macOS_64bit
41
+ artifact-suffix : macOS_64bit
42
+ - task : macOS_ARM64
43
+ artifact-suffix : macOS_ARM64
34
44
35
45
steps :
36
46
- name : Checkout repository
40
50
41
51
- name : Create changelog
42
52
# Avoid creating the same changelog for each os
43
- if : matrix.os == 'Windows_32bit'
53
+ if : matrix.os.task == 'Windows_32bit'
44
54
uses : arduino/create-changelog@v1
45
55
with :
46
56
tag-regex : ' ^[0-9]+\.[0-9]+\.[0-9]+.*$'
@@ -55,17 +65,17 @@ jobs:
55
65
version : 3.x
56
66
57
67
- name : Build
58
- run : task dist:${{ matrix.os }}
68
+ run : task dist:${{ matrix.os.task }}
59
69
60
70
- name : Upload artifacts
61
- uses : actions/upload-artifact@v3
71
+ uses : actions/upload-artifact@v4
62
72
with :
63
73
if-no-files-found : error
64
- name : ${{ env.ARTIFACT_NAME }}
74
+ name : ${{ env.ARTIFACT_PREFIX }}${{ matrix.os.artifact-suffix }}
65
75
path : ${{ env.DIST_DIR }}
66
76
67
77
notarize-macos :
68
- name : Notarize ${{ matrix.artifact.name }}
78
+ name : Notarize ${{ matrix.build.folder-suffix }}
69
79
runs-on : macos-latest
70
80
needs : create-release-artifacts
71
81
outputs :
@@ -77,20 +87,29 @@ jobs:
77
87
78
88
strategy :
79
89
matrix :
80
- artifact :
81
- - name : darwin_amd64
82
- path : " macOS_64bit.tar.gz"
83
- - name : darwin_arm64
84
- path : " macOS_ARM64.tar.gz"
90
+ build :
91
+ - artifact-suffix : macOS_64bit
92
+ folder-suffix : darwin_amd64
93
+ package-suffix : " macOS_64bit.tar.gz"
94
+ - artifact-suffix : macOS_ARM64
95
+ folder-suffix : darwin_arm64
96
+ package-suffix : " macOS_ARM64.tar.gz"
85
97
86
98
steps :
99
+ - name : Set environment variables
100
+ run : |
101
+ # See: https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable
102
+ echo "BUILD_FOLDER=${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}" >> "$GITHUB_ENV"
103
+ TAG="${GITHUB_REF/refs\/tags\//}"
104
+ echo "PACKAGE_FILENAME=${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.build.package-suffix }}" >> $GITHUB_ENV
105
+
87
106
- name : Checkout repository
88
107
uses : actions/checkout@v4
89
108
90
109
- name : Download artifacts
91
- uses : actions/download-artifact@v3
110
+ uses : actions/download-artifact@v4
92
111
with :
93
- name : ${{ env.ARTIFACT_NAME }}
112
+ name : ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
94
113
path : ${{ env.DIST_DIR }}
95
114
96
115
- name : Import Code-Signing Certificates
@@ -127,7 +146,7 @@ jobs:
127
146
run : |
128
147
cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
129
148
# See: https://github.com/Bearer/gon#configuration-file
130
- source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"]
149
+ source = ["${{ env.DIST_DIR }}/${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"]
131
150
bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
132
151
133
152
sign {
@@ -156,30 +175,33 @@ jobs:
156
175
run : |
157
176
# GitHub's upload/download-artifact actions don't preserve file permissions,
158
177
# so we need to add execution permission back until the action is made to do this.
159
- chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"
160
- TAG="${GITHUB_REF/refs\/tags\//}"
161
- PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.artifact.path }}"
162
- tar -czvf "$PACKAGE_FILENAME" \
163
- -C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
178
+ chmod +x "${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"
179
+ tar -czvf "${{ env.PACKAGE_FILENAME }}" \
180
+ -C "${{ env.BUILD_FOLDER }}/" "${{ env.PROJECT_NAME }}" \
164
181
-C ../../ LICENSE.txt
165
- echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
166
182
167
- - name : Upload artifact
168
- uses : actions/upload-artifact@v3
183
+ - name : Replace artifact with notarized build
184
+ uses : actions/upload-artifact@v4
169
185
with :
170
186
if-no-files-found : error
171
- name : ${{ env.ARTIFACT_NAME }}
187
+ name : ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
188
+ overwrite : true
172
189
path : ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }}
173
190
174
191
create-release :
175
192
runs-on : ubuntu-latest
193
+ environment : production
176
194
needs : notarize-macos
195
+ permissions :
196
+ contents : write
197
+ id-token : write # This is required for requesting the JWT
177
198
178
199
steps :
179
200
- name : Download artifact
180
- uses : actions/download-artifact@v3
201
+ uses : actions/download-artifact@v4
181
202
with :
182
- name : ${{ env.ARTIFACT_NAME }}
203
+ pattern : ${{ env.ARTIFACT_PREFIX }}*
204
+ merge-multiple : true
183
205
path : ${{ env.DIST_DIR }}
184
206
185
207
- name : Create checksum file
@@ -216,12 +238,12 @@ jobs:
216
238
# (all the files we need are in the DIST_DIR root)
217
239
artifacts : ${{ env.DIST_DIR }}/*
218
240
241
+ - name : configure aws credentials
242
+ uses : aws-actions/configure-aws-credentials@v4
243
+ with :
244
+ role-to-assume : ${{ secrets.AWS_ROLE_TO_ASSUME }}
245
+ role-session-name : " github_${{ env.PROJECT_NAME }}"
246
+ aws-region : ${{ env.AWS_REGION }}
247
+
219
248
- name : Upload release files on Arduino downloads servers
220
- uses : docker://plugins/s3
221
- env :
222
- PLUGIN_SOURCE : " ${{ env.DIST_DIR }}/*"
223
- PLUGIN_TARGET : ${{ env.AWS_PLUGIN_TARGET }}
224
- PLUGIN_STRIP_PREFIX : " ${{ env.DIST_DIR }}/"
225
- PLUGIN_BUCKET : ${{ secrets.DOWNLOADS_BUCKET }}
226
- AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
227
- AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
249
+ run : aws s3 sync ${{ env.DIST_DIR }} s3://${{ secrets.DOWNLOADS_BUCKET }}${{ env.AWS_PLUGIN_TARGET }}
0 commit comments