|
| 1 | +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/publish-go-tester-task.md |
| 2 | +name: Publish Tester Build |
| 3 | + |
| 4 | +env: |
| 5 | + # See: https://github.com/actions/setup-go/tree/v2#readme |
| 6 | + GO_VERSION: ^1.16.2 |
| 7 | + # As defined by the Taskfile's DIST_DIR variable |
| 8 | + DIST_DIR: dist |
| 9 | + BUILDS_ARTIFACT: build-artifacts |
| 10 | + |
| 11 | +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows |
| 12 | +on: |
| 13 | + push: |
| 14 | + paths: |
| 15 | + - ".github/workflows/publish-go-tester-task.ya?ml" |
| 16 | + - "go.mod" |
| 17 | + - "go.sum" |
| 18 | + - "Taskfile.ya?ml" |
| 19 | + - "DistTasks.ya?ml" |
| 20 | + - "**.go" |
| 21 | + pull_request: |
| 22 | + paths: |
| 23 | + - ".github/workflows/publish-go-tester-task.ya?ml" |
| 24 | + - "go.mod" |
| 25 | + - "go.sum" |
| 26 | + - "Taskfile.ya?ml" |
| 27 | + - "DistTasks.ya?ml" |
| 28 | + - "**.go" |
| 29 | + workflow_dispatch: |
| 30 | + repository_dispatch: |
| 31 | + |
| 32 | +jobs: |
| 33 | + build: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + |
| 36 | + steps: |
| 37 | + - name: Checkout repository |
| 38 | + uses: actions/checkout@v2 |
| 39 | + |
| 40 | + - name: Install Go |
| 41 | + uses: actions/setup-go@v2 |
| 42 | + with: |
| 43 | + go-version: ${{ env.GO_VERSION }} |
| 44 | + |
| 45 | + - name: Install Task |
| 46 | + uses: arduino/setup-task@v1 |
| 47 | + with: |
| 48 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + version: 3.x |
| 50 | + |
| 51 | + - name: Build |
| 52 | + run: | |
| 53 | + PACKAGE_NAME_PREFIX="test" |
| 54 | + if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 55 | + PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.event.number }}" |
| 56 | + fi |
| 57 | + PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.sha }}-" |
| 58 | + export PACKAGE_NAME_PREFIX |
| 59 | + task dist:all |
| 60 | +
|
| 61 | + # Transfer builds to artifacts job |
| 62 | + - name: Upload combined builds artifact |
| 63 | + uses: actions/upload-artifact@v2 |
| 64 | + with: |
| 65 | + path: ${{ env.DIST_DIR }} |
| 66 | + name: ${{ env.BUILDS_ARTIFACT }} |
| 67 | + |
| 68 | + artifacts: |
| 69 | + name: ${{ matrix.artifact.name }} artifact |
| 70 | + needs: build |
| 71 | + runs-on: ubuntu-latest |
| 72 | + |
| 73 | + strategy: |
| 74 | + matrix: |
| 75 | + artifact: |
| 76 | + - path: "*Linux_32bit.tar.gz" |
| 77 | + name: Linux_X86-32 |
| 78 | + - path: "*Linux_64bit.tar.gz" |
| 79 | + name: Linux_X86-64 |
| 80 | + - path: "*Linux_ARM.tar.gz" |
| 81 | + name: Linux_ARM |
| 82 | + - path: "*Linux_ARM64.tar.gz" |
| 83 | + name: Linux_ARM64 |
| 84 | + - path: "*macOS_64bit.tar.gz" |
| 85 | + name: macOS_64 |
| 86 | + - path: "*Windows_32bit.zip" |
| 87 | + name: Windows_X86-32 |
| 88 | + - path: "*Windows_64bit.zip" |
| 89 | + name: Windows_X86-64 |
| 90 | + |
| 91 | + steps: |
| 92 | + - name: Download combined builds artifact |
| 93 | + uses: actions/download-artifact@v2 |
| 94 | + with: |
| 95 | + name: ${{ env.BUILDS_ARTIFACT }} |
| 96 | + path: ${{ env.BUILDS_ARTIFACT }} |
| 97 | + |
| 98 | + - name: Upload individual build artifact |
| 99 | + uses: actions/upload-artifact@v2 |
| 100 | + with: |
| 101 | + path: ${{ env.BUILDS_ARTIFACT }}/${{ matrix.artifact.path }} |
| 102 | + name: ${{ matrix.artifact.name }} |
| 103 | + |
| 104 | + clean: |
| 105 | + needs: artifacts |
| 106 | + runs-on: ubuntu-latest |
| 107 | + |
| 108 | + steps: |
| 109 | + - name: Remove unneeded combined builds artifact |
| 110 | + uses: geekyeggo/delete-artifact@v1 |
| 111 | + with: |
| 112 | + name: ${{ env.BUILDS_ARTIFACT }} |
0 commit comments