Skip to content

Commit 2298ce8

Browse files
Push releases to the S3 downloads bucket (#12)
* Automatically determine pre-releases * Push releases to the downloads bucket
1 parent 598e909 commit 2298ce8

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

.github/workflows/release.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
env:
99
PROJECT_NAME: "arduino-flasher-cli"
1010
DIST_DIR: build
11+
# The project's folder on Arduino's download server for uploading builds
12+
AWS_PLUGIN_TARGET: /arduino-flasher-cli/
13+
AWS_REGION: "us-east-1"
1114

1215
jobs:
1316
build:
@@ -264,6 +267,10 @@ jobs:
264267
create-release:
265268
runs-on: ubuntu-24.04
266269
needs: [build, sign-windows-executable, notarize-macos]
270+
environment: production
271+
permissions:
272+
contents: write
273+
id-token: write # This is required for requesting the JWT
267274
steps:
268275
- name: Checkout
269276
uses: actions/checkout@v4
@@ -276,10 +283,46 @@ jobs:
276283
merge-multiple: true
277284
path: ${{ env.DIST_DIR }}
278285

286+
- name: Identify Prerelease
287+
# This is a workaround while waiting for create-release action
288+
# to implement auto pre-release based on tag
289+
id: prerelease
290+
run: |
291+
wget \
292+
-q \
293+
-P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.2.0.zip
294+
295+
unzip \
296+
-p /tmp/3.2.0.zip semver-tool-3.2.0/src/semver \
297+
>/tmp/semver
298+
299+
chmod \
300+
+x \
301+
/tmp/semver
302+
303+
if [[ "$(/tmp/semver get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then
304+
echo "IS_PRE=true" >>$GITHUB_OUTPUT
305+
fi
306+
279307
- name: Upload artifacts index
280308
uses: ncipollo/release-action@v1
281309
with:
282310
token: ${{ secrets.GITHUB_TOKEN }}
283311
draft: false
284-
prerelease: true
312+
prerelease: ${{ steps.prerelease.outputs.IS_PRE }}
285313
artifacts: ${{ env.DIST_DIR }}/*
314+
315+
- name: configure aws credentials
316+
uses: aws-actions/configure-aws-credentials@v5
317+
with:
318+
role-to-assume: ${{ secrets.AWS_IAM_ROLE }}
319+
role-session-name: "github_${{ env.PROJECT_NAME }}"
320+
aws-region: ${{ env.AWS_REGION }}
321+
if: ${{ steps.prerelease.outputs.IS_PRE != 'true' }}
322+
323+
- name: Upload release files on Arduino downloads servers
324+
run: |
325+
aws s3 sync \
326+
${{ env.DIST_DIR }} \
327+
s3://${{ secrets.DOWNLOADS_BUCKET }}${{ env.AWS_PLUGIN_TARGET }}
328+
if: ${{ steps.prerelease.outputs.IS_PRE != 'true' }}

0 commit comments

Comments
 (0)