26
26
env :
27
27
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
28
28
GO_VERSION : " 1.18"
29
+ # As defined by the Taskfile's PROJECT_NAME variable
30
+ PROJECT_NAME : arduino-fwuploader
29
31
# As defined by the Taskfile's DIST_DIR variable
30
32
DIST_DIR : dist
31
- BUILDS_ARTIFACT : build-artifacts
32
33
33
34
jobs :
34
35
run-determination :
@@ -40,10 +41,12 @@ jobs:
40
41
id : determination
41
42
run : |
42
43
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
44
+ TAG_REGEX="refs/tags/.*"
43
45
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
44
46
if [[
45
- "${{ github.event_name }}" != "create" ||
46
- "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
47
+ ("${{ github.event_name }}" != "create" ||
48
+ "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX) &&
49
+ ! "${{ github.ref }}" =~ $TAG_REGEX
47
50
]]; then
48
51
# Run the other jobs.
49
52
RESULT="true"
@@ -54,10 +57,59 @@ jobs:
54
57
55
58
echo "result=$RESULT" >> $GITHUB_OUTPUT
56
59
57
- build :
60
+ package-name-prefix :
58
61
needs : run-determination
59
62
if : needs.run-determination.outputs.result == 'true'
60
63
runs-on : ubuntu-latest
64
+ outputs :
65
+ prefix : ${{ steps.calculation.outputs.prefix }}
66
+ steps :
67
+ - name : package name prefix calculation
68
+ id : calculation
69
+ run : |
70
+ PACKAGE_NAME_PREFIX="test"
71
+ if [ "${{ github.event_name }}" = "pull_request" ]; then
72
+ PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.event.number }}"
73
+ fi
74
+ PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.sha }}-"
75
+
76
+ echo "prefix=$PACKAGE_NAME_PREFIX" >> $GITHUB_OUTPUT
77
+
78
+ build :
79
+ needs : package-name-prefix
80
+ name : Build ${{ matrix.os.name }}
81
+ runs-on : ubuntu-latest
82
+
83
+ strategy :
84
+ matrix :
85
+ os :
86
+ - task : Windows_32bit
87
+ path : " *Windows_32bit.zip"
88
+ name : Windows_X86-32
89
+ - task : Windows_64bit
90
+ path : " *Windows_64bit.zip"
91
+ name : Windows_X86-64
92
+ - task : Linux_32bit
93
+ path : " *Linux_32bit.tar.gz"
94
+ name : Linux_X86-32
95
+ - task : Linux_64bit
96
+ path : " *Linux_64bit.tar.gz"
97
+ name : Linux_X86-64
98
+ - task : Linux_ARMv6
99
+ path : " *Linux_ARMv6.tar.gz"
100
+ name : Linux_ARMv6
101
+ - task : Linux_ARMv7
102
+ path : " *Linux_ARMv7.tar.gz"
103
+ name : Linux_ARMv7
104
+ - task : Linux_ARM64
105
+ path : " *Linux_ARM64.tar.gz"
106
+ name : Linux_ARM64
107
+ - task : macOS_64bit
108
+ path : " *macOS_64bit.tar.gz"
109
+ name : macOS_64
110
+ - task : macOS_ARM64
111
+ path : " *macOS_ARM64.tar.gz"
112
+ name : macOS_ARM64
61
113
62
114
steps :
63
115
- name : Checkout repository
@@ -76,69 +128,41 @@ jobs:
76
128
77
129
- name : Build
78
130
run : |
79
- PACKAGE_NAME_PREFIX="test"
80
- if [ "${{ github.event_name }}" = "pull_request" ]; then
81
- PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.event.number }}"
82
- fi
83
- PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.sha }}-"
131
+ PACKAGE_NAME_PREFIX=${{ needs.package-name-prefix.outputs.prefix }}
84
132
export PACKAGE_NAME_PREFIX
85
- task dist:all
133
+ task dist:${{ matrix.os.task }}
86
134
87
135
# Transfer builds to artifacts job
88
- - name : Upload combined builds artifact
136
+ - name : Upload build artifact
89
137
uses : actions/upload-artifact@v3
90
138
with :
91
- path : ${{ env.DIST_DIR }}
92
- name : ${{ env.BUILDS_ARTIFACT }}
139
+ path : ${{ env.DIST_DIR }}/${{ matrix.os.path }}
140
+ name : ${{ matrix.os.name }}
93
141
94
- artifacts :
95
- name : ${{ matrix.artifact.name }} artifact
96
- needs : build
142
+ checksums :
143
+ needs :
144
+ - build
145
+ - package-name-prefix
97
146
runs-on : ubuntu-latest
98
147
99
- strategy :
100
- matrix :
101
- artifact :
102
- - path : " *checksums.txt"
103
- name : checksums
104
- - path : " *Linux_32bit.tar.gz"
105
- name : Linux_X86-32
106
- - path : " *Linux_64bit.tar.gz"
107
- name : Linux_X86-64
108
- - path : " *Linux_ARM64.tar.gz"
109
- name : Linux_ARM64
110
- - path : " *Linux_ARMv6.tar.gz"
111
- name : Linux_ARMv6
112
- - path : " *Linux_ARMv7.tar.gz"
113
- name : Linux_ARMv7
114
- - path : " *macOS_64bit.tar.gz"
115
- name : macOS_64
116
- - path : " *macOS_ARM64.tar.gz"
117
- name : macOS_ARM64
118
- - path : " *Windows_32bit.zip"
119
- name : Windows_X86-32
120
- - path : " *Windows_64bit.zip"
121
- name : Windows_X86-64
122
-
123
148
steps :
124
- - name : Download combined builds artifact
149
+ - name : Download build artifacts
125
150
uses : actions/download-artifact@v3
126
- with :
127
- name : ${{ env.BUILDS_ARTIFACT }}
128
- path : ${{ env.BUILDS_ARTIFACT }}
129
151
130
- - name : Upload individual build artifact
152
+ - name : Create checksum file
153
+ run : |
154
+ TAG="${{ needs.package-name-prefix.outputs.prefix }}git-snapshot"
155
+ declare -a artifacts=($(ls -d */))
156
+ for artifact in ${artifacts[@]}
157
+ do
158
+ cd $artifact
159
+ checksum=$(sha256sum ${{ env.PROJECT_NAME }}_${TAG}*)
160
+ cd ..
161
+ echo $checksum >> ${TAG}-checksums.txt
162
+ done
163
+
164
+ - name : Upload checksum artifact
131
165
uses : actions/upload-artifact@v3
132
166
with :
133
- path : ${{ env.BUILDS_ARTIFACT }}/${{ matrix.artifact.path }}
134
- name : ${{ matrix.artifact.name }}
135
-
136
- clean :
137
- needs : artifacts
138
- runs-on : ubuntu-latest
139
-
140
- steps :
141
- - name : Remove unneeded combined builds artifact
142
- uses : geekyeggo/delete-artifact@v2
143
- with :
144
- name : ${{ env.BUILDS_ARTIFACT }}
167
+ path : ./*checksums.txt
168
+ name : checksums
0 commit comments