Skip to content

Commit 38c6054

Browse files
Merge pull request #57 from MatteoPologruto/macos-arm64-support
Update release workflows to add macOS arm64 support
2 parents 806b624 + aebd1e9 commit 38c6054

File tree

3 files changed

+180
-100
lines changed

3 files changed

+180
-100
lines changed
Lines changed: 101 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/publish-go-tester-task.md
22
name: Publish Tester Build
33

4-
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
4+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
55
on:
6+
create:
67
push:
78
paths:
89
- ".github/workflows/publish-go-tester-task.ya?ml"
@@ -23,89 +24,138 @@ on:
2324
repository_dispatch:
2425

2526
env:
27+
# As defined by the Taskfile's PROJECT_NAME variable
28+
PROJECT_NAME: serial-discovery
2629
# As defined by the Taskfile's DIST_DIR variable
2730
DIST_DIR: dist
28-
BUILDS_ARTIFACT: build-artifacts
2931

3032
jobs:
31-
build:
33+
run-determination:
3234
runs-on: ubuntu-latest
33-
35+
outputs:
36+
result: ${{ steps.determination.outputs.result }}
3437
steps:
35-
- name: Checkout repository
36-
uses: actions/checkout@v3
37-
with:
38-
fetch-depth: 0
38+
- name: Determine if the rest of the workflow should run
39+
id: determination
40+
run: |
41+
RELEASE_BRANCH_REGEX="refs/heads/v[0-9]+.[0-9]+.x"
42+
TAG_REGEX="refs/tags/.*"
43+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
44+
if [[
45+
("${{ github.event_name }}" != "create" ||
46+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX) &&
47+
! "${{ github.ref }}" =~ $TAG_REGEX
48+
]]; then
49+
# Run the other jobs.
50+
RESULT="true"
51+
else
52+
# There is no need to run the other jobs.
53+
RESULT="false"
54+
fi
3955
40-
- name: Install Task
41-
uses: arduino/setup-task@v1
42-
with:
43-
repo-token: ${{ secrets.GITHUB_TOKEN }}
44-
version: 3.x
56+
echo "result=$RESULT" >> $GITHUB_OUTPUT
4557
46-
- name: Build
58+
package-name-prefix:
59+
needs: run-determination
60+
if: needs.run-determination.outputs.result == 'true'
61+
runs-on: ubuntu-latest
62+
outputs:
63+
prefix: ${{ steps.calculation.outputs.prefix }}
64+
steps:
65+
- name: package name prefix calculation
66+
id: calculation
4767
run: |
4868
PACKAGE_NAME_PREFIX="test"
4969
if [ "${{ github.event_name }}" = "pull_request" ]; then
5070
PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.event.number }}"
5171
fi
5272
PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.sha }}-"
53-
export PACKAGE_NAME_PREFIX
54-
task dist:all
5573
56-
# Transfer builds to artifacts job
57-
- name: Upload combined builds artifact
58-
uses: actions/upload-artifact@v3
59-
with:
60-
path: ${{ env.DIST_DIR }}
61-
name: ${{ env.BUILDS_ARTIFACT }}
74+
echo "prefix=$PACKAGE_NAME_PREFIX" >> $GITHUB_OUTPUT
6275
63-
artifacts:
64-
name: ${{ matrix.artifact.name }} artifact
65-
needs: build
76+
build:
77+
needs: package-name-prefix
78+
name: Build ${{ matrix.os.name }}
6679
runs-on: ubuntu-latest
6780

6881
strategy:
6982
matrix:
70-
artifact:
71-
- path: "*checksums.txt"
72-
name: checksums
73-
- path: "*Linux_32bit.tar.gz"
83+
os:
84+
- task: Windows_32bit
85+
path: "*Windows_32bit.zip"
86+
name: Windows_X86-32
87+
- task: Windows_64bit
88+
path: "*Windows_64bit.zip"
89+
name: Windows_X86-64
90+
- task: Linux_32bit
91+
path: "*Linux_32bit.tar.gz"
7492
name: Linux_X86-32
75-
- path: "*Linux_64bit.tar.gz"
93+
- task: Linux_64bit
94+
path: "*Linux_64bit.tar.gz"
7695
name: Linux_X86-64
77-
- path: "*Linux_ARM64.tar.gz"
78-
name: Linux_ARM64
79-
- path: "*Linux_ARMv6.tar.gz"
96+
- task: Linux_ARMv6
97+
path: "*Linux_ARMv6.tar.gz"
8098
name: Linux_ARMv6
81-
- path: "*Linux_ARMv7.tar.gz"
99+
- task: Linux_ARMv7
100+
path: "*Linux_ARMv7.tar.gz"
82101
name: Linux_ARMv7
83-
- path: "*macOS_64bit.tar.gz"
102+
- task: Linux_ARM64
103+
path: "*Linux_ARM64.tar.gz"
104+
name: Linux_ARM64
105+
- task: macOS_64bit
106+
path: "*macOS_64bit.tar.gz"
84107
name: macOS_64
85-
- path: "*Windows_32bit.zip"
86-
name: Windows_X86-32
87-
- path: "*Windows_64bit.zip"
88-
name: Windows_X86-64
108+
- task: macOS_ARM64
109+
path: "*macOS_ARM64.tar.gz"
110+
name: macOS_ARM64
89111

90112
steps:
91-
- name: Download combined builds artifact
92-
uses: actions/download-artifact@v3
113+
- name: Checkout repository
114+
uses: actions/checkout@v3
115+
116+
- name: Install Task
117+
uses: arduino/setup-task@v1
93118
with:
94-
name: ${{ env.BUILDS_ARTIFACT }}
95-
path: ${{ env.BUILDS_ARTIFACT }}
119+
repo-token: ${{ secrets.GITHUB_TOKEN }}
120+
version: 3.x
121+
122+
- name: Build
123+
run: |
124+
PACKAGE_NAME_PREFIX=${{ needs.package-name-prefix.outputs.prefix }}
125+
export PACKAGE_NAME_PREFIX
126+
task dist:${{ matrix.os.task }}
96127
97-
- name: Upload individual build artifact
128+
# Transfer builds to artifacts job
129+
- name: Upload build artifact
98130
uses: actions/upload-artifact@v3
99131
with:
100-
path: ${{ env.BUILDS_ARTIFACT }}/${{ matrix.artifact.path }}
101-
name: ${{ matrix.artifact.name }}
132+
path: ${{ env.DIST_DIR }}/${{ matrix.os.path }}
133+
name: ${{ matrix.os.name }}
102134

103-
clean:
104-
needs: artifacts
135+
checksums:
136+
needs:
137+
- build
138+
- package-name-prefix
105139
runs-on: ubuntu-latest
106140

107141
steps:
108-
- name: Remove unneeded combined builds artifact
109-
uses: geekyeggo/delete-artifact@v2
142+
- name: Download build artifacts
143+
uses: actions/download-artifact@v3
144+
145+
- name: Create checksum file
146+
run: |
147+
TAG="${{ needs.package-name-prefix.outputs.prefix }}git-snapshot"
148+
declare -a artifacts=($(ls -d */))
149+
for artifact in ${artifacts[@]}
150+
do
151+
cd $artifact
152+
checksum=$(sha256sum ${{ env.PROJECT_NAME }}_${TAG}*)
153+
cd ..
154+
echo $checksum >> ${TAG}-checksums.txt
155+
done
156+
157+
- name: Upload checksum artifact
158+
uses: actions/upload-artifact@v3
110159
with:
111-
name: ${{ env.BUILDS_ARTIFACT }}
160+
path: ./*checksums.txt
161+
name: checksums

.github/workflows/release-go-task.yml

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,28 @@ jobs:
1919
create-release-artifacts:
2020
runs-on: ubuntu-latest
2121

22+
strategy:
23+
matrix:
24+
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
34+
2235
steps:
2336
- name: Checkout repository
2437
uses: actions/checkout@v3
2538
with:
2639
fetch-depth: 0
2740

2841
- name: Create changelog
42+
# Avoid creating the same changelog for each os
43+
if: matrix.os == 'Windows_32bit'
2944
uses: arduino/create-changelog@v1
3045
with:
3146
tag-regex: '^v[0-9]+\.[0-9]+\.[0-9]+.*$'
@@ -40,16 +55,47 @@ jobs:
4055
version: 3.x
4156

4257
- name: Build
43-
run: task dist:all
58+
run: task dist:${{ matrix.os }}
59+
60+
- name: Upload artifacts
61+
uses: actions/upload-artifact@v3
62+
with:
63+
if-no-files-found: error
64+
name: ${{ env.ARTIFACT_NAME }}
65+
path: ${{ env.DIST_DIR }}
66+
67+
create-release:
68+
runs-on: ubuntu-latest
69+
needs: create-release-artifacts
70+
71+
steps:
72+
- name: Download artifact
73+
uses: actions/download-artifact@v3
74+
with:
75+
name: ${{ env.ARTIFACT_NAME }}
76+
path: ${{ env.DIST_DIR }}
77+
78+
- name: Create checksum file
79+
working-directory: ${{ env.DIST_DIR}}
80+
run: |
81+
TAG="${GITHUB_REF/refs\/tags\//}"
82+
sha256sum ${{ env.PROJECT_NAME }}_${TAG}* > ${TAG}-checksums.txt
4483
4584
- name: Identify Prerelease
4685
# This is a workaround while waiting for create-release action
4786
# to implement auto pre-release based on tag
4887
id: prerelease
4988
run: |
50-
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.0.0.zip
51-
unzip -p /tmp/3.0.0.zip semver-tool-3.0.0/src/semver >/tmp/semver && chmod +x /tmp/semver
52-
if [[ "$(/tmp/semver get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
89+
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.2.0.zip
90+
unzip -p /tmp/3.2.0.zip semver-tool-3.2.0/src/semver >/tmp/semver && chmod +x /tmp/semver
91+
if [[
92+
"$(
93+
/tmp/semver get prerel \
94+
"${GITHUB_REF/refs\/tags\//}"
95+
)"
96+
]]; then
97+
echo "IS_PRE=true" >> $GITHUB_OUTPUT
98+
fi
5399
54100
- name: Create Github Release and upload artifacts
55101
uses: ncipollo/release-action@v1

0 commit comments

Comments
 (0)