Skip to content

Commit 038fd91

Browse files
authoredMay 23, 2023
Merge pull request #157 from MatteoPologruto/deprecate-set-output
Sync workflows with their upstream template
2 parents db7ceeb + 0e6d316 commit 038fd91

11 files changed

+278
-348
lines changed
 

‎.github/workflows/check-go-dependencies-task.yml

+13-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
RESULT="false"
5757
fi
5858
59-
echo "::set-output name=result::$RESULT"
59+
echo "result=$RESULT" >> $GITHUB_OUTPUT
6060
6161
check-cache:
6262
needs: run-determination
@@ -69,6 +69,12 @@ jobs:
6969
with:
7070
submodules: recursive
7171

72+
# This is required to allow jonabc/setup-licensed to install licensed via Ruby gem.
73+
- name: Install Ruby
74+
uses: ruby/setup-ruby@v1
75+
with:
76+
ruby-version: ruby # Install latest version
77+
7278
- name: Install licensed
7379
uses: jonabc/setup-licensed@v1
7480
with:
@@ -119,6 +125,12 @@ jobs:
119125
with:
120126
submodules: recursive
121127

128+
# This is required to allow jonabc/setup-licensed to install licensed via Ruby gem.
129+
- name: Install Ruby
130+
uses: ruby/setup-ruby@v1
131+
with:
132+
ruby-version: ruby # Install latest version
133+
122134
- name: Install licensed
123135
uses: jonabc/setup-licensed@v1
124136
with:

‎.github/workflows/check-go-task.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
RESULT="false"
5151
fi
5252
53-
echo "::set-output name=result::$RESULT"
53+
echo "result=$RESULT" >> $GITHUB_OUTPUT
5454
5555
check-errors:
5656
name: check-errors (${{ matrix.module.path }})

‎.github/workflows/check-license.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
RESULT="false"
5555
fi
5656
57-
echo "::set-output name=result::$RESULT"
57+
echo "result=$RESULT" >> $GITHUB_OUTPUT
5858
5959
check-license:
6060
needs: run-determination

‎.github/workflows/check-markdown-task.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
RESULT="false"
6161
fi
6262
63-
echo "::set-output name=result::$RESULT"
63+
echo "result=$RESULT" >> $GITHUB_OUTPUT
6464
6565
lint:
6666
needs: run-determination

‎.github/workflows/check-taskfiles.yml

+28-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ env:
77

88
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
99
on:
10+
create:
1011
push:
1112
paths:
1213
- ".github/workflows/check-taskfiles.ya?ml"
@@ -28,8 +29,33 @@ on:
2829
repository_dispatch:
2930

3031
jobs:
32+
run-determination:
33+
runs-on: ubuntu-latest
34+
outputs:
35+
result: ${{ steps.determination.outputs.result }}
36+
steps:
37+
- name: Determine if the rest of the workflow should run
38+
id: determination
39+
run: |
40+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
41+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
42+
if [[
43+
"${{ github.event_name }}" != "create" ||
44+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
45+
]]; then
46+
# Run the other jobs.
47+
RESULT="true"
48+
else
49+
# There is no need to run the other jobs.
50+
RESULT="false"
51+
fi
52+
53+
echo "result=$RESULT" >> $GITHUB_OUTPUT
54+
3155
validate:
3256
name: Validate ${{ matrix.file }}
57+
needs: run-determination
58+
if: needs.run-determination.outputs.result == 'true'
3359
runs-on: ubuntu-latest
3460

3561
strategy:
@@ -53,8 +79,8 @@ jobs:
5379
id: download-schema
5480
uses: carlosperate/download-file-action@v2
5581
with:
56-
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
57-
file-url: https://json.schemastore.org/taskfile.json
82+
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
83+
file-url: https://taskfile.dev/schema.json
5884
location: ${{ runner.temp }}/taskfile-schema
5985

6086
- name: Install JSON schema validator

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

+38-24
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: '^[0-9]+\.[0-9]+\.[0-9]+.*$'
@@ -40,15 +55,15 @@ jobs:
4055
version: 3.x
4156

4257
- name: Build
43-
run: task dist:all
58+
run: task dist:${{ matrix.os }}
4459

4560
- name: Upload artifacts
4661
uses: actions/upload-artifact@v3
4762
with:
4863
if-no-files-found: error
4964
name: ${{ env.ARTIFACT_NAME }}
5065
path: ${{ env.DIST_DIR }}
51-
66+
5267
notarize-macos:
5368
name: Notarize ${{ matrix.artifact.name }}
5469
runs-on: macos-latest
@@ -82,7 +97,8 @@ jobs:
8297
env:
8398
KEYCHAIN: "sign.keychain"
8499
INSTALLER_CERT_MAC_PATH: "/tmp/ArduinoCerts2020.p12"
85-
KEYCHAIN_PASSWORD: keychainpassword # Arbitrary password for a keychain that exists only for the duration of the job, so not secret
100+
# Arbitrary password for a keychain that exists only for the duration of the job, so not secret
101+
KEYCHAIN_PASSWORD: keychainpassword
86102
run: |
87103
echo "${{ secrets.INSTALLER_CERT_MAC_P12 }}" | base64 --decode > "${{ env.INSTALLER_CERT_MAC_PATH }}"
88104
security create-keychain -p "${{ env.KEYCHAIN_PASSWORD }}" "${{ env.KEYCHAIN }}"
@@ -132,14 +148,10 @@ jobs:
132148
run: |
133149
gon "${{ env.GON_CONFIG_PATH }}"
134150
135-
- name: Re-package binary and output checksum
151+
- name: Re-package binary
136152
id: re-package
137153
working-directory: ${{ env.DIST_DIR }}
138-
# This step performs the following:
139-
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
140-
# 2. Recalculate package checksum
141-
# 3. Output the new checksum to include in the nnnnnn-checksums.txt file
142-
# (it cannot be done there because of workflow job parallelization)
154+
# Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
143155
run: |
144156
# GitHub's upload/download-artifact actions don't preserve file permissions,
145157
# so we need to add execution permission back until the action is made to do this.
@@ -149,11 +161,9 @@ jobs:
149161
tar -czvf "$PACKAGE_FILENAME" \
150162
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
151163
-C ../../ LICENSE.txt
152-
CHECKSUM_LINE="$(shasum -a 256 $PACKAGE_FILENAME)"
153164
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
154-
echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"
155165
156-
- name: Upload artifacts
166+
- name: Upload artifact
157167
uses: actions/upload-artifact@v3
158168
with:
159169
if-no-files-found: error
@@ -170,25 +180,29 @@ jobs:
170180
with:
171181
name: ${{ env.ARTIFACT_NAME }}
172182
path: ${{ env.DIST_DIR }}
173-
174-
- name: Update checksum
183+
184+
- name: Create checksum file
185+
working-directory: ${{ env.DIST_DIR}}
175186
run: |
176-
declare -a checksum_lines=("${{ needs.notarize-macos.outputs.checksum-darwin_amd64 }}" "${{ needs.notarize-macos.outputs.checksum-darwin_arm64 }}")
177-
for checksum_line in "${checksum_lines[@]}"
178-
do
179-
CHECKSUM=$(echo ${checksum_line} | cut -d " " -f 1)
180-
PACKAGE_FILENAME=$(echo ${checksum_line} | cut -d " " -f 2)
181-
perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
182-
done
187+
TAG="${GITHUB_REF/refs\/tags\//}"
188+
sha256sum ${{ env.PROJECT_NAME }}_${TAG}* > ${TAG}-checksums.txt
183189
184190
- name: Identify Prerelease
185191
# This is a workaround while waiting for create-release action
186192
# to implement auto pre-release based on tag
187193
id: prerelease
188194
run: |
189-
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.0.0.zip
190-
unzip -p /tmp/3.0.0.zip semver-tool-3.0.0/src/semver >/tmp/semver && chmod +x /tmp/semver
191-
if [[ "$(/tmp/semver get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
195+
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.2.0.zip
196+
unzip -p /tmp/3.2.0.zip semver-tool-3.2.0/src/semver >/tmp/semver && chmod +x /tmp/semver
197+
if [[ \
198+
"$(
199+
/tmp/semver get prerel \
200+
"${GITHUB_REF/refs\/tags\//}"
201+
)" != \
202+
"" \
203+
]]; then
204+
echo "IS_PRE=true" >> $GITHUB_OUTPUT
205+
fi
192206
193207
- name: Create Github Release and upload artifacts
194208
uses: ncipollo/release-action@v1

‎.github/workflows/sync-labels.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md
22
name: Sync Labels
33

4-
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
4+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
55
on:
66
push:
77
paths:
@@ -86,7 +86,7 @@ jobs:
8686
steps:
8787
- name: Set environment variables
8888
run: |
89-
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
89+
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
9090
echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV"
9191
9292
- name: Determine whether to dry run
@@ -103,7 +103,7 @@ jobs:
103103
run: |
104104
# Use of this flag in the github-label-sync command will cause it to only check the validity of the
105105
# configuration.
106-
echo "::set-output name=flag::--dry-run"
106+
echo "flag=--dry-run" >> $GITHUB_OUTPUT
107107
108108
- name: Checkout repository
109109
uses: actions/checkout@v3

‎DistTasks.yml

+1-24
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,8 @@ version: "3"
2020
vars:
2121
CONTAINER: "docker.elastic.co/beats-dev/golang-crossbuild"
2222
GO_VERSION: "1.18.3"
23-
CHECKSUM_FILE: "{{.VERSION}}-checksums.txt"
2423

2524
tasks:
26-
all:
27-
desc: Build for distribution for all platforms
28-
cmds:
29-
- task: Windows_32bit
30-
- task: Windows_64bit
31-
- task: Linux_32bit
32-
- task: Linux_64bit
33-
- task: Linux_ARMv6
34-
- task: Linux_ARMv7
35-
- task: Linux_ARM64
36-
- task: macOS_64bit
37-
- task: macOS_ARM64
38-
3925
Windows_32bit:
4026
desc: Builds Windows 32 bit binaries
4127
dir: "{{.DIST_DIR}}"
@@ -48,7 +34,6 @@ tasks:
4834
-p "{{.BUILD_PLATFORM}}"
4935
5036
zip {{.PACKAGE_NAME}} {{.PLATFORM_DIR}}/{{.PROJECT_NAME}}.exe ../LICENSE.txt -j
51-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
5237
5338
vars:
5439
PLATFORM_DIR: "{{.PROJECT_NAME}}_windows_386"
@@ -70,7 +55,6 @@ tasks:
7055
-p "{{.BUILD_PLATFORM}}"
7156
7257
zip {{.PACKAGE_NAME}} {{.PLATFORM_DIR}}/{{.PROJECT_NAME}}.exe ../LICENSE.txt -j
73-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
7458
7559
vars:
7660
PLATFORM_DIR: "{{.PROJECT_NAME}}_windows_amd64"
@@ -92,7 +76,6 @@ tasks:
9276
-p "{{.BUILD_PLATFORM}}"
9377
9478
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
95-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
9679
9780
vars:
9881
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_amd32"
@@ -114,7 +97,6 @@ tasks:
11497
-p "{{.BUILD_PLATFORM}}"
11598
11699
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
117-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
118100
119101
vars:
120102
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_amd64"
@@ -136,7 +118,6 @@ tasks:
136118
-p "{{.BUILD_PLATFORM}}"
137119
138120
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
139-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
140121
141122
vars:
142123
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_7"
@@ -158,7 +139,6 @@ tasks:
158139
-p "{{.BUILD_PLATFORM}}"
159140
160141
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
161-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
162142
163143
vars:
164144
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_6"
@@ -208,10 +188,9 @@ tasks:
208188
-p "{{.BUILD_PLATFORM}}"
209189
210190
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
211-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
212191
213192
vars:
214-
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_6"
193+
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_64"
215194
BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}"
216195
BUILD_PLATFORM: "linux/arm64"
217196
CONTAINER_TAG: "{{.GO_VERSION}}-arm"
@@ -230,7 +209,6 @@ tasks:
230209
-p "{{.BUILD_PLATFORM}}"
231210
232211
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
233-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
234212
235213
vars:
236214
PLATFORM_DIR: "{{.PROJECT_NAME}}_osx_darwin_amd64"
@@ -265,7 +243,6 @@ tasks:
265243
-p "{{.BUILD_PLATFORM}}"
266244
267245
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
268-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
269246
270247
vars:
271248
PLATFORM_DIR: "{{.PROJECT_NAME}}_osx_darwin_arm64"

‎Taskfile.yml

+21-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ vars:
1010
DEFAULT_GO_MODULE_PATH: ./
1111
DEFAULT_GO_PACKAGES:
1212
sh: |
13-
echo $(cd {{default "./" .GO_MODULE_PATH}} && go list ./... | tr '\n' ' ' || echo '"ERROR: Unable to discover Go packages"')
13+
echo $(
14+
cd {{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}} &&
15+
go list ./... | tr '\n' ' ' ||
16+
echo '"ERROR: Unable to discover Go packages"'
17+
)
1418
# build vars
1519
COMMIT:
1620
sh: echo "$(git log --no-show-signature -n 1 --format=%h)"
@@ -45,17 +49,25 @@ tasks:
4549
docs:generate:
4650
desc: Create all generated documentation content
4751

52+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-dependencies-task/Taskfile.yml
53+
general:prepare-deps:
54+
desc: Prepare project dependencies for license check
55+
# No preparation is needed for Go module-based projects.
56+
4857
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml
4958
general:cache-dep-licenses:
5059
desc: Cache dependency license metadata
60+
deps:
61+
- task: general:prepare-deps
5162
cmds:
5263
- |
5364
if ! which licensed &>/dev/null; then
5465
if [[ {{OS}} == "windows" ]]; then
5566
echo "Licensed does not have Windows support."
5667
echo "Please use Linux/macOS or download the dependencies cache from the GitHub Actions workflow artifact."
5768
else
58-
echo "licensed not found or not in PATH. Please install: https://github.com/github/licensed#as-an-executable"
69+
echo "licensed not found or not in PATH."
70+
echo "Please install: https://github.com/github/licensed#as-an-executable"
5971
fi
6072
exit 1
6173
fi
@@ -78,7 +90,7 @@ tasks:
7890
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/go-task/Taskfile.yml
7991
go:build:
8092
desc: Build the Go code
81-
dir: '{{default "./" .GO_MODULE_PATH}}'
93+
dir: "{{.DEFAULT_GO_MODULE_PATH}}"
8294
cmds:
8395
- go build -v {{.LDFLAGS}}
8496

@@ -95,21 +107,21 @@ tasks:
95107
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
96108
go:fix:
97109
desc: Modernize usages of outdated APIs
98-
dir: '{{default "./" .GO_MODULE_PATH}}'
110+
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
99111
cmds:
100112
- go fix {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
101113

102114
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
103115
go:format:
104116
desc: Format Go code
105-
dir: '{{default "./" .GO_MODULE_PATH}}'
117+
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
106118
cmds:
107119
- go fmt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
108120

109121
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
110122
go:lint:
111123
desc: Lint Go code
112-
dir: '{{default "./" .GO_MODULE_PATH}}'
124+
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
113125
cmds:
114126
- |
115127
if ! which golint &>/dev/null; then
@@ -148,7 +160,7 @@ tasks:
148160
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
149161
go:vet:
150162
desc: Check for errors in Go code
151-
dir: '{{default "./" .GO_MODULE_PATH}}'
163+
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
152164
cmds:
153165
- go vet {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
154166

@@ -164,7 +176,8 @@ tasks:
164176
# npx --call uses the native shell, which makes it too difficult to use npx for this application on Windows,
165177
# so the Windows user is required to have markdown-link-check installed and in PATH.
166178
if ! which markdown-link-check &>/dev/null; then
167-
echo "markdown-link-check not found or not in PATH. Please install: https://github.com/tcort/markdown-link-check#readme"
179+
echo "markdown-link-check not found or not in PATH."
180+
echo "Please install: https://github.com/tcort/markdown-link-check#readme"
168181
exit 1
169182
fi
170183
# Default behavior of the task on Windows is to exit the task when the first broken link causes a non-zero

‎package-lock.json

+169-281
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"devDependencies": {
33
"ajv-cli": "^5.0.0",
44
"ajv-formats": "^2.1.1",
5-
"markdown-link-check": "^3.10.2",
6-
"markdownlint-cli": "^0.32.1"
5+
"markdown-link-check": "^3.11.2",
6+
"markdownlint-cli": "^0.33.0"
77
}
88
}

0 commit comments

Comments
 (0)
Please sign in to comment.