|
1 | 1 | # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/publish-go-tester-task.md
|
2 | 2 | name: Publish Tester Build
|
3 | 3 |
|
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 |
5 | 5 | on:
|
| 6 | + create: |
6 | 7 | push:
|
7 | 8 | paths:
|
8 | 9 | - ".github/workflows/publish-go-tester-task.ya?ml"
|
|
23 | 24 | repository_dispatch:
|
24 | 25 |
|
25 | 26 | env:
|
| 27 | + # As defined by the Taskfile's PROJECT_NAME variable |
| 28 | + PROJECT_NAME: serial-discovery |
26 | 29 | # As defined by the Taskfile's DIST_DIR variable
|
27 | 30 | DIST_DIR: dist
|
28 |
| - BUILDS_ARTIFACT: build-artifacts |
29 | 31 |
|
30 | 32 | jobs:
|
31 |
| - build: |
| 33 | + run-determination: |
32 | 34 | runs-on: ubuntu-latest
|
33 |
| - |
| 35 | + outputs: |
| 36 | + result: ${{ steps.determination.outputs.result }} |
34 | 37 | 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 |
39 | 55 |
|
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 |
45 | 57 |
|
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 |
47 | 67 | run: |
|
48 | 68 | PACKAGE_NAME_PREFIX="test"
|
49 | 69 | if [ "${{ github.event_name }}" = "pull_request" ]; then
|
50 | 70 | PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.event.number }}"
|
51 | 71 | fi
|
52 | 72 | PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.sha }}-"
|
53 |
| - export PACKAGE_NAME_PREFIX |
54 |
| - task dist:all |
55 | 73 |
|
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 |
62 | 75 |
|
63 |
| - artifacts: |
64 |
| - name: ${{ matrix.artifact.name }} artifact |
65 |
| - needs: build |
| 76 | + build: |
| 77 | + needs: package-name-prefix |
| 78 | + name: Build ${{ matrix.os.name }} |
66 | 79 | runs-on: ubuntu-latest
|
67 | 80 |
|
68 | 81 | strategy:
|
69 | 82 | 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" |
74 | 92 | name: Linux_X86-32
|
75 |
| - - path: "*Linux_64bit.tar.gz" |
| 93 | + - task: Linux_64bit |
| 94 | + path: "*Linux_64bit.tar.gz" |
76 | 95 | 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" |
80 | 98 | name: Linux_ARMv6
|
81 |
| - - path: "*Linux_ARMv7.tar.gz" |
| 99 | + - task: Linux_ARMv7 |
| 100 | + path: "*Linux_ARMv7.tar.gz" |
82 | 101 | 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" |
84 | 107 | 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 |
89 | 111 |
|
90 | 112 | 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 |
93 | 118 | 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 }} |
96 | 127 |
|
97 |
| - - name: Upload individual build artifact |
| 128 | + # Transfer builds to artifacts job |
| 129 | + - name: Upload build artifact |
98 | 130 | uses: actions/upload-artifact@v3
|
99 | 131 | 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 }} |
102 | 134 |
|
103 |
| - clean: |
104 |
| - needs: artifacts |
| 135 | + checksums: |
| 136 | + needs: |
| 137 | + - build |
| 138 | + - package-name-prefix |
105 | 139 | runs-on: ubuntu-latest
|
106 | 140 |
|
107 | 141 | 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 |
110 | 159 | with:
|
111 |
| - name: ${{ env.BUILDS_ARTIFACT }} |
| 160 | + path: ./*checksums.txt |
| 161 | + name: checksums |
0 commit comments