From ce91c64ea75678e7c6d1c138dd8e37aafc0e380b Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 22 Mar 2021 20:44:27 -0700 Subject: [PATCH 1/3] Don't use magic string for job transfer artifact name Previously, the build CI/CD workflow had many occurrences of the string "build-artifacts" used for the workflow artifact name. This made the workflow more difficult to understand and maintain. Now a single workflow scoped environment variable is used to define the artifact name. --- .github/workflows/build.yml | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 556c6ecf2..c0462aeb2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,9 @@ on: schedule: - cron: '0 3 * * *' # run every day at 3AM (https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule) +env: + JOB_TRANSFER_ARTIFACT: build-artifacts + jobs: build: @@ -79,7 +82,7 @@ jobs: - name: Upload [GitHub Actions] uses: actions/upload-artifact@v2 with: - name: build-artifacts + name: ${{ env.JOB_TRANSFER_ARTIFACT }} path: electron/build/dist/build-artifacts/ changelog: @@ -121,7 +124,7 @@ jobs: if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') uses: actions/upload-artifact@v2 with: - name: build-artifacts + name: ${{ env.JOB_TRANSFER_ARTIFACT }} path: CHANGELOG.txt publish: @@ -132,14 +135,14 @@ jobs: - name: Download [GitHub Actions] uses: actions/download-artifact@v2 with: - name: build-artifacts - path: build-artifacts + name: ${{ env.JOB_TRANSFER_ARTIFACT }} + path: ${{ env.JOB_TRANSFER_ARTIFACT }} - name: Publish Nightly [S3] uses: docker://plugins/s3 env: - PLUGIN_SOURCE: "build-artifacts/*" - PLUGIN_STRIP_PREFIX: "build-artifacts/" + PLUGIN_SOURCE: "${{ env.JOB_TRANSFER_ARTIFACT }}/*" + PLUGIN_STRIP_PREFIX: "${{ env.JOB_TRANSFER_ARTIFACT }}/" PLUGIN_TARGET: "/arduino-ide/nightly" PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} @@ -153,8 +156,8 @@ jobs: - name: Download [GitHub Actions] uses: actions/download-artifact@v2 with: - name: build-artifacts - path: build-artifacts + name: ${{ env.JOB_TRANSFER_ARTIFACT }} + path: ${{ env.JOB_TRANSFER_ARTIFACT }} - name: Get Tag id: tag_name @@ -166,7 +169,7 @@ jobs: with: repo_token: ${{ secrets.GITHUB_TOKEN }} release_name: ${{ steps.tag_name.outputs.TAG_NAME }} - file: build-artifacts/* + file: ${{ env.JOB_TRANSFER_ARTIFACT }}/* tag: ${{ github.ref }} file_glob: true body: ${{ needs.changelog.outputs.BODY }} @@ -174,8 +177,8 @@ jobs: - name: Publish Release [S3] uses: docker://plugins/s3 env: - PLUGIN_SOURCE: "build-artifacts/*" - PLUGIN_STRIP_PREFIX: "build-artifacts/" + PLUGIN_SOURCE: "${{ env.JOB_TRANSFER_ARTIFACT }}/*" + PLUGIN_STRIP_PREFIX: "${{ env.JOB_TRANSFER_ARTIFACT }}/" PLUGIN_TARGET: "/arduino-ide" PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} From 4d6bda61374ea71128e2f2471c80221698380086 Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 22 Mar 2021 21:05:56 -0700 Subject: [PATCH 2/3] Create separate tester artifacts for each build Previously, a single workflow artifact was created by the "Arduino IDE" GitHub Actions workflow. This artifact contained the builds for each operating system, including all three versions of the Windows build. This resulted in beta testers needing to do a >1 GB download for every build, even though they likely needed only ~200 MB of what they downloaded. Producing separate workflows makes it easier for beta testers to participate in the development and is less wasteful of resources. --- .github/workflows/build.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0462aeb2..999563ba4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -183,3 +183,36 @@ jobs: PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + artifacts: + name: ${{ matrix.artifact.name }} artifact + needs: build + if: always() && needs.build.result != 'skipped' + runs-on: ubuntu-latest + + strategy: + matrix: + artifact: + - path: "*Linux_64bit.zip" + name: Linux_X86-64 + - path: "*macOS_64bit.dmg" + name: macOS + - path: "*Windows_64bit.exe" + name: Windows_X86-64_interactive_installer + - path: "*Windows_64bit.msi" + name: Windows_X86-64_MSI + - path: "*Windows_64bit.zip" + name: Windows_X86-64_zip + + steps: + - name: Download job transfer artifact + uses: actions/download-artifact@v2 + with: + name: ${{ env.JOB_TRANSFER_ARTIFACT }} + path: ${{ env.JOB_TRANSFER_ARTIFACT }} + + - name: Upload tester build artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.artifact.name }} + path: ${{ env.JOB_TRANSFER_ARTIFACT }}/${{ matrix.artifact.path }} From a3287ca1de656d8d5442941b85751e6e08f5d6e5 Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 22 Mar 2021 21:10:55 -0700 Subject: [PATCH 3/3] Delete job transfer workflow artifact The "Arduino IDE" GitHub Actions workflow uses a workflow artifact to transfer the build artifacts between jobs. Now that separate tester build artifacts are produced, the monolithic job transfer artifact is superfluous once the workflow run is finished. Deleting it avoids potential confusion for beta testers and unnecessary storage space usage. --- .github/workflows/build.yml | 68 +++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 999563ba4..b33ef1e30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -85,6 +85,39 @@ jobs: name: ${{ env.JOB_TRANSFER_ARTIFACT }} path: electron/build/dist/build-artifacts/ + artifacts: + name: ${{ matrix.artifact.name }} artifact + needs: build + if: always() && needs.build.result != 'skipped' + runs-on: ubuntu-latest + + strategy: + matrix: + artifact: + - path: "*Linux_64bit.zip" + name: Linux_X86-64 + - path: "*macOS_64bit.dmg" + name: macOS + - path: "*Windows_64bit.exe" + name: Windows_X86-64_interactive_installer + - path: "*Windows_64bit.msi" + name: Windows_X86-64_MSI + - path: "*Windows_64bit.zip" + name: Windows_X86-64_zip + + steps: + - name: Download job transfer artifact + uses: actions/download-artifact@v2 + with: + name: ${{ env.JOB_TRANSFER_ARTIFACT }} + path: ${{ env.JOB_TRANSFER_ARTIFACT }} + + - name: Upload tester build artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.artifact.name }} + path: ${{ env.JOB_TRANSFER_ARTIFACT }}/${{ matrix.artifact.path }} + changelog: needs: build runs-on: ubuntu-latest @@ -184,35 +217,18 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - artifacts: - name: ${{ matrix.artifact.name }} artifact - needs: build + clean: + # This job must run after all jobs that use the transfer artifact. + needs: + - build + - publish + - release + - artifacts if: always() && needs.build.result != 'skipped' runs-on: ubuntu-latest - strategy: - matrix: - artifact: - - path: "*Linux_64bit.zip" - name: Linux_X86-64 - - path: "*macOS_64bit.dmg" - name: macOS - - path: "*Windows_64bit.exe" - name: Windows_X86-64_interactive_installer - - path: "*Windows_64bit.msi" - name: Windows_X86-64_MSI - - path: "*Windows_64bit.zip" - name: Windows_X86-64_zip - steps: - - name: Download job transfer artifact - uses: actions/download-artifact@v2 + - name: Remove unneeded job transfer artifact + uses: geekyeggo/delete-artifact@v1 with: name: ${{ env.JOB_TRANSFER_ARTIFACT }} - path: ${{ env.JOB_TRANSFER_ARTIFACT }} - - - name: Upload tester build artifact - uses: actions/upload-artifact@v2 - with: - name: ${{ matrix.artifact.name }} - path: ${{ env.JOB_TRANSFER_ARTIFACT }}/${{ matrix.artifact.path }}