|
| 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 | +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows |
| 5 | +on: |
| 6 | + create: |
| 7 | + push: |
| 8 | + paths: |
| 9 | + - ".github/workflows/publish-go-tester-task.ya?ml" |
| 10 | + - "go.mod" |
| 11 | + - "go.sum" |
| 12 | + - "Taskfile.ya?ml" |
| 13 | + - "DistTasks.ya?ml" |
| 14 | + - "**.go" |
| 15 | + - "icon/**" |
| 16 | + - "config.ini" |
| 17 | + - "manifest.xml" |
| 18 | + pull_request: |
| 19 | + paths: |
| 20 | + - ".github/workflows/publish-go-tester-task.ya?ml" |
| 21 | + - "go.mod" |
| 22 | + - "go.sum" |
| 23 | + - "Taskfile.ya?ml" |
| 24 | + - "DistTasks.ya?ml" |
| 25 | + - "**.go" |
| 26 | + - "icon/**" |
| 27 | + - "config.ini" |
| 28 | + - "manifest.xml" |
| 29 | + workflow_dispatch: |
| 30 | + repository_dispatch: |
| 31 | + |
| 32 | +env: |
| 33 | + GO_VERSION: "1.14" |
| 34 | + |
| 35 | +jobs: |
| 36 | + run-determination: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + outputs: |
| 39 | + result: ${{ steps.determination.outputs.result }} |
| 40 | + steps: |
| 41 | + - name: Determine if the rest of the workflow should run |
| 42 | + id: determination |
| 43 | + run: | |
| 44 | + RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x" |
| 45 | + # The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead. |
| 46 | + if [[ \ |
| 47 | + "${{ github.event_name }}" != "create" || \ |
| 48 | + "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX \ |
| 49 | + ]]; then |
| 50 | + # Run the other jobs. |
| 51 | + RESULT="true" |
| 52 | + else |
| 53 | + # There is no need to run the other jobs. |
| 54 | + RESULT="false" |
| 55 | + fi |
| 56 | +
|
| 57 | + echo "::set-output name=result::$RESULT" |
| 58 | +
|
| 59 | + #this job is heavily customized because the build is quite a bit different from other tooling team projects |
| 60 | + build: |
| 61 | + needs: run-determination |
| 62 | + if: needs.run-determination.outputs.result == 'true' |
| 63 | + |
| 64 | + #use the strategy instead because we still use the native build |
| 65 | + strategy: |
| 66 | + matrix: |
| 67 | + os: [ubuntu-18.04, windows-2019, macos-10.15] |
| 68 | + arch: [-amd64] |
| 69 | + include: |
| 70 | + - os: windows-2019 |
| 71 | + arch: -386 |
| 72 | + |
| 73 | + defaults: |
| 74 | + run: |
| 75 | + shell: bash |
| 76 | + |
| 77 | + runs-on: ${{ matrix.os }} |
| 78 | + |
| 79 | + steps: |
| 80 | + |
| 81 | + - name: Set env vars |
| 82 | + run: | |
| 83 | + echo $(go env GOPATH)/bin >> $GITHUB_PATH |
| 84 | +
|
| 85 | + - name: Disable EOL conversions |
| 86 | + run: git config --global core.autocrlf false |
| 87 | + |
| 88 | + - name: Checkout repository |
| 89 | + uses: actions/checkout@v2 |
| 90 | + |
| 91 | + - name: Install Go |
| 92 | + uses: actions/setup-go@v2 |
| 93 | + with: |
| 94 | + go-version: ${{ env.GO_VERSION }} |
| 95 | + |
| 96 | + # dependencies used for compiling the GUI |
| 97 | + - name: Install Dependencies (Linux) |
| 98 | + run: sudo apt update && sudo apt install -y --no-install-recommends build-essential libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev |
| 99 | + if: runner.os == 'Linux' |
| 100 | + |
| 101 | + - name: Install Task |
| 102 | + uses: arduino/setup-task@v1 |
| 103 | + with: |
| 104 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 105 | + version: 3.x |
| 106 | + |
| 107 | + - name: Build the Agent for linux |
| 108 | + run: task go:build |
| 109 | + if: runner.os == 'Linux' |
| 110 | + |
| 111 | + # build the agent without GUI support (no tray icon) |
| 112 | + - name: Build the Agent-cli |
| 113 | + run: task go:build-cli |
| 114 | + if: runner.os == 'Linux' |
| 115 | + |
| 116 | + # the manifest is required by windows GUI apps, otherwise the binary will crash with: "Unable to create main window: TTM_ADDTOOL failed" (for reference https://github.com/lxn/walk/issues/28) |
| 117 | + # rsrc will produce a *.syso file that should get automatically recognized by go build command and linked into an executable. |
| 118 | + - name: Download tool to embed manifest in win binary |
| 119 | + run: go get github.com/akavel/rsrc |
| 120 | + if: runner.os == 'Windows' |
| 121 | + |
| 122 | + # building the agent for win requires a different task because of an extra flag |
| 123 | + - name: Build the Agent for win32 |
| 124 | + env: |
| 125 | + GOARCH: 386 # 32bit architecture (for support) |
| 126 | + GO386: 387 # support old instruction sets without MMX (used in the Pentium 4) (will be deprecated in GO > 1.15 https://golang.org/doc/go1.15) |
| 127 | + run: task go:build-win |
| 128 | + if: runner.os == 'Windows' && matrix.arch == '-386' |
| 129 | + |
| 130 | + - name: Build the Agent for win64 |
| 131 | + run: task go:build-win # GOARCH=amd64 by default on the runners |
| 132 | + if: runner.os == 'Windows' && matrix.arch == '-amd64' |
| 133 | + |
| 134 | + - name: Build the Agent for macos |
| 135 | + env: |
| 136 | + MACOSX_DEPLOYMENT_TARGET: 10.11 # minimum supported version for mac |
| 137 | + CGO_CFLAGS: -mmacosx-version-min=10.11 |
| 138 | + CGO_LDFLAGS: -mmacosx-version-min=10.11 |
| 139 | + run: task go:build |
| 140 | + if: runner.os == 'macOS' |
| 141 | + |
| 142 | + # config.ini is required by the executable when it's run |
| 143 | + - name: Upload artifacts |
| 144 | + uses: actions/upload-artifact@v2 |
| 145 | + with: |
| 146 | + name: arduino-create-agent-${{ matrix.os }}${{ matrix.arch }} |
| 147 | + path: | |
| 148 | + arduino-create-agent* |
| 149 | + config.ini |
| 150 | + if-no-files-found: error |
0 commit comments