From de6cf131f3989152d7613de6b342e06942f2224d Mon Sep 17 00:00:00 2001 From: Mike Zorn Date: Fri, 9 Aug 2024 16:32:03 -0700 Subject: [PATCH 01/22] WIP build sandbox --- .github/actions/mike-test-build/action.yml | 47 +++++++++++++++++++ .github/workflows/mike-test-release.yml | 53 ++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 .github/actions/mike-test-build/action.yml create mode 100644 .github/workflows/mike-test-release.yml diff --git a/.github/actions/mike-test-build/action.yml b/.github/actions/mike-test-build/action.yml new file mode 100644 index 00000000..aee5d81f --- /dev/null +++ b/.github/actions/mike-test-build/action.yml @@ -0,0 +1,47 @@ +name: Publish Artifacts +description: 'Publish artifacts to Github Release' +inputs: + token: + description: 'Token to use for publishing.' + required: true + homebrew-gh-secret: + description: 'SSH private key used as a GitHub deploy key for publishing to homebrew-tap.' + required: true + dry-run: + description: 'Is this a dry run. If so no package will be published.' + required: false + default: 'true' + tag: + description: 'Tag to upload artifacts to.' + required: true +outputs: + hashes: + description: sha256sum hashes of built artifacts + value: ${{ steps.hash.outputs.hashes }} + +runs: + using: composite + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + platforms: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/386 + - name: Login to Docker + shell: bash + run: | + echo $DOCKER_TOKEN | docker login --username $DOCKER_USERNAME --password-stdin + - name: Run Goreleaser + uses: goreleaser/goreleaser-action@v5 + with: + version: latest + args: build --snapshot --config .goreleaser.yaml + env: + GITHUB_TOKEN: ${{ inputs.token }} + HOMEBREW_DEPLOY_KEY: ${{ inputs.homebrew-gh-secret }} + - name: Hash build artifacts for provenance + id: hash + shell: bash + run: | + echo "hashes=$(sha256sum dist/*.tar.gz | base64 -w0)" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/mike-test-release.yml b/.github/workflows/mike-test-release.yml new file mode 100644 index 00000000..1ff2aa2a --- /dev/null +++ b/.github/workflows/mike-test-release.yml @@ -0,0 +1,53 @@ +name: Mike test build + +on: + push: + +jobs: + go-versions: + uses: ./.github/workflows/go-versions.yml + + release-please: + runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + steps: + - uses: google-github-actions/release-please-action@v4 + id: release + with: + token: ${{secrets.GITHUB_TOKEN}} + + release-ldcli: + permissions: + id-token: write # Needed to obtain Docker tokens + contents: write # Needed to upload release artifacts + needs: [ release-please, go-versions ] + if: ${{ needs.release-please.outputs.release_created == 'true' }} + runs-on: ubuntu-latest + outputs: + hashes: ${{ steps.publish.outputs.hashes }} + steps: + - uses: actions/checkout@v4 + name: Checkout + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ needs.go-versions.outputs.latest }} + + - uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.1 + name: 'Get Docker token' + with: + aws_assume_role: ${{ vars.AWS_ROLE_ARN }} + ssm_parameter_pairs: '/global/services/docker/public/username = DOCKER_USERNAME, /global/services/docker/public/token = DOCKER_TOKEN' + + - uses: ./.github/actions/mike-test-build + id: publish + with: + dry-run: 'true' + token: ${{ secrets.GITHUB_TOKEN }} + homebrew-gh-secret: ${{secrets.HOMEBREW_DEPLOY_KEY}} + tag: ${{ needs.release-please.outputs.tag_name }} \ No newline at end of file From e6a2ab133f4029726a1cfe39f69108f5edca7f30 Mon Sep 17 00:00:00 2001 From: Mike Zorn Date: Fri, 9 Aug 2024 16:38:50 -0700 Subject: [PATCH 02/22] remove conditional --- .github/workflows/mike-test-release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/mike-test-release.yml b/.github/workflows/mike-test-release.yml index 1ff2aa2a..8927a5e6 100644 --- a/.github/workflows/mike-test-release.yml +++ b/.github/workflows/mike-test-release.yml @@ -23,7 +23,6 @@ jobs: id-token: write # Needed to obtain Docker tokens contents: write # Needed to upload release artifacts needs: [ release-please, go-versions ] - if: ${{ needs.release-please.outputs.release_created == 'true' }} runs-on: ubuntu-latest outputs: hashes: ${{ steps.publish.outputs.hashes }} From 1dc4ff071ae987c397a6375785adf8d8725ccf41 Mon Sep 17 00:00:00 2001 From: Mike Zorn Date: Fri, 9 Aug 2024 16:44:36 -0700 Subject: [PATCH 03/22] enable cgo --- .goreleaser.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 2bc2299c..8cc6f9de 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -14,6 +14,8 @@ builds: - -w - -linkmode external - -extldflags -static + env: + - CGO_ENABLED=1 dockers: # AMD64 - image_templates: From 10993de584d86e9123ab3825445780f55b5dc8cb Mon Sep 17 00:00:00 2001 From: Mike Zorn Date: Fri, 9 Aug 2024 16:52:52 -0700 Subject: [PATCH 04/22] install i386 dependencies --- .goreleaser.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 8cc6f9de..04d46430 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -16,6 +16,9 @@ builds: - -extldflags -static env: - CGO_ENABLED=1 + hooks: + pre: + apt-get install libc6-dev-i386 dockers: # AMD64 - image_templates: From 4f8458d2af05291ff1855befd5b2a9805c51bbe8 Mon Sep 17 00:00:00 2001 From: Mike Zorn Date: Fri, 9 Aug 2024 16:54:09 -0700 Subject: [PATCH 05/22] sudo !! --- .goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 04d46430..f057906c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -18,7 +18,7 @@ builds: - CGO_ENABLED=1 hooks: pre: - apt-get install libc6-dev-i386 + sudo apt-get install libc6-dev-i386 dockers: # AMD64 - image_templates: From ec7cdb7a24f9eb895551a5f9b3d2733e185697f9 Mon Sep 17 00:00:00 2001 From: Mike Zorn Date: Fri, 9 Aug 2024 17:10:45 -0700 Subject: [PATCH 06/22] move to global hook --- .goreleaser.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index f057906c..97327a3f 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,3 +1,6 @@ +before: + hooks: + - sudo apt-get install libc6-dev-i386 builds: - id: ldcli binary: ldcli @@ -16,9 +19,6 @@ builds: - -extldflags -static env: - CGO_ENABLED=1 - hooks: - pre: - sudo apt-get install libc6-dev-i386 dockers: # AMD64 - image_templates: From db447eaaacdba35e13f4827d9b2c06707e238244 Mon Sep 17 00:00:00 2001 From: Mike Zorn Date: Fri, 9 Aug 2024 17:17:55 -0700 Subject: [PATCH 07/22] use musl --- .goreleaser.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 97327a3f..8876636b 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,6 +1,6 @@ before: hooks: - - sudo apt-get install libc6-dev-i386 + - sudo apt-get install libc6-dev-i386 musl-tools builds: - id: ldcli binary: ldcli @@ -19,6 +19,7 @@ builds: - -extldflags -static env: - CGO_ENABLED=1 + - CC=musl-gcc dockers: # AMD64 - image_templates: From f553827b46ae34fba65859583829f1d98d95e883 Mon Sep 17 00:00:00 2001 From: Mike Zorn Date: Fri, 9 Aug 2024 17:24:30 -0700 Subject: [PATCH 08/22] split build --- .goreleaser.yaml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 8876636b..809cba1f 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -5,7 +5,6 @@ builds: - id: ldcli binary: ldcli goos: - - darwin - linux - windows goarch: @@ -20,6 +19,20 @@ builds: env: - CGO_ENABLED=1 - CC=musl-gcc + - id: ldcli-macos + binary: ldcli + goos: + - darwin + goarch: + - amd64 + - arm64 + ldflags: + - -s + - -w + - -linkmode external + - -extldflags -static + env: + - CGO_ENABLED=1 dockers: # AMD64 - image_templates: From 92f57376a6c86c7213b2af25bd5dc6d08b5ba0e3 Mon Sep 17 00:00:00 2001 From: Mike Zorn Date: Fri, 9 Aug 2024 17:38:22 -0700 Subject: [PATCH 09/22] fix arm & use templated env --- .goreleaser.yaml | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 809cba1f..2974a1d7 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,11 +1,12 @@ before: hooks: - - sudo apt-get install libc6-dev-i386 musl-tools + - sudo apt-get install libc6-dev-i386 musl-tools musl-dev musl-dev-arm64 builds: - id: ldcli binary: ldcli goos: - linux + - darwin - windows goarch: - 386 @@ -18,21 +19,13 @@ builds: - -extldflags -static env: - CGO_ENABLED=1 - - CC=musl-gcc - - id: ldcli-macos - binary: ldcli - goos: - - darwin - goarch: - - amd64 - - arm64 - ldflags: - - -s - - -w - - -linkmode external - - -extldflags -static - env: - - CGO_ENABLED=1 + - >- + {{- if eq .Os "darwin" }}CC={{- end }} + {{- if eq .Os "windows" }}CC={{- end }} + {{- if eq .Os "linux" }} + {{- if eq .Arch "amd64"}}CC=musl-gcc{{- end }} + {{- if eq .Arch "arm64"}}CC=aarch64-linux-musl-gcc{{- end }} + {{- end }} dockers: # AMD64 - image_templates: From 476dcbe86d9c658cefe8a7d347a9de722ad09a36 Mon Sep 17 00:00:00 2001 From: Mike Zorn Date: Fri, 9 Aug 2024 17:44:04 -0700 Subject: [PATCH 10/22] eliminate nonexistent package --- .goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 2974a1d7..b8e158ae 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,6 +1,6 @@ before: hooks: - - sudo apt-get install libc6-dev-i386 musl-tools musl-dev musl-dev-arm64 + - sudo apt-get install libc6-dev-i386 musl-tools musl-dev builds: - id: ldcli binary: ldcli From 07a91f3f1eee82327b4422093c70708e3b659992 Mon Sep 17 00:00:00 2001 From: Mike Zorn Date: Fri, 9 Aug 2024 17:50:49 -0700 Subject: [PATCH 11/22] use musl for 386 & explicitly set cc for darwin --- .goreleaser.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index b8e158ae..0cd1ed0f 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -20,9 +20,10 @@ builds: env: - CGO_ENABLED=1 - >- - {{- if eq .Os "darwin" }}CC={{- end }} + {{- if eq .Os "darwin" }}CC=o64-clang{{- end }} {{- if eq .Os "windows" }}CC={{- end }} {{- if eq .Os "linux" }} + {{- if eq .Arch "386"}}CC=musl-gcc{{- end }} {{- if eq .Arch "amd64"}}CC=musl-gcc{{- end }} {{- if eq .Arch "arm64"}}CC=aarch64-linux-musl-gcc{{- end }} {{- end }} From cd1fc18f6aec54eed83fb5ea11132050469e778f Mon Sep 17 00:00:00 2001 From: Mike Zorn Date: Fri, 9 Aug 2024 18:00:47 -0700 Subject: [PATCH 12/22] add more deps --- .goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0cd1ed0f..00151026 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,6 +1,6 @@ before: hooks: - - sudo apt-get install libc6-dev-i386 musl-tools musl-dev + - sudo apt-get install libc6-dev-i386 musl-tools musl-dev llvm clang lld mingw-w64 builds: - id: ldcli binary: ldcli From 1498a2d405640269df9e3fb8b8988e7551a22662 Mon Sep 17 00:00:00 2001 From: Mike Zorn Date: Fri, 9 Aug 2024 18:05:58 -0700 Subject: [PATCH 13/22] try different deps and cc name --- .goreleaser.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 00151026..164f3aef 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,6 +1,6 @@ before: hooks: - - sudo apt-get install libc6-dev-i386 musl-tools musl-dev llvm clang lld mingw-w64 + - sudo apt-get install build-essentials libc6-dev-i386 musl-tools musl-dev llvm clang lld mingw-w64 builds: - id: ldcli binary: ldcli @@ -20,7 +20,7 @@ builds: env: - CGO_ENABLED=1 - >- - {{- if eq .Os "darwin" }}CC=o64-clang{{- end }} + {{- if eq .Os "darwin" }}CC=o64h-clang{{- end }} {{- if eq .Os "windows" }}CC={{- end }} {{- if eq .Os "linux" }} {{- if eq .Arch "386"}}CC=musl-gcc{{- end }} From 71ceee9d6476a48c2cae3bb61879dadb5871aa40 Mon Sep 17 00:00:00 2001 From: Mike Zorn Date: Fri, 9 Aug 2024 18:08:52 -0700 Subject: [PATCH 14/22] remove extraneous pacckages --- .goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 164f3aef..b88bf71c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,6 +1,6 @@ before: hooks: - - sudo apt-get install build-essentials libc6-dev-i386 musl-tools musl-dev llvm clang lld mingw-w64 + - sudo apt-get install libc6-dev-i386 musl-tools musl-dev builds: - id: ldcli binary: ldcli From 6afc7e628d92bc17d57ca5616c915a7b6b32ae14 Mon Sep 17 00:00:00 2001 From: Mike Zorn Date: Fri, 9 Aug 2024 18:28:17 -0700 Subject: [PATCH 15/22] skip non-linux for now --- .goreleaser.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index b88bf71c..d4ab872f 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -6,8 +6,8 @@ builds: binary: ldcli goos: - linux - - darwin - - windows + # WIP - darwin + # WIP - windows goarch: - 386 - amd64 @@ -20,7 +20,7 @@ builds: env: - CGO_ENABLED=1 - >- - {{- if eq .Os "darwin" }}CC=o64h-clang{{- end }} + {{- if eq .Os "darwin" }}CC={{- end }} {{- if eq .Os "windows" }}CC={{- end }} {{- if eq .Os "linux" }} {{- if eq .Arch "386"}}CC=musl-gcc{{- end }} From cf5da8c7c9f10818e4ba428166ac2a3e1124b3ba Mon Sep 17 00:00:00 2001 From: Hosh Sadiq Date: Mon, 12 Aug 2024 21:41:17 +0100 Subject: [PATCH 16/22] attempt xbuild --- .github/actions/mike-test-build/action.yml | 9 +++ .goreleaser.grcross.yaml | 60 ++++++++++++++++++ .goreleaser.zig.yaml | 73 ++++++++++++++++++++++ scripts/gr-cross-runner.sh | 14 +++++ scripts/zig-runner.sh | 25 ++++++++ 5 files changed, 181 insertions(+) create mode 100644 .goreleaser.grcross.yaml create mode 100644 .goreleaser.zig.yaml create mode 100755 scripts/gr-cross-runner.sh create mode 100755 scripts/zig-runner.sh diff --git a/.github/actions/mike-test-build/action.yml b/.github/actions/mike-test-build/action.yml index aee5d81f..76aa46f5 100644 --- a/.github/actions/mike-test-build/action.yml +++ b/.github/actions/mike-test-build/action.yml @@ -14,6 +14,7 @@ inputs: tag: description: 'Tag to upload artifacts to.' required: true + outputs: hashes: description: sha256sum hashes of built artifacts @@ -32,6 +33,14 @@ runs: shell: bash run: | echo $DOCKER_TOKEN | docker login --username $DOCKER_USERNAME --password-stdin + + - uses: goto-bus-stop/setup-zig@v1.0.0 + with: + version: 0.14.0 + + - run: sudo apt-get install gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf + shell: bash + - name: Run Goreleaser uses: goreleaser/goreleaser-action@v5 with: diff --git a/.goreleaser.grcross.yaml b/.goreleaser.grcross.yaml new file mode 100644 index 00000000..90ec5488 --- /dev/null +++ b/.goreleaser.grcross.yaml @@ -0,0 +1,60 @@ +env: + - CGO_ENABLED=1 +builds: + - &default_config + id: ldcli-linux_amd64 + binary: ldcli + goos: + - linux + goarch: + - amd64 + ldflags: + - -s + - -w + env: + - CC=x86_64-linux-gnu-gcc + - CXX=x86_64-linux-gnu-g++ + - <<: *default_config + id: ldcli-linux_arm64 + goarch: + - arm64 + env: + - CC=aarch64-linux-gnu-gcc + - CXX=aarch64-linux-gnu-gcc + - <<: *default_config + id: ldcli-linux_armhf + goarm: + - "7" + goarch: + - arm + env: + - CC=arm-linux-gnueabihf-gcc + - CXX=arm-linux-gnueabihf-g++ + - <<: *default_config + id: ldcli-darwin_amd64 + goarch: + - amd64 + env: + - CC=o64-clang + - CXX=o64-clang++ + - <<: *default_config + id: ldcli-darwin_arm64 + goarch: + - arm64 + env: + - CC=oa64-clang + - CXX=oa64-clang++ + - <<: *default_config + id: ldcli-windows_amd64 + goarch: + - amd64 + env: + - CC=x86_64-w64-mingw32-gcc + - CXX=x86_64-w64-mingw32-g++ + - <<: *default_config + id: ldcli-windows_arm64 + goarch: + - arm64 + env: + - CC=/llvm-mingw/bin/aarch64-w64-mingw32-gcc + - CXX=/llvm-mingw/bin/aarch64-w64-mingw32-g++ diff --git a/.goreleaser.zig.yaml b/.goreleaser.zig.yaml new file mode 100644 index 00000000..c5d6065f --- /dev/null +++ b/.goreleaser.zig.yaml @@ -0,0 +1,73 @@ +env: + - CGO_ENABLED=1 +builds: + - &default_config + id: ldcli-linux_amd64 + binary: ldcli + goos: + - linux + goarch: + - amd64 + ldflags: + - -s + - -w + - -extldflags=-static + flags: + - -trimpath + tags: + - osusergo + - netgo + - sqlite_omit_load_extension + env: + - CC=zig cc -target x86_64-linux-musl + - CXX=zig c++ -target x86_64-linux-musl + - <<: *default_config + id: ldcli-linux_arm64 + goarch: + - arm64 + env: + - CC=zig cc -target aarch64-linux-musl + - CXX=zig c++ -target aarch64-linux-musl + - <<: *default_config + id: ldcli-linux_armhf + goarm: + - "7" + goarch: + - arm + env: + - CC=zig cc -target arm-linux-musl + - CXX=zig c++ -target arm-linux-musl + - <<: *default_config + id: ldcli-darwin_amd64 + goarch: + - amd64 + flags: + - -trimpath + - -buildmode=pie + env: + - CC=zig cc -target x86_64-macos-none + - CXX=zig c++ -target x86_64-macos-none + - <<: *default_config + id: ldcli-darwin_arm64 + goarch: + - arm64 + flags: + - -trimpath + - -buildmode=pie + env: + - CC=zig cc -target aarch64-macos-none + - CXX=zig c++ -target aarch64-macos-none + - <<: *default_config + id: ldcli-windows_amd64 + goarch: + - amd64 + env: + - CC=zig cc -target x86_64-windows-gnu + - CXX=zig c++ -target x86_64-windows-gnu + - <<: *default_config + id: ldcli-windows_arm64 + goarch: + - arm64 + env: + - CC=zig cc -target aarch64-windows-gnu + - CXX=zig c++ -target aarch64-windows-gnu diff --git a/scripts/gr-cross-runner.sh b/scripts/gr-cross-runner.sh new file mode 100755 index 00000000..439709e0 --- /dev/null +++ b/scripts/gr-cross-runner.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -eu + +# based on https://github.com/goreleaser/goreleaser-cross +docker image inspect grcross-xbuilder &>/dev/null || docker build -t grcross-xbuilder -f - . </dev/null || docker build -t zig-xbuilder -f - . < Date: Tue, 13 Aug 2024 12:25:59 +0100 Subject: [PATCH 17/22] Cross build --- .goreleaser.grcross.yaml | 60 ------------------------------- .goreleaser.yaml | 68 ++++++++++++++++++++--------------- .goreleaser.zig.yaml | 73 -------------------------------------- scripts/gr-cross-runner.sh | 12 +------ scripts/zig-runner.sh | 25 ------------- 5 files changed, 41 insertions(+), 197 deletions(-) delete mode 100644 .goreleaser.grcross.yaml delete mode 100644 .goreleaser.zig.yaml delete mode 100755 scripts/zig-runner.sh diff --git a/.goreleaser.grcross.yaml b/.goreleaser.grcross.yaml deleted file mode 100644 index 90ec5488..00000000 --- a/.goreleaser.grcross.yaml +++ /dev/null @@ -1,60 +0,0 @@ -env: - - CGO_ENABLED=1 -builds: - - &default_config - id: ldcli-linux_amd64 - binary: ldcli - goos: - - linux - goarch: - - amd64 - ldflags: - - -s - - -w - env: - - CC=x86_64-linux-gnu-gcc - - CXX=x86_64-linux-gnu-g++ - - <<: *default_config - id: ldcli-linux_arm64 - goarch: - - arm64 - env: - - CC=aarch64-linux-gnu-gcc - - CXX=aarch64-linux-gnu-gcc - - <<: *default_config - id: ldcli-linux_armhf - goarm: - - "7" - goarch: - - arm - env: - - CC=arm-linux-gnueabihf-gcc - - CXX=arm-linux-gnueabihf-g++ - - <<: *default_config - id: ldcli-darwin_amd64 - goarch: - - amd64 - env: - - CC=o64-clang - - CXX=o64-clang++ - - <<: *default_config - id: ldcli-darwin_arm64 - goarch: - - arm64 - env: - - CC=oa64-clang - - CXX=oa64-clang++ - - <<: *default_config - id: ldcli-windows_amd64 - goarch: - - amd64 - env: - - CC=x86_64-w64-mingw32-gcc - - CXX=x86_64-w64-mingw32-g++ - - <<: *default_config - id: ldcli-windows_arm64 - goarch: - - arm64 - env: - - CC=/llvm-mingw/bin/aarch64-w64-mingw32-gcc - - CXX=/llvm-mingw/bin/aarch64-w64-mingw32-g++ diff --git a/.goreleaser.yaml b/.goreleaser.yaml index d4ab872f..a7b7135d 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,64 +1,76 @@ -before: - hooks: - - sudo apt-get install libc6-dev-i386 musl-tools musl-dev +version: 2 + builds: - id: ldcli binary: ldcli goos: + - darwin - linux - # WIP - darwin - # WIP - windows + - windows goarch: - - 386 + - "386" - amd64 - arm64 ldflags: - -s - -w - - -linkmode external - - -extldflags -static + + ignore: + - goos: linux + goarch: "386" + - goos: darwin + goarch: "386" + env: - - CGO_ENABLED=1 - >- - {{- if eq .Os "darwin" }}CC={{- end }} - {{- if eq .Os "windows" }}CC={{- end }} - {{- if eq .Os "linux" }} - {{- if eq .Arch "386"}}CC=musl-gcc{{- end }} - {{- if eq .Arch "amd64"}}CC=musl-gcc{{- end }} - {{- if eq .Arch "arm64"}}CC=aarch64-linux-musl-gcc{{- end }} - {{- end }} + TOOLCHAIN_BASE= + {{- if eq .Os "darwin" -}} + o + {{- if eq .Arch "arm64" -}}a{{- end -}} + 64-clang + {{- else -}} + {{- if eq .Os "windows" -}}/llvm-mingw/bin/{{- end -}} + {{- if eq .Arch "386" -}}i686{{- end -}} + {{- if eq .Arch "arm64" -}}aarch64{{- end -}} + {{- if eq .Arch "amd64" -}}x86_64{{- end -}} + - + {{- if eq .Os "windows" -}}w64-mingw32{{- end -}} + {{- if eq .Os "linux" -}}linux-gnu{{- end -}} + {{- end -}} + - CC={{ .Env.TOOLCHAIN_BASE }}{{ if ne .Os "darwin" }}-gcc{{ end }} + - CXX={{ .Env.TOOLCHAIN_BASE }}{{ if eq .Os "darwin" }}++{{ else }}-g++{{ end }} dockers: # AMD64 - image_templates: - - "launchdarkly/ldcli:{{ .Version }}-amd64" - - "launchdarkly/ldcli:v{{ .Major }}-amd64" - - "launchdarkly/ldcli:latest-amd64" + - "launchdarkly/ldcli:{{ .Version }}-amd64" + - "launchdarkly/ldcli:v{{ .Major }}-amd64" + - "launchdarkly/ldcli:latest-amd64" goos: linux goarch: amd64 dockerfile: Dockerfile.goreleaser skip_push: false build_flag_templates: - - "--pull" - - "--platform=linux/amd64" + - "--pull" + - "--platform=linux/amd64" # ARM64v8 - image_templates: - - "launchdarkly/ldcli:{{ .Version }}-arm64v8" - - "launchdarkly/ldcli:v{{ .Major }}-arm64v8" - - "launchdarkly/ldcli:latest-arm64v8" + - "launchdarkly/ldcli:{{ .Version }}-arm64v8" + - "launchdarkly/ldcli:v{{ .Major }}-arm64v8" + - "launchdarkly/ldcli:latest-arm64v8" goos: linux goarch: arm64 dockerfile: Dockerfile.goreleaser skip_push: false build_flag_templates: - - "--pull" - - "--platform=linux/arm64/v8" + - "--pull" + - "--platform=linux/arm64/v8" docker_manifests: - name_template: "launchdarkly/ldcli:{{ .Version}}" skip_push: false image_templates: - - "launchdarkly/ldcli:{{ .Version }}-amd64" - - "launchdarkly/ldcli:{{ .Version }}-arm64v8" + - "launchdarkly/ldcli:{{ .Version }}-amd64" + - "launchdarkly/ldcli:{{ .Version }}-arm64v8" - name_template: "launchdarkly/ldcli:v{{ .Major }}" skip_push: false diff --git a/.goreleaser.zig.yaml b/.goreleaser.zig.yaml deleted file mode 100644 index c5d6065f..00000000 --- a/.goreleaser.zig.yaml +++ /dev/null @@ -1,73 +0,0 @@ -env: - - CGO_ENABLED=1 -builds: - - &default_config - id: ldcli-linux_amd64 - binary: ldcli - goos: - - linux - goarch: - - amd64 - ldflags: - - -s - - -w - - -extldflags=-static - flags: - - -trimpath - tags: - - osusergo - - netgo - - sqlite_omit_load_extension - env: - - CC=zig cc -target x86_64-linux-musl - - CXX=zig c++ -target x86_64-linux-musl - - <<: *default_config - id: ldcli-linux_arm64 - goarch: - - arm64 - env: - - CC=zig cc -target aarch64-linux-musl - - CXX=zig c++ -target aarch64-linux-musl - - <<: *default_config - id: ldcli-linux_armhf - goarm: - - "7" - goarch: - - arm - env: - - CC=zig cc -target arm-linux-musl - - CXX=zig c++ -target arm-linux-musl - - <<: *default_config - id: ldcli-darwin_amd64 - goarch: - - amd64 - flags: - - -trimpath - - -buildmode=pie - env: - - CC=zig cc -target x86_64-macos-none - - CXX=zig c++ -target x86_64-macos-none - - <<: *default_config - id: ldcli-darwin_arm64 - goarch: - - arm64 - flags: - - -trimpath - - -buildmode=pie - env: - - CC=zig cc -target aarch64-macos-none - - CXX=zig c++ -target aarch64-macos-none - - <<: *default_config - id: ldcli-windows_amd64 - goarch: - - amd64 - env: - - CC=zig cc -target x86_64-windows-gnu - - CXX=zig c++ -target x86_64-windows-gnu - - <<: *default_config - id: ldcli-windows_arm64 - goarch: - - arm64 - env: - - CC=zig cc -target aarch64-windows-gnu - - CXX=zig c++ -target aarch64-windows-gnu diff --git a/scripts/gr-cross-runner.sh b/scripts/gr-cross-runner.sh index 439709e0..271798df 100755 --- a/scripts/gr-cross-runner.sh +++ b/scripts/gr-cross-runner.sh @@ -1,14 +1,4 @@ #!/usr/bin/env bash set -eu - -# based on https://github.com/goreleaser/goreleaser-cross -docker image inspect grcross-xbuilder &>/dev/null || docker build -t grcross-xbuilder -f - . </dev/null || docker build -t zig-xbuilder -f - . < Date: Tue, 13 Aug 2024 12:32:45 +0100 Subject: [PATCH 18/22] invoke docker command --- .github/actions/mike-test-build/action.yml | 23 +++++++++++----------- scripts/gr-cross-runner.sh | 4 ---- 2 files changed, 11 insertions(+), 16 deletions(-) delete mode 100755 scripts/gr-cross-runner.sh diff --git a/.github/actions/mike-test-build/action.yml b/.github/actions/mike-test-build/action.yml index 76aa46f5..6da12cf9 100644 --- a/.github/actions/mike-test-build/action.yml +++ b/.github/actions/mike-test-build/action.yml @@ -34,18 +34,17 @@ runs: run: | echo $DOCKER_TOKEN | docker login --username $DOCKER_USERNAME --password-stdin - - uses: goto-bus-stop/setup-zig@v1.0.0 - with: - version: 0.14.0 - - - run: sudo apt-get install gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf - shell: bash - - - name: Run Goreleaser - uses: goreleaser/goreleaser-action@v5 - with: - version: latest - args: build --snapshot --config .goreleaser.yaml + - shell: bash + run: | + docker run \ + --tty \ + --rm + --env GITHUB_TOKEN \ + --env HOMEBREW_DEPLOY_KEY \ + --volume "$PWD:$PWD" \ + --workdir "$PWD" \ + ghcr.io/goreleaser/goreleaser-cross:latest \ + build --snapshot --config .goreleaser.yaml env: GITHUB_TOKEN: ${{ inputs.token }} HOMEBREW_DEPLOY_KEY: ${{ inputs.homebrew-gh-secret }} diff --git a/scripts/gr-cross-runner.sh b/scripts/gr-cross-runner.sh deleted file mode 100755 index 271798df..00000000 --- a/scripts/gr-cross-runner.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -set -eu -exec docker run -it --rm -v "$PWD:$PWD" -w "$PWD" ghcr.io/goreleaser/goreleaser-cross:latest "$@" From d14fc25212ecb351e71065bdd2894cf2e34cadcf Mon Sep 17 00:00:00 2001 From: Hosh Sadiq Date: Tue, 13 Aug 2024 12:37:02 +0100 Subject: [PATCH 19/22] fix docker run --- .github/actions/mike-test-build/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/mike-test-build/action.yml b/.github/actions/mike-test-build/action.yml index 6da12cf9..c40e11c8 100644 --- a/.github/actions/mike-test-build/action.yml +++ b/.github/actions/mike-test-build/action.yml @@ -38,7 +38,7 @@ runs: run: | docker run \ --tty \ - --rm + --rm \ --env GITHUB_TOKEN \ --env HOMEBREW_DEPLOY_KEY \ --volume "$PWD:$PWD" \ From a0a7928a085a364509c7cf1d3e341a320f2eea6f Mon Sep 17 00:00:00 2001 From: Hosh Sadiq Date: Tue, 13 Aug 2024 13:33:06 +0100 Subject: [PATCH 20/22] re-enable CGO --- .goreleaser.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index a7b7135d..6d7ca273 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,5 +1,10 @@ version: 2 +env: + - GO111MODULE=on + - CGO_ENABLED=1 + - DOCKER_CLI_EXPERIMENTAL=enabled + builds: - id: ldcli binary: ldcli @@ -14,13 +19,12 @@ builds: ldflags: - -s - -w - + - -X 'main.version={{.Version}}' ignore: - goos: linux goarch: "386" - goos: darwin goarch: "386" - env: - >- TOOLCHAIN_BASE= @@ -39,6 +43,7 @@ builds: {{- end -}} - CC={{ .Env.TOOLCHAIN_BASE }}{{ if ne .Os "darwin" }}-gcc{{ end }} - CXX={{ .Env.TOOLCHAIN_BASE }}{{ if eq .Os "darwin" }}++{{ else }}-g++{{ end }} + dockers: # AMD64 - image_templates: From 030824c048791871e6e535b1f0e0a094bbfcce44 Mon Sep 17 00:00:00 2001 From: Hosh Sadiq Date: Tue, 13 Aug 2024 13:37:31 +0100 Subject: [PATCH 21/22] upload artifacts --- .github/actions/mike-test-build/action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/actions/mike-test-build/action.yml b/.github/actions/mike-test-build/action.yml index c40e11c8..2220a612 100644 --- a/.github/actions/mike-test-build/action.yml +++ b/.github/actions/mike-test-build/action.yml @@ -48,6 +48,11 @@ runs: env: GITHUB_TOKEN: ${{ inputs.token }} HOMEBREW_DEPLOY_KEY: ${{ inputs.homebrew-gh-secret }} + - name: Upload assets + uses: actions/upload-artifact@v4 + with: + name: ldcli-build + path: dist/* - name: Hash build artifacts for provenance id: hash shell: bash From c2506d1554cd1e9665c5e080a0829b402c7f9730 Mon Sep 17 00:00:00 2001 From: Hosh Sadiq Date: Wed, 14 Aug 2024 10:07:58 +0100 Subject: [PATCH 22/22] Remove custom workflow and re-add i686 --- .github/actions/mike-test-build/action.yml | 60 ---------------------- .github/actions/publish/action.yml | 36 +++++++++++-- .github/workflows/mike-test-release.yml | 52 ------------------- .goreleaser.yaml | 10 ++-- 4 files changed, 35 insertions(+), 123 deletions(-) delete mode 100644 .github/actions/mike-test-build/action.yml delete mode 100644 .github/workflows/mike-test-release.yml diff --git a/.github/actions/mike-test-build/action.yml b/.github/actions/mike-test-build/action.yml deleted file mode 100644 index 2220a612..00000000 --- a/.github/actions/mike-test-build/action.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Publish Artifacts -description: 'Publish artifacts to Github Release' -inputs: - token: - description: 'Token to use for publishing.' - required: true - homebrew-gh-secret: - description: 'SSH private key used as a GitHub deploy key for publishing to homebrew-tap.' - required: true - dry-run: - description: 'Is this a dry run. If so no package will be published.' - required: false - default: 'true' - tag: - description: 'Tag to upload artifacts to.' - required: true - -outputs: - hashes: - description: sha256sum hashes of built artifacts - value: ${{ steps.hash.outputs.hashes }} - -runs: - using: composite - steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - platforms: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/386 - - name: Login to Docker - shell: bash - run: | - echo $DOCKER_TOKEN | docker login --username $DOCKER_USERNAME --password-stdin - - - shell: bash - run: | - docker run \ - --tty \ - --rm \ - --env GITHUB_TOKEN \ - --env HOMEBREW_DEPLOY_KEY \ - --volume "$PWD:$PWD" \ - --workdir "$PWD" \ - ghcr.io/goreleaser/goreleaser-cross:latest \ - build --snapshot --config .goreleaser.yaml - env: - GITHUB_TOKEN: ${{ inputs.token }} - HOMEBREW_DEPLOY_KEY: ${{ inputs.homebrew-gh-secret }} - - name: Upload assets - uses: actions/upload-artifact@v4 - with: - name: ldcli-build - path: dist/* - - name: Hash build artifacts for provenance - id: hash - shell: bash - run: | - echo "hashes=$(sha256sum dist/*.tar.gz | base64 -w0)" >> "$GITHUB_OUTPUT" diff --git a/.github/actions/publish/action.yml b/.github/actions/publish/action.yml index 413366fe..d8ac23b3 100644 --- a/.github/actions/publish/action.yml +++ b/.github/actions/publish/action.yml @@ -14,6 +14,7 @@ inputs: tag: description: 'Tag to upload artifacts to.' required: true + outputs: hashes: description: sha256sum hashes of built artifacts @@ -29,17 +30,42 @@ runs: with: platforms: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/386 - name: Login to Docker + shell: bash + run: echo $DOCKER_TOKEN | docker login --username $DOCKER_USERNAME --password-stdin + + - name: Set up goreleaser shell: bash run: | - echo $DOCKER_TOKEN | docker login --username $DOCKER_USERNAME --password-stdin + CONTAINER_ID="$( + docker run --detach \ + --volume "$PWD:$PWD" \ + --entrypoint tail \ + ghcr.io/goreleaser/goreleaser-cross:latest \ + -f /dev/null + )" + docker exec --tty "$CONTAINER_ID" dpkg --add-architecture i386 + docker exec --tty "$CONTAINER_ID" apt-get update + docker exec --tty "$CONTAINER_ID" apt-get install --no-install-recommends -y -q crossbuild-essential-i386 + docker exec --tty "$CONTAINER_ID" git config --global --add safe.directory '*' + echo "CONTAINER_ID=$CONTAINER_ID" >> "$GITHUB_ENV" + - name: Run Goreleaser - uses: goreleaser/goreleaser-action@v5 - with: - version: latest - args: release ${{ inputs.dry-run == 'true' && '--skip=publish' || '' }} --config .goreleaser.yaml + shell: bash + run: docker exec + --env GITHUB_TOKEN + --env HOMEBREW_DEPLOY_KEY + --workdir "$PWD" + --tty + "$CONTAINER_ID" + goreleaser release ${{ inputs.dry-run == 'true' && '--skip=publish' || '' }} --config .goreleaser.yaml env: GITHUB_TOKEN: ${{ inputs.token }} HOMEBREW_DEPLOY_KEY: ${{ inputs.homebrew-gh-secret }} + - name: Upload assets + uses: actions/upload-artifact@v4 + with: + name: ldcli + path: dist/* - name: Hash build artifacts for provenance id: hash shell: bash diff --git a/.github/workflows/mike-test-release.yml b/.github/workflows/mike-test-release.yml deleted file mode 100644 index 8927a5e6..00000000 --- a/.github/workflows/mike-test-release.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Mike test build - -on: - push: - -jobs: - go-versions: - uses: ./.github/workflows/go-versions.yml - - release-please: - runs-on: ubuntu-latest - outputs: - release_created: ${{ steps.release.outputs.release_created }} - tag_name: ${{ steps.release.outputs.tag_name }} - steps: - - uses: google-github-actions/release-please-action@v4 - id: release - with: - token: ${{secrets.GITHUB_TOKEN}} - - release-ldcli: - permissions: - id-token: write # Needed to obtain Docker tokens - contents: write # Needed to upload release artifacts - needs: [ release-please, go-versions ] - runs-on: ubuntu-latest - outputs: - hashes: ${{ steps.publish.outputs.hashes }} - steps: - - uses: actions/checkout@v4 - name: Checkout - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: ${{ needs.go-versions.outputs.latest }} - - - uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.1 - name: 'Get Docker token' - with: - aws_assume_role: ${{ vars.AWS_ROLE_ARN }} - ssm_parameter_pairs: '/global/services/docker/public/username = DOCKER_USERNAME, /global/services/docker/public/token = DOCKER_TOKEN' - - - uses: ./.github/actions/mike-test-build - id: publish - with: - dry-run: 'true' - token: ${{ secrets.GITHUB_TOKEN }} - homebrew-gh-secret: ${{secrets.HOMEBREW_DEPLOY_KEY}} - tag: ${{ needs.release-please.outputs.tag_name }} \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 6d7ca273..154baf9a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,5 +1,7 @@ version: 2 +project_name: ldcli + env: - GO111MODULE=on - CGO_ENABLED=1 @@ -21,13 +23,10 @@ builds: - -w - -X 'main.version={{.Version}}' ignore: - - goos: linux - goarch: "386" - goos: darwin goarch: "386" env: - - >- - TOOLCHAIN_BASE= + - TOOLCHAIN_BASE= {{- if eq .Os "darwin" -}} o {{- if eq .Arch "arm64" -}}a{{- end -}} @@ -89,8 +88,7 @@ docker_manifests: - "launchdarkly/ldcli:latest-amd64" - "launchdarkly/ldcli:latest-arm64v8" brews: - - - name: ldcli + - name: ldcli description: "The official command line interface for managing LaunchDarkly feature flags." homepage: "https://launchdarkly.com" repository: