diff --git a/.github/workflows/i18n-nightly-push.yaml b/.github/workflows/i18n-nightly-push.yaml index 7241150d483..080a74a9106 100644 --- a/.github/workflows/i18n-nightly-push.yaml +++ b/.github/workflows/i18n-nightly-push.yaml @@ -24,6 +24,7 @@ jobs: uses: Arduino/actions/setup-taskfile@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x - name: Run task i18n:push run: task i18n:push diff --git a/.github/workflows/i18n-weekly-pull.yaml b/.github/workflows/i18n-weekly-pull.yaml index 1909f555c63..6bdf1c5391d 100644 --- a/.github/workflows/i18n-weekly-pull.yaml +++ b/.github/workflows/i18n-weekly-pull.yaml @@ -28,6 +28,7 @@ jobs: uses: Arduino/actions/setup-taskfile@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x - name: Run task i18n:pull run: task i18n:pull diff --git a/.github/workflows/link-validation.yaml b/.github/workflows/link-validation.yaml index d12e9957f99..cad3cafedd8 100644 --- a/.github/workflows/link-validation.yaml +++ b/.github/workflows/link-validation.yaml @@ -20,6 +20,7 @@ jobs: uses: Arduino/actions/setup-taskfile@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x - name: Install Go uses: actions/setup-go@v2 diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index 7eb8f1081de..58ef62cdbfb 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -12,22 +12,22 @@ jobs: if: github.repository == 'arduino/arduino-cli' runs-on: ubuntu-latest - container: - image: arduino/arduino-cli:builder-1 - volumes: - # cache go dependencies across pipeline's steps - - ${{ github.workspace }}/go:/go - steps: - name: checkout uses: actions/checkout@v1 with: fetch-depth: 0 - - name: build + - name: Install Taskfile + uses: arduino/actions/setup-taskfile@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x + + - name: Build env: - PACKAGE_NAME_PREFIX: ${{ github.workflow }} - run: goreleaser --snapshot + NIGHTLY: true + run: task dist:all - name: Upload artifacts uses: actions/upload-artifact@v2 @@ -77,14 +77,14 @@ jobs: - name: Re-package binary and update checksum # This step performs the following: # 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file) - # 2. Recalculate package checksum and replace it in the goreleaser nnnnnn-checksums.txt file + # 2. Recalculate package checksum and replace it in the nnnnnn-checksums.txt file run: | # GitHub's upload/download-artifact@v1 actions don't preserve file permissions, # so we need to add execution permission back until @v2 actions are released. - chmod +x dist/arduino_cli_osx_darwin_amd64/arduino-cli + chmod +x dist/arduino-cli_osx_darwin_amd64/arduino-cli PACKAGE_FILENAME="$(basename dist/arduino-cli_${{ github.workflow }}-*_macOS_64bit.tar.gz)" tar -czvf dist/$PACKAGE_FILENAME \ - -C dist/arduino_cli_osx_darwin_amd64/ arduino-cli \ + -C dist/arduino-cli_osx_darwin_amd64/ arduino-cli \ -C ../../ LICENSE.txt CLI_CHECKSUM=$(shasum -a 256 dist/$PACKAGE_FILENAME | cut -d " " -f 1) perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CLI_CHECKSUM} ${PACKAGE_FILENAME}/g;" dist/*-checksums.txt diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index 36b76327d01..7baa8b76015 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -47,6 +47,7 @@ jobs: uses: Arduino/actions/setup-taskfile@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x - name: Setup Go uses: actions/setup-go@v2 diff --git a/.github/workflows/python-lint.yaml b/.github/workflows/python-lint.yaml index 85b7ff6978f..4e4a25063c2 100644 --- a/.github/workflows/python-lint.yaml +++ b/.github/workflows/python-lint.yaml @@ -23,6 +23,7 @@ jobs: uses: Arduino/actions/setup-taskfile@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x - name: Activate Python uses: actions/setup-python@v1 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 99da49f91d2..be5a6f5c17a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,20 +9,28 @@ jobs: create-release-artifacts: runs-on: ubuntu-latest - container: - image: arduino/arduino-cli:builder-1 - volumes: - # cache go dependencies across pipeline's steps - - ${{ github.workspace }}/go:/go - steps: - name: Checkout uses: actions/checkout@v1 with: fetch-depth: 0 + - name: Create changelog + uses: arduino/create-changelog@1.2.0 + with: + tag-regex: '^[0-9]+\.[0-9]+\.[0-9]+$' + filter-regex: '^\[(skip|changelog)[ ,-](skip|changelog)\].*' + case-insensitive-regex: true + changelog-file-path: "dist/CHANGELOG.md" + + - name: Install Taskfile + uses: arduino/actions/setup-taskfile@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x + - name: Build - run: goreleaser + run: task dist:all - name: Upload artifacts uses: actions/upload-artifact@v2 @@ -72,14 +80,14 @@ jobs: - name: Re-package binary and update checksum # This step performs the following: # 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file) - # 2. Recalculate package checksum and replace it in the goreleaser nnnnnn-checksums.txt file + # 2. Recalculate package checksum and replace it in the nnnnnn-checksums.txt file run: | # GitHub's upload/download-artifact@v1 actions don't preserve file permissions, # so we need to add execution permission back until @v2 actions are released. - chmod +x dist/arduino_cli_osx_darwin_amd64/arduino-cli + chmod +x dist/arduino-cli_osx_darwin_amd64/arduino-cli TAG=${GITHUB_REF/refs\/tags\//} tar -czvf dist/arduino-cli_${TAG}_macOS_64bit.tar.gz \ - -C dist/arduino_cli_osx_darwin_amd64/ arduino-cli \ + -C dist/arduino-cli_osx_darwin_amd64/ arduino-cli \ -C ../../ LICENSE.txt CLI_CHECKSUM=$(shasum -a 256 dist/arduino-cli_${TAG}_macOS_64bit.tar.gz | cut -d " " -f 1) perl -pi -w -e "s/.*arduino-cli_${TAG}_macOS_64bit.tar.gz/${CLI_CHECKSUM} arduino-cli_${TAG}_macOS_64bit.tar.gz/g;" dist/*-checksums.txt diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a2280e32153..4354b5c48a5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -39,6 +39,7 @@ jobs: uses: Arduino/actions/setup-taskfile@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x - name: Install Python uses: actions/setup-python@v1 @@ -105,28 +106,27 @@ jobs: runs-on: ubuntu-latest needs: test-matrix - container: - image: arduino/arduino-cli:builder-1 - volumes: - # cache go dependencies across pipeline's steps - - ${{ github.workspace }}/go:/go - steps: - name: checkout uses: actions/checkout@v1 with: fetch-depth: 0 - - name: build - shell: bash + - name: Install Taskfile + uses: arduino/actions/setup-taskfile@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x + + - name: Build run: | PACKAGE_NAME_PREFIX="${{ github.workflow }}" if [ "${{ github.event_name }}" = "pull_request" ]; then PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.event.number }}" fi - PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.sha }}" + PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.sha }}-" export PACKAGE_NAME_PREFIX - goreleaser --snapshot + task dist:all # Uploads all architectures as separate artifacts - name: Upload Linux 32 bit artifact diff --git a/.github/workflows/validate-docs.yaml b/.github/workflows/validate-docs.yaml index b49132ab7c9..1910111d18f 100644 --- a/.github/workflows/validate-docs.yaml +++ b/.github/workflows/validate-docs.yaml @@ -34,6 +34,7 @@ jobs: uses: Arduino/actions/setup-taskfile@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x - name: Setup Go uses: actions/setup-go@v2 diff --git a/.github/workflows/verify-formatting.yaml b/.github/workflows/verify-formatting.yaml index 1d6a9932acf..e2e7997398c 100644 --- a/.github/workflows/verify-formatting.yaml +++ b/.github/workflows/verify-formatting.yaml @@ -28,6 +28,7 @@ jobs: uses: Arduino/actions/setup-taskfile@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x - name: Verify formatting of all files run: task docs:check config:check diff --git a/.goreleaser.yml b/.goreleaser.yml deleted file mode 100644 index 7da443a5128..00000000000 --- a/.goreleaser.yml +++ /dev/null @@ -1,123 +0,0 @@ -# Global section -checksum: - name_template: '{{ .Tag }}-{{ time "20060102" }}-checksums.txt' - -snapshot: - name_template: '{{ .Env.PACKAGE_NAME_PREFIX }}-{{ time "20060102" }}' - -release: - disable: true - -changelog: - filters: - exclude: - # [skip changelog], [skip-changelog], [changelog skip], [changelog-skip] - - '^(?i)\[(skip|changelog)[ ,-](skip|changelog)\].*' - # [skip ci], [skip-ci], [ci skip], [ci-skip] - - '^(?i)\[(skip|ci)[ ,-](skip|ci)\].*' - -# We have multiple builds in order to fine tune -# cross compilations. -builds: - - # OSX - id: arduino_cli_osx - binary: arduino-cli - env: - - CGO_ENABLED=1 - - CXXFLAGS="-mmacosx-version-min=10.10" - - CC=/usr/x86_64-apple-darwin14/bin/cc - goos: - - darwin - goarch: - - amd64 - ldflags: - - -s -w - - -X github.com/arduino/arduino-cli/version.versionString={{.Tag}} - - -X github.com/arduino/arduino-cli/version.commit={{ .ShortCommit }} - - -X github.com/arduino/arduino-cli/version.date={{.Date}} - - # ARM - id: arduino_cli_arm - binary: arduino-cli - env: - - CGO_ENABLED=1 - - CC=/usr/arm-linux-gnueabi/bin/cc - goos: - - linux - goarch: - - arm - goarm: - - 6 - ldflags: - - -s -w - - -X github.com/arduino/arduino-cli/version.versionString={{.Tag}} - - -X github.com/arduino/arduino-cli/version.commit={{ .ShortCommit }} - - -X github.com/arduino/arduino-cli/version.date={{.Date}} - - "-extldflags '-static'" - - # ARMv7 - id: arduino_cli_armv7 - binary: arduino-cli - env: - - CGO_ENABLED=1 - - CC=/usr/arm-linux-gnueabihf/bin/cc - goos: - - linux - goarch: - - arm - goarm: - - 7 - ldflags: - - -s -w - - -X github.com/arduino/arduino-cli/version.versionString={{.Tag}} - - -X github.com/arduino/arduino-cli/version.commit={{ .ShortCommit }} - - -X github.com/arduino/arduino-cli/version.date={{.Date}} - - "-extldflags '-static'" - - # ARM64 - id: arduino_cli_arm64 - binary: arduino-cli - env: - - CGO_ENABLED=1 - - CC=/usr/aarch64-linux-gnu/bin/cc - goos: - - linux - goarch: - - arm64 - ldflags: - - -s -w - - -X github.com/arduino/arduino-cli/version.versionString={{.Tag}} - - -X github.com/arduino/arduino-cli/version.commit={{ .ShortCommit }} - - -X github.com/arduino/arduino-cli/version.date={{.Date}} - - "-extldflags '-static'" - - # All the other platforms - id: arduino_cli - binary: arduino-cli - env: - - CGO_ENABLED=0 - goos: - - linux - - windows - goarch: - - amd64 - - 386 - ldflags: - - -s -w - - -X github.com/arduino/arduino-cli/version.versionString={{.Tag}} - - -X github.com/arduino/arduino-cli/version.commit={{ .ShortCommit }} - - -X github.com/arduino/arduino-cli/version.date={{.Date}} - - "-extldflags '-static'" - -archives: - - id: "arduino_cli" - format: tar.gz - format_overrides: - - goos: windows - format: zip - replacements: - amd64: 64bit - darwin: macOS - 386: 32bit - arm: ARM - arm64: ARM64 - linux: Linux - windows: Windows - files: - - LICENSE.txt diff --git a/DistTasks.yml b/DistTasks.yml new file mode 100644 index 00000000000..feb392d5374 --- /dev/null +++ b/DistTasks.yml @@ -0,0 +1,211 @@ +version: "3" + +# This taskfile is ideally meant to be project agnostic and could be dropped in +# on other Go projects with minimal or no changes. +# +# To use it simply add the following lines to your main taskfile: +# includes: +# dist: ./DistTasks.yml +# +# The following variables must be declared in the including taskfile for the +# build process to work correctly: +# * DIST_DIR: the folder that will contain the final binaries and packages +# * PROJECT_NAME: the name of the project, used in package name +# * VERSION: the version of the project, used in package name and checksum file +# * LD_FLAGS: flags used at build time +# +# The project MUST contain a LICENSE.txt file in the root folder or packaging will fail. + +tasks: + all: + desc: Build for distribution for all platforms + cmds: + - task: Windows_32bit + - task: Windows_64bit + - task: Linux_32bit + - task: Linux_64bit + - task: Linux_ARMv6 + - task: Linux_ARMv7 + - task: Linux_ARM64 + - task: macOS_64bit + + Windows_32bit: + desc: Builds Windows 32 bit binaries + dir: "{{ .DIST_DIR }}" + cmds: + - | + docker run -v `pwd`/..:/home/build -w /home/build \ + -e CGO_ENABLED=1 \ + {{ .CONTAINER }}:{{ .CONTAINER_TAG }} \ + --build-cmd "{{ .BUILD_COMMAND }}" \ + -p "{{ .BUILD_PLATFORM }}" + + zip {{ .PACKAGE_NAME}} {{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }}.exe ../LICENSE.txt -j + sha256sum {{ .PACKAGE_NAME }} >> {{ .CHECKSUM_FILE }} + + vars: + PLATFORM_DIR: "{{ .PROJECT_NAME }}_windows_386" + BUILD_COMMAND: "go build -o {{ .DIST_DIR }}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }}.exe {{ .LDFLAGS }}" + BUILD_PLATFORM: "windows/386" + CONTAINER_TAG: "{{ .GO_VERSION }}-main" + PACKAGE_PLATFORM: "Windows_32bit" + PACKAGE_NAME: "{{ .PROJECT_NAME }}_{{ .VERSION }}_{{ .PACKAGE_PLATFORM }}.zip" + + Windows_64bit: + desc: Builds Windows 64 bit binaries + dir: "{{ .DIST_DIR }}" + cmds: + - | + docker run -v `pwd`/..:/home/build -w /home/build \ + -e CGO_ENABLED=1 \ + {{ .CONTAINER }}:{{ .CONTAINER_TAG }} \ + --build-cmd "{{ .BUILD_COMMAND }}" \ + -p "{{ .BUILD_PLATFORM }}" + + zip {{ .PACKAGE_NAME}} {{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }}.exe ../LICENSE.txt -j + sha256sum {{ .PACKAGE_NAME }} >> {{ .CHECKSUM_FILE }} + + vars: + PLATFORM_DIR: "{{ .PROJECT_NAME }}_windows_amd64" + BUILD_COMMAND: "go build -o {{ .DIST_DIR }}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }}.exe {{ .LDFLAGS }}" + BUILD_PLATFORM: "windows/amd64" + CONTAINER_TAG: "{{ .GO_VERSION }}-main" + PACKAGE_PLATFORM: "Windows_64bit" + PACKAGE_NAME: "{{ .PROJECT_NAME }}_{{ .VERSION }}_{{ .PACKAGE_PLATFORM }}.zip" + + Linux_32bit: + desc: Builds Linux 32 bit binaries + dir: "{{ .DIST_DIR }}" + cmds: + - | + docker run -v `pwd`/..:/home/build -w /home/build \ + -e CGO_ENABLED=1 \ + {{ .CONTAINER }}:{{ .CONTAINER_TAG }} \ + --build-cmd "{{ .BUILD_COMMAND }}" \ + -p "{{ .BUILD_PLATFORM }}" + + tar cz -C {{ .PLATFORM_DIR }} {{ .PROJECT_NAME }} -C ../.. LICENSE.txt -f {{ .PACKAGE_NAME }} + sha256sum {{ .PACKAGE_NAME }} >> {{ .CHECKSUM_FILE }} + + vars: + PLATFORM_DIR: "{{ .PROJECT_NAME }}_linux_amd32" + BUILD_COMMAND: "go build -o {{ .DIST_DIR }}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }} {{ .LDFLAGS }}" + BUILD_PLATFORM: "linux/386" + CONTAINER_TAG: "{{ .GO_VERSION }}-main" + PACKAGE_PLATFORM: "Linux_32bit" + PACKAGE_NAME: "{{ .PROJECT_NAME }}_{{ .VERSION }}_{{ .PACKAGE_PLATFORM }}.tar.gz" + + Linux_64bit: + desc: Builds Linux 64 bit binaries + dir: "{{ .DIST_DIR }}" + cmds: + - | + docker run -v `pwd`/..:/home/build -w /home/build \ + -e CGO_ENABLED=1 \ + {{ .CONTAINER }}:{{ .CONTAINER_TAG }} \ + --build-cmd "{{ .BUILD_COMMAND }}" \ + -p "{{ .BUILD_PLATFORM }}" + + tar cz -C {{ .PLATFORM_DIR }} {{ .PROJECT_NAME }} -C ../.. LICENSE.txt -f {{ .PACKAGE_NAME }} + sha256sum {{ .PACKAGE_NAME }} >> {{ .CHECKSUM_FILE }} + + vars: + PLATFORM_DIR: "{{ .PROJECT_NAME }}_linux_amd64" + BUILD_COMMAND: "go build -o {{ .DIST_DIR }}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }} {{ .LDFLAGS }}" + BUILD_PLATFORM: "linux/amd64" + CONTAINER_TAG: "{{ .GO_VERSION }}-main" + PACKAGE_PLATFORM: "Linux_64bit" + PACKAGE_NAME: "{{ .PROJECT_NAME }}_{{ .VERSION }}_{{ .PACKAGE_PLATFORM }}.tar.gz" + + Linux_ARMv7: + desc: Builds Linux ARMv7 binaries + dir: "{{ .DIST_DIR }}" + cmds: + - | + docker run -v `pwd`/..:/home/build -w /home/build \ + -e CGO_ENABLED=1 \ + {{ .CONTAINER }}:{{ .CONTAINER_TAG }} \ + --build-cmd "{{ .BUILD_COMMAND }}" \ + -p "{{ .BUILD_PLATFORM }}" + + tar cz -C {{ .PLATFORM_DIR }} {{ .PROJECT_NAME }} -C ../.. LICENSE.txt -f {{ .PACKAGE_NAME }} + sha256sum {{ .PACKAGE_NAME }} >> {{ .CHECKSUM_FILE }} + + vars: + PLATFORM_DIR: "{{ .PROJECT_NAME }}_linux_arm_7" + BUILD_COMMAND: "go build -o {{ .DIST_DIR }}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }} {{ .LDFLAGS }}" + BUILD_PLATFORM: "linux/armv7" + CONTAINER_TAG: "{{ .GO_VERSION }}-arm" + PACKAGE_PLATFORM: "Linux_ARMv7" + PACKAGE_NAME: "{{ .PROJECT_NAME }}_{{ .VERSION }}_{{ .PACKAGE_PLATFORM }}.tar.gz" + + Linux_ARMv6: + desc: Builds Linux ARMv6 binaries + dir: "{{ .DIST_DIR }}" + cmds: + - | + docker run -v `pwd`/..:/home/build -w /home/build \ + -e CGO_ENABLED=1 \ + {{ .CONTAINER }}:{{ .CONTAINER_TAG }} \ + --build-cmd "{{ .BUILD_COMMAND }}" \ + -p "{{ .BUILD_PLATFORM }}" + + tar cz -C {{ .PLATFORM_DIR }} {{ .PROJECT_NAME }} -C ../.. LICENSE.txt -f {{ .PACKAGE_NAME }} + sha256sum {{ .PACKAGE_NAME }} >> {{ .CHECKSUM_FILE }} + + vars: + PLATFORM_DIR: "{{ .PROJECT_NAME }}_linux_arm_6" + BUILD_COMMAND: "go build -o {{ .DIST_DIR }}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }} {{ .LDFLAGS }}" + BUILD_PLATFORM: "linux/armv6" + CONTAINER_TAG: "{{ .GO_VERSION }}-arm" + PACKAGE_PLATFORM: "Linux_ARMv6" + PACKAGE_NAME: "{{ .PROJECT_NAME }}_{{ .VERSION }}_{{ .PACKAGE_PLATFORM }}.tar.gz" + + Linux_ARM64: + desc: Builds Linux ARM64 binaries + dir: "{{ .DIST_DIR }}" + cmds: + - | + docker run -v `pwd`/..:/home/build -w /home/build \ + -e CGO_ENABLED=1 \ + {{ .CONTAINER }}:{{ .CONTAINER_TAG }} \ + --build-cmd "{{ .BUILD_COMMAND }}" \ + -p "{{ .BUILD_PLATFORM }}" + + tar cz -C {{ .PLATFORM_DIR }} {{ .PROJECT_NAME }} -C ../.. LICENSE.txt -f {{ .PACKAGE_NAME }} + sha256sum {{ .PACKAGE_NAME }} >> {{ .CHECKSUM_FILE }} + + vars: + PLATFORM_DIR: "{{ .PROJECT_NAME }}_linux_arm_6" + BUILD_COMMAND: "go build -o {{ .DIST_DIR }}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }} {{ .LDFLAGS }}" + BUILD_PLATFORM: "linux/arm64" + CONTAINER_TAG: "{{ .GO_VERSION }}-arm" + PACKAGE_PLATFORM: "Linux_ARM64" + PACKAGE_NAME: "{{ .PROJECT_NAME }}_{{ .VERSION }}_{{ .PACKAGE_PLATFORM }}.tar.gz" + + macOS_64bit: + desc: Builds Mac OS X 64 bit binaries + dir: "{{ .DIST_DIR }}" + cmds: + - | + docker run -v `pwd`/..:/home/build -w /home/build \ + -e CGO_ENABLED=1 \ + {{ .CONTAINER }}:{{ .CONTAINER_TAG }} \ + --build-cmd "{{ .BUILD_COMMAND }}" \ + -p "{{ .BUILD_PLATFORM }}" + + tar cz -C {{ .PLATFORM_DIR }} {{ .PROJECT_NAME }} -C ../.. LICENSE.txt -f {{ .PACKAGE_NAME }} + sha256sum {{ .PACKAGE_NAME }} >> {{ .CHECKSUM_FILE }} + + vars: + PLATFORM_DIR: "{{ .PROJECT_NAME }}_osx_darwin_amd64" + BUILD_COMMAND: "go build -o {{ .DIST_DIR }}/{{ .PLATFORM_DIR }}/{{ .PROJECT_NAME }} {{ .LDFLAGS }}" + BUILD_PLATFORM: "darwin/amd64" + CONTAINER_TAG: "{{ .GO_VERSION }}-darwin" + PACKAGE_PLATFORM: "macOS_64bit" + PACKAGE_NAME: "{{ .PROJECT_NAME }}_{{ .VERSION }}_{{ .PACKAGE_PLATFORM }}.tar.gz" + +vars: + CONTAINER: "docker.elastic.co/beats-dev/golang-crossbuild" + GO_VERSION: "1.14.7" + CHECKSUM_FILE: "{{ .VERSION }}-checksums.txt" diff --git a/Dockerfiles/builder/Dockerfile b/Dockerfiles/builder/Dockerfile deleted file mode 100644 index 64bde10b9d3..00000000000 --- a/Dockerfiles/builder/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM multiarch/crossbuild - -ENV PATH $PATH:/usr/local/go/bin - -# Install tooling -ENV GORELEASER_VER 0.113.0 -ENV GORELEASER_SHA 2379beebb6369b75ccead7f7a43269de700b51821feae3857701d106ed72bd63 -ENV GOVER 1.14 -RUN set -ex \ - && curl -o goreleaser.tar.gz -LO https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VER}/goreleaser_Linux_x86_64.tar.gz \ - && echo "$GORELEASER_SHA goreleaser.tar.gz" | sha256sum -c - || exit 1 \ - && tar -xzf goreleaser.tar.gz -C /usr/bin/ goreleaser \ - && rm goreleaser.tar.gz \ - && curl -LO https://dl.google.com/go/go${GOVER}.linux-amd64.tar.gz \ - && tar -C /usr/local -xzf go${GOVER}.linux-amd64.tar.gz \ - && rm go${GOVER}.linux-amd64.tar.gz diff --git a/Taskfile.yml b/Taskfile.yml index 6647e32dfba..d382994e1e2 100755 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,4 +1,7 @@ -version: "2" +version: "3" + +includes: + dist: ./DistTasks.yml tasks: docs:gen:commands: @@ -196,25 +199,39 @@ tasks: - git diff --exit-code ./i18n/data &> /dev/null || (cd ./i18n && rice embed-go) vars: + PROJECT_NAME: "arduino-cli" + DIST_DIR: "dist" # all modules of this project except for "legacy/..." module DEFAULT_TARGETS: sh: echo `go list ./... | grep -v legacy | tr '\n' ' '` # build vars COMMIT: - sh: echo ${TRAVIS_COMMIT:-`git log -n 1 --format=%h`} + sh: echo "$(git log -n 1 --format=%h)" TIMESTAMP: sh: echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" + TIMESTAMP_SHORT: + sh: echo "{{now | date "20060102"}}" + TAG: + sh: echo "`git tag --points-at=HEAD 2> /dev/null`" + VERSION: "{{ if .NIGHTLY }}nightly-{{ .TIMESTAMP_SHORT }}{{ else if .TAG }}{{ .TAG }}{{ else }}{{ .PACKAGE_NAME_PREFIX }}git-snapshot{{ end }}" LDFLAGS: > - -ldflags '-X github.com/arduino/arduino-cli/version.commit={{.COMMIT}} - -X github.com/arduino/arduino-cli/version.date={{.TIMESTAMP}}' + -ldflags + ' + -X github.com/arduino/arduino-cli/version.versionString={{.VERSION}} + -X github.com/arduino/arduino-cli/version.commit={{ .COMMIT }} + -X github.com/arduino/arduino-cli/version.date={{.TIMESTAMP}} + ' # test vars GOFLAGS: "-timeout 10m -v -coverpkg=./... -covermode=atomic" - TEST_VERSIONSTRING: "0.0.0-test.preview" + TEST_VERSION: "0.0.0-test.preview" TEST_COMMIT: "deadbeef" TEST_LDFLAGS: > - -ldflags '-X github.com/arduino/arduino-cli/version.versionString={{.TEST_VERSIONSTRING}} + -ldflags + ' + -X github.com/arduino/arduino-cli/version.versionString={{.TEST_VERSION}} -X github.com/arduino/arduino-cli/version.commit={{.TEST_COMMIT}} - -X github.com/arduino/arduino-cli/version.date={{.TIMESTAMP}}' + -X github.com/arduino/arduino-cli/version.date={{.TIMESTAMP}} + ' # check-lint vars GOLINTBIN: sh: go list -f {{"{{"}}".Target{{"}}"}}" golang.org/x/lint/golint diff --git a/docs/installation.md b/docs/installation.md index 831b66e6a60..8d296aa58c5 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -106,13 +106,14 @@ If you’re familiar with Golang or if you want to contribute to the project, yo locally with your Go toolchain. Please refer to the [CONTRIBUTING] document for setup instructions. If you don’t have a working Golang environment or if you want to build `arduino-cli` targeting different platforms, you -can use Docker to get a binary directly from sources. From the project folder run: +can use [Task][task-site] to get a binary directly from sources. From the project folder run: ```sh -docker run -v $PWD:/arduino-cli -w /arduino-cli -e PACKAGE_NAME_PREFIX='snapshot' arduino/arduino-cli:builder-1 goreleaser --rm-dist --snapshot --skip-publish +task dist:all ``` Once the build is over, you will find a `./dist/` folder containing the packages built out of the current source tree. [git for windows]: https://gitforwindows.org/ [contributing]: CONTRIBUTING.md +[task-site]: https://taskfile.dev/#/installation diff --git a/gon.config.hcl b/gon.config.hcl index a804b259c67..a73110a3d13 100644 --- a/gon.config.hcl +++ b/gon.config.hcl @@ -1,4 +1,4 @@ -source = ["dist/arduino_cli_osx_darwin_amd64/arduino-cli"] +source = ["dist/arduino-cli_osx_darwin_amd64/arduino-cli"] bundle_id = "cc.arduino.arduino-cli" sign { diff --git a/poetry.lock b/poetry.lock index 386ffc5b58c..8625f7ac420 100644 --- a/poetry.lock +++ b/poetry.lock @@ -381,11 +381,11 @@ socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"] [[package]] name = "semver" -version = "2.9.0" +version = "2.13.0" description = "Python helper for Semantic Versioning (http://semver.org/)" category = "main" optional = false -python-versions = "*" +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [[package]] name = "simplejson" @@ -455,7 +455,7 @@ watchdog = ["watchdog"] [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "366ed44051d9d750af552310f355cb4fd48eee3169bd011ef5c5fb61852e82d0" +content-hash = "a987a9f86a55ef8203013e0da6ce71788ff7cf6e96ea44b76c8f1e1b00a17dc2" [metadata.files] apipkg = [ @@ -631,8 +631,8 @@ requests = [ {file = "requests-2.22.0.tar.gz", hash = "sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4"}, ] semver = [ - {file = "semver-2.9.0-py2.py3-none-any.whl", hash = "sha256:aa1c6be3bf23e346e00c509a7ee87735a7e0fd6b404cf066037cfeab2c770320"}, - {file = "semver-2.9.0.tar.gz", hash = "sha256:ed1edeaa0c27f68feb74f09f715077fd07b728446dc2bb7fc470fc0f737873a0"}, + {file = "semver-2.13.0-py2.py3-none-any.whl", hash = "sha256:ced8b23dceb22134307c1b8abfa523da14198793d9787ac838e70e29e77458d4"}, + {file = "semver-2.13.0.tar.gz", hash = "sha256:fa0fe2722ee1c3f57eac478820c3a5ae2f624af8264cbdf9000c980ff7f75e3f"}, ] simplejson = [ {file = "simplejson-3.17.0-cp27-cp27m-macosx_10_13_x86_64.whl", hash = "sha256:87d349517b572964350cc1adc5a31b493bbcee284505e81637d0174b2758ba17"}, diff --git a/pyproject.toml b/pyproject.toml index d9af915d71f..f92a14aa5c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ authors = [] python = "^3.8" pytest = "6.0.2" simplejson = "3.17.0" -semver = "2.9.0" +semver = "2.13.0" pyserial = "3.4" pyyaml = "5.3" prometheus-client = "0.7.1" diff --git a/test/test_main.py b/test/test_main.py index 80f8e39072a..47c694362c2 100644 --- a/test/test_main.py +++ b/test/test_main.py @@ -37,7 +37,8 @@ def test_version(run_command): assert result.ok parsed_out = json.loads(result.stdout) assert parsed_out.get("Application", False) == "arduino-cli" - assert isinstance(semver.parse(parsed_out.get("VersionString", False)), dict) + version = parsed_out.get("VersionString", False) + assert semver.VersionInfo.isvalid(version=version) or "git-snapshot" in version or "nightly" in version assert isinstance(parsed_out.get("Commit", False), str)