88 DIST_DIR : dist
99 # The project's folder on Arduino's download server for uploading builds
1010 AWS_PLUGIN_TARGET : /arduino-language-server/
11- ARTIFACT_NAME : dist
11+ AWS_REGION : " us-east-1"
12+ ARTIFACT_PREFIX : dist-
1213
1314on :
1415 push :
@@ -22,15 +23,24 @@ jobs:
2223 strategy :
2324 matrix :
2425 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
3444
3545 steps :
3646 - name : Checkout repository
4050
4151 - name : Create changelog
4252 # Avoid creating the same changelog for each os
43- if : matrix.os == 'Windows_32bit'
53+ if : matrix.os.task == 'Windows_32bit'
4454 uses : arduino/create-changelog@v1
4555 with :
4656 tag-regex : ' ^[0-9]+\.[0-9]+\.[0-9]+.*$'
@@ -55,17 +65,17 @@ jobs:
5565 version : 3.x
5666
5767 - name : Build
58- run : task dist:${{ matrix.os }}
68+ run : task dist:${{ matrix.os.task }}
5969
6070 - name : Upload artifacts
61- uses : actions/upload-artifact@v3
71+ uses : actions/upload-artifact@v4
6272 with :
6373 if-no-files-found : error
64- name : ${{ env.ARTIFACT_NAME }}
74+ name : ${{ env.ARTIFACT_PREFIX }}${{ matrix.os.artifact-suffix }}
6575 path : ${{ env.DIST_DIR }}
6676
6777 notarize-macos :
68- name : Notarize ${{ matrix.artifact.name }}
78+ name : Notarize ${{ matrix.build.folder-suffix }}
6979 runs-on : macos-latest
7080 needs : create-release-artifacts
7181 outputs :
@@ -77,20 +87,29 @@ jobs:
7787
7888 strategy :
7989 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"
8597
8698 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+
87106 - name : Checkout repository
88107 uses : actions/checkout@v4
89108
90109 - name : Download artifacts
91- uses : actions/download-artifact@v3
110+ uses : actions/download-artifact@v4
92111 with :
93- name : ${{ env.ARTIFACT_NAME }}
112+ name : ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
94113 path : ${{ env.DIST_DIR }}
95114
96115 - name : Import Code-Signing Certificates
@@ -127,7 +146,7 @@ jobs:
127146 run : |
128147 cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
129148 # 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 }}"]
131150 bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
132151
133152 sign {
@@ -156,30 +175,33 @@ jobs:
156175 run : |
157176 # GitHub's upload/download-artifact actions don't preserve file permissions,
158177 # 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 }}" \
164181 -C ../../ LICENSE.txt
165- echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
166182
167- - name : Upload artifact
168- uses : actions/upload-artifact@v3
183+ - name : Replace artifact with notarized build
184+ uses : actions/upload-artifact@v4
169185 with :
170186 if-no-files-found : error
171- name : ${{ env.ARTIFACT_NAME }}
187+ name : ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
188+ overwrite : true
172189 path : ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }}
173190
174191 create-release :
175192 runs-on : ubuntu-latest
193+ environment : production
176194 needs : notarize-macos
195+ permissions :
196+ contents : write
197+ id-token : write # This is required for requesting the JWT
177198
178199 steps :
179200 - name : Download artifact
180- uses : actions/download-artifact@v3
201+ uses : actions/download-artifact@v4
181202 with :
182- name : ${{ env.ARTIFACT_NAME }}
203+ pattern : ${{ env.ARTIFACT_PREFIX }}*
204+ merge-multiple : true
183205 path : ${{ env.DIST_DIR }}
184206
185207 - name : Create checksum file
@@ -216,12 +238,12 @@ jobs:
216238 # (all the files we need are in the DIST_DIR root)
217239 artifacts : ${{ env.DIST_DIR }}/*
218240
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+
219248 - 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