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 <<EOF + source = ["arduino-create-agent-${{ env.RUNS_ON }}/arduino-create-agent"] + bundle_id = "cc.arduino.arduino-agent" + sign { + application_identity = "Developer ID Application: ARDUINO SA (7KT7ZWMCJT)" + } + # Ask Gon for zip output to force notarization process to take place. + # The CI will ignore the zip output, using the signed binary only. + zip { + output_path = "arduino-create-agent.zip" + } + EOF + - name: Code sign and notarize app env: AC_USERNAME: ${{ secrets.AC_USERNAME }} AC_PASSWORD: ${{ secrets.AC_PASSWORD }} run: | + echo "gon will notarize executable in arduino-create-agent-${{ env.RUNS_ON }}/arduino-create-agent" gon -log-level=debug -log-json gon.config.hcl - # gon will notarize executable in "arduino-create-agent-${{ env.RUNS_ON }}/arduino-create-agent - # The CI will ignore the zip output, using the signed binary only. timeout-minutes: 30 # This step will overwrite the non signed mac artifact (arduino-create-agent-${{ env.RUNS_ON }}) @@ -171,13 +192,20 @@ jobs: strategy: fail-fast: false # if one os is failing continue nonetheless matrix: # used to generate installers for different OS and not for runs-on - operating-system: [ubuntu-18.04, windows-2019, macos-10.15] include: - operating-system: ubuntu-18.04 install-builder-name: linux-x64 executable-path: artifacts/linux-amd64/ - operating-system: windows-2019 + arch: -386 + browser: edge + install-builder-name: windows + executable-path: artifacts/windows/ + extension: .exe + installer-extension: .exe + - operating-system: windows-2019 + arch: -amd64 browser: edge install-builder-name: windows executable-path: artifacts/windows/ @@ -213,7 +241,7 @@ jobs: - name: Download artifact uses: actions/download-artifact@v2 with: - name: arduino-create-agent-${{ matrix.operating-system }} + name: arduino-create-agent-${{ matrix.operating-system }}${{ matrix.arch }} path: ${{ matrix.executable-path }} # path expected by installbuilder # zip artifacts do not mantain executable permission @@ -244,10 +272,10 @@ jobs: - name: Launch Bitrock installbuilder-20 with CERT_INSTALL && CHOICE_CERT_INSTALL run: | ${{ env.INSTALLBUILDER_PATH }} build installer.xml ${{ matrix.install-builder-name }} --verbose --license /tmp/license.xml --setvars ${INSTALLER_VARS} ${{ env.CERT_INSTALL }} - mv -v ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CI${{matrix.installer-extension}} ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-${{matrix.browser}}${{matrix.installer-extension}} + mv -v ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CI${{matrix.installer-extension}} ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}${{ matrix.arch }}-installer-${{matrix.browser}}${{matrix.installer-extension}} ${{ env.INSTALLBUILDER_PATH }} build installer.xml ${{ matrix.install-builder-name }} --verbose --license /tmp/license.xml --setvars ${INSTALLER_VARS} ${{ env.CHOICE_CERT_INSTALL }} - cp -vr ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CC${{matrix.installer-extension}} ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-chrome${{matrix.installer-extension}} - mv -v ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CC${{matrix.installer-extension}} ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-firefox${{matrix.installer-extension}} + cp -vr ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CC${{matrix.installer-extension}} ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}${{ matrix.arch }}-installer-chrome${{matrix.installer-extension}} + mv -v ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CC${{matrix.installer-extension}} ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}${{ matrix.arch }}-installer-firefox${{matrix.installer-extension}} rm -r ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-C* if: matrix.operating-system == 'windows-2019' || matrix.operating-system == 'macos-10.15' @@ -264,7 +292,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v2 with: - name: ArduinoCreateAgent-${{ matrix.install-builder-name }} + name: ArduinoCreateAgent-${{ matrix.install-builder-name }}${{ matrix.arch }} path: ArduinoCreateAgent* if-no-files-found: error @@ -378,7 +406,7 @@ jobs: mv -v ArduinoCreateAgent-linux-x64/* release/ cat ArduinoCreateAgent-osx/*.tar | tar -xvf - -i -C release/ rm -v release/._ArduinoCreateAgent*.dmg - mv -v ArduinoCreateAgent-windows/* release/ + mv -v ArduinoCreateAgent-windows*/* release/ - name: Create Github Release uses: actions/create-release@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4d711e6e7..5e082621a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,13 @@ jobs: test-matrix: 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 }} @@ -21,7 +27,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) @@ -49,9 +55,9 @@ jobs: - name: Run unit tests run: task test-unit - - name: Build the Agent + - name: Build the Agent for linux run: task build - if: matrix.operating-system != 'windows-2019' + if: matrix.operating-system == 'ubuntu-18.04' # build the agent without GUI support (no tray icon) - name: Build the Agent-cli @@ -59,11 +65,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 @@ -71,5 +75,27 @@ 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.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