diff --git a/.drone.yml b/.drone.yml index 59337faa..a16d0cb8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -351,36 +351,3 @@ steps: - tag depends_on: - manifest-quay-tag - - - # this builds the binaries that get uploaded to GH for a release - # docker binaries are build in docker itself via multi-stage Docker files - - name: build-all-binaries - image: golang:1.23 - pull: if-not-exists - environment: - GO111MODULE: on - LOG_LEVEL: "info" - commands: - - make build-all-binaries - when: - event: - - tag - depends_on: - - start - - - name: release-github-binaries - image: golang:1.23 - pull: if-not-exists - environment: - GITHUB_TOKEN: - from_secret: github_token - GO111MODULE: on - commands: - - "apt-get update && apt-get install -y zip" - - "./release-github-binaries.sh" - when: - event: - - tag - depends_on: - - build-all-binaries diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0d4925db..e828e4fe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,10 @@ jobs: go-version: '1.23' - name: Build binaries + env: + RELEASE_TAG: ${{ env.GITHUB_REF_NAME }} run: | + env make build-all-binaries ls -la ./package-github-binaries.sh @@ -30,3 +33,4 @@ jobs: with: artifacts: "dist/*" allowUpdates: true + omitBodyDuringUpdate: true diff --git a/Makefile b/Makefile index f62579c5..8a838753 100644 --- a/Makefile +++ b/Makefile @@ -70,7 +70,7 @@ mixin: BUILD_DT:=$(shell date +%F-%T) -GO_LDFLAGS:="-s -w -extldflags \"-static\" -X main.BuildVersion=${DRONE_TAG} -X main.BuildCommitSha=${DRONE_COMMIT_SHA} -X main.BuildDate=$(BUILD_DT)" +GO_LDFLAGS:="-s -w -extldflags \"-static\" -X main.BuildVersion=${RELEASE_TAG} -X main.BuildCommitSha=${DRONE_COMMIT_SHA} -X main.BuildDate=$(BUILD_DT)" .PHONE: build-some-amd64-binaries @@ -80,7 +80,7 @@ build-some-amd64-binaries: rm -rf .build | true export CGO_ENABLED=0 ; \ - gox -os="linux windows" -arch="amd64" -verbose -rebuild -ldflags $(GO_LDFLAGS) -output ".build/redis_exporter-${DRONE_TAG}.{{.OS}}-{{.Arch}}/{{.Dir}}" && echo "done" + gox -os="linux windows" -arch="amd64" -verbose -rebuild -ldflags $(GO_LDFLAGS) -output ".build/redis_exporter-${RELEASE_TAG}.{{.OS}}-{{.Arch}}/{{.Dir}}" && echo "done" .PHONE: build-all-binaries @@ -90,9 +90,9 @@ build-all-binaries: rm -rf .build | true export CGO_ENABLED=0 ; \ - gox -os="linux windows freebsd netbsd openbsd" -arch="amd64 386" -verbose -rebuild -ldflags $(GO_LDFLAGS) -output ".build/redis_exporter-${DRONE_TAG}.{{.OS}}-{{.Arch}}/{{.Dir}}" && \ - gox -os="darwin solaris illumos" -arch="amd64" -verbose -rebuild -ldflags $(GO_LDFLAGS) -output ".build/redis_exporter-${DRONE_TAG}.{{.OS}}-{{.Arch}}/{{.Dir}}" && \ - gox -os="darwin" -arch="arm64" -verbose -rebuild -ldflags $(GO_LDFLAGS) -output ".build/redis_exporter-${DRONE_TAG}.{{.OS}}-{{.Arch}}/{{.Dir}}" && \ - gox -os="linux freebsd netbsd" -arch="arm" -verbose -rebuild -ldflags $(GO_LDFLAGS) -output ".build/redis_exporter-${DRONE_TAG}.{{.OS}}-{{.Arch}}/{{.Dir}}" && \ - gox -os="linux" -arch="arm64 mips64 mips64le ppc64 ppc64le s390x" -verbose -rebuild -ldflags $(GO_LDFLAGS) -output ".build/redis_exporter-${DRONE_TAG}.{{.OS}}-{{.Arch}}/{{.Dir}}" && \ + gox -os="linux windows freebsd netbsd openbsd" -arch="amd64 386" -verbose -rebuild -ldflags $(GO_LDFLAGS) -output ".build/redis_exporter-${RELEASE_TAG}.{{.OS}}-{{.Arch}}/{{.Dir}}" && \ + gox -os="darwin solaris illumos" -arch="amd64" -verbose -rebuild -ldflags $(GO_LDFLAGS) -output ".build/redis_exporter-${RELEASE_TAG}.{{.OS}}-{{.Arch}}/{{.Dir}}" && \ + gox -os="darwin" -arch="arm64" -verbose -rebuild -ldflags $(GO_LDFLAGS) -output ".build/redis_exporter-${RELEASE_TAG}.{{.OS}}-{{.Arch}}/{{.Dir}}" && \ + gox -os="linux freebsd netbsd" -arch="arm" -verbose -rebuild -ldflags $(GO_LDFLAGS) -output ".build/redis_exporter-${RELEASE_TAG}.{{.OS}}-{{.Arch}}/{{.Dir}}" && \ + gox -os="linux" -arch="arm64 mips64 mips64le ppc64 ppc64le s390x" -verbose -rebuild -ldflags $(GO_LDFLAGS) -output ".build/redis_exporter-${RELEASE_TAG}.{{.OS}}-{{.Arch}}/{{.Dir}}" && \ echo "done" diff --git a/release-github-binaries.sh b/release-github-binaries.sh deleted file mode 100755 index b35bbe05..00000000 --- a/release-github-binaries.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash - - -set -u -e -o pipefail - -if [[ -z "${DRONE_TAG}" ]] ; then - echo 'ERROR: Missing DRONE_TAG env' - exit 1 -fi - -echo "go install ghr" -go install github.com/tcnksm/ghr@v0.14.0 - -mkdir -p dist - -for build in $(ls .build); do - echo "Creating archive for ${build}" - - cp LICENSE README.md ".build/${build}/" - - if [[ "${build}" =~ windows-.*$ ]] ; then - - # Make sure to clear out zip files to prevent zip from appending to the archive. - rm "dist/${build}.zip" || true - cd ".build/" && zip -r --quiet -9 "../dist/${build}.zip" "${build}" && cd ../ - else - tar -C ".build/" -czf "dist/${build}.tar.gz" "${build}" - fi -done - -cd dist -sha256sum *.gz *.zip > sha256sums.txt -ls -la -cd .. - -echo "Upload to Github" -ghr -parallel 1 -u oliver006 -r redis_exporter --replace "${DRONE_TAG}" dist/ - -echo "Done"