diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 93c33c505..ca90e7218 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,9 +10,17 @@ jobs: build: strategy: matrix: - operating-system: [ubuntu-18.04, windows-2019, macos-10.15] + include: + - operating-system: ubuntu-18.04 + - operating-system: windows-2019 + arch: -386 + - operating-system: windows-2019 + arch: -amd64 + - operating-system: macos-10.15 runs-on: ${{ matrix.operating-system }} + env: + TAG_VERSION: ${GITHUB_REF##*/} # will be available to all steps and will be used by task build steps: - name: Disable EOL conversions @@ -24,7 +32,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2 with: - go-version: "1.15" + go-version: "1.14" # dependencies used for compiling the GUI - name: Install Dependencies (Linux) @@ -53,7 +61,7 @@ jobs: run: task test-unit - name: Build the Agent for linux - run: task build + run: task build if: matrix.operating-system == 'ubuntu-18.04' # build the agent without GUI support (no tray icon) @@ -62,11 +70,9 @@ jobs: if: matrix.operating-system == 'ubuntu-18.04' # 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) - # rsrc will produce *.syso files that should get automatically recognized by go build command and linked into an executable. - - name: Embed manifest in win binary - run: | - go get github.com/akavel/rsrc - rsrc -arch 386 -manifest manifest.xml + # rsrc will produce a *.syso file that should get automatically recognized by go build command and linked into an executable. + - name: Download tool to embed manifest in win binary + run: go get github.com/akavel/rsrc if: matrix.operating-system == 'windows-2019' # building the agent for win requires a different task because of an extra flag @@ -74,12 +80,18 @@ jobs: env: GOARCH: 386 # 32bit architecture (for support) 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) - run: task build-win32 - if: matrix.operating-system == 'windows-2019' + run: task build-win + if: matrix.operating-system == 'windows-2019' && matrix.arch == '-386' + + - name: Build the Agent for win64 + run: task build-win # GOARCH=amd64 by default on the runners + if: matrix.operating-system == 'windows-2019' && matrix.arch == '-amd64' - name: Build the Agent for macos env: - MACOSX_DEPLOYMENT_TARGET: 10.9 # minimum supported version for mac + MACOSX_DEPLOYMENT_TARGET: 10.11 # minimum supported version for mac + CGO_CFLAGS: -mmacosx-version-min=10.11 + CGO_LDFLAGS: -mmacosx-version-min=10.11 run: task build if: matrix.operating-system == 'macos-10.15' @@ -87,7 +99,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v2 with: - name: arduino-create-agent-${{ matrix.operating-system }} + name: arduino-create-agent-${{ matrix.operating-system }}${{ matrix.arch }} path: | arduino-create-agent* config.ini @@ -101,12 +113,6 @@ jobs: RUNS_ON: macos-10.15 # used to parametrize filenames steps: - - name: Checkout - uses: actions/checkout@v2 - with: - repository: 'bcmi-labs/arduino-create-agent-installer' # the repo which contains gon.config.hcl - token: ${{ secrets.ARDUINO_CREATE_AGENT_CI_PAT }} - - name: Download artifact uses: actions/download-artifact@v2 with: @@ -130,14 +136,29 @@ jobs: wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip unzip gon_macos.zip -d /usr/local/bin + - name: Write gon config to file + # gon does not allow env variables in config file (https://github.com/mitchellh/gon/issues/20) + run: | + cat > gon.config.hcl < 1.15 https://golang.org/doc/go1.15) - run: task build-win32 - if: matrix.operating-system == 'windows-2019' + run: task build-win + if: matrix.operating-system == 'windows-2019' && matrix.arch == '-386' + + - name: Build the Agent for win64 + run: task build-win # GOARCH=amd64 by default on the runners + if: matrix.operating-system == 'windows-2019' && matrix.arch == '-amd64' + + - name: Build the Agent for macos + env: + MACOSX_DEPLOYMENT_TARGET: 10.11 # minimum supported version for mac + CGO_CFLAGS: -mmacosx-version-min=10.11 + CGO_LDFLAGS: -mmacosx-version-min=10.11 + run: task build + if: matrix.operating-system == 'macos-10.15' + + # config.ini is required by the executable when it's run + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: arduino-create-agent-${{ matrix.operating-system }}${{ matrix.arch }} + path: | + arduino-create-agent* + config.ini + if-no-files-found: error diff --git a/Taskfile.yml b/Taskfile.yml index fed3fdee7..a744299e0 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,26 +1,32 @@ -version: "2" +version: '3' tasks: build: - desc: Build the project + desc: Build the project, to use a specific version use `task build TAG_VERSION=x.x.x` cmds: - - go build -v -i {{.LDFLAGS}} + - go build -v -i {{default "" .ADDITIONAL_FLAGS}} -o {{default "arduino-create-agent" .APP_NAME}} -ldflags '-X main.version={{default .TAG_TEST .TAG_VERSION}} -X main.git_revision={{.COMMIT}} {{default "" .WIN_FLAGS}}' + vars: + COMMIT: + sh: git log -n 1 --format=%h build-cli: desc: Build the project without tray support cmds: - - go build -v -i -tags cli -o {{.APP_NAME}}_cli {{.LDFLAGS}} + - task: build + vars: + APP_NAME: arduino-create-agent_cli + ADDITIONAL_FLAGS: -tags cli - build-win32: - desc: Build the project for win 32 bit + build-win: + desc: Build the project for win, to build 32bit `export GOARCH=386` and for 64 bit `export GOARCH=amd64` before `task build-win` cmds: - - go build -v -i {{.WIN_LDFLAGS}} - - test: - desc: Run the full testsuite, `legacy` will be skipped - cmds: - - task: test-unit + - rsrc -arch {{.GOARCH}} -manifest manifest.xml # GOARCH shoud be either amd64 or 386 + - task: build + vars: + APP_NAME: arduino-create-agent.exe + WIN_FLAGS: -H=windowsgui + - rm *.syso # rm file to avoid compilation problems on other platforms test-unit: desc: Run unit tests only @@ -43,38 +49,16 @@ tasks: # - task: python:check # - task: docs:check # - task: config:check - + vars: + TAG_TEST: "0.0.0-dev" + GOARCH: + sh: go env GOARCH # all modules of this project except for "gen/..." module DEFAULT_TARGETS: sh: echo `go list ./... | grep -v 'arduino-create-agent/gen/' | tr '\n' ' '` - # build vars - APP_NAME: arduino-create-agent - WIN_FLAGS: -H=windowsgui - COMMIT: - sh: echo ${TRAVIS_COMMIT:-`git log -n 1 --format=%h`} - TAG: - sh: echo `git describe --tags --abbrev=0` - LDFLAGS: > - -ldflags '-X main.version={{.TAG}} - -X main.git_revision={{.COMMIT}}' - WIN_LDFLAGS: > - -ldflags '-X main.version={{.TAG}} - -X main.git_revision={{.COMMIT}} - {{.WIN_FLAGS}}' - # test vars GOFLAGS: "-timeout 10m -v -coverpkg=./... -covermode=atomic" - TEST_VERSIONSTRING: "0.0.0-alpha" - TEST_COMMIT: "deadbeef" - TEST_LDFLAGS: > - -ldflags '-X main.version={{.TEST_VERSIONSTRING}} - -X main.git_revision={{.TEST_COMMIT}}' # check-lint vars GOLINTBIN: sh: go list -f {{"{{"}}".Target{{"}}"}}" golang.org/x/lint/golint GOLINTFLAGS: "-min_confidence 0.8 -set_exit_status" - # # docs versioning - # DOCS_VERSION: dev - # DOCS_ALIAS: "" - # DOCS_REMOTE: "origin" - PRETTIER: prettier@2.0.5