From eb335e6ad9d0dc19d1c43db422cd409d62bc3cea Mon Sep 17 00:00:00 2001 From: Allen Zhong Date: Wed, 31 Mar 2021 16:41:24 +0800 Subject: [PATCH] *: fix releasing workflow (#1257) --- .github/workflows/release-tiup.yaml | 49 ++++++++++++++++------------- .github/workflows/reprotest.yaml | 2 +- Makefile | 2 +- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release-tiup.yaml b/.github/workflows/release-tiup.yaml index 2f07833642..d8b14da49c 100644 --- a/.github/workflows/release-tiup.yaml +++ b/.github/workflows/release-tiup.yaml @@ -54,8 +54,9 @@ jobs: STAGING_VER=`git describe --tags | sed -r "s/([^-]*-g)/r\1/"` echo ::set-output name=STAGING::$STAGING_VER - - name: Get git ref - id: get_ref + - name: Get git ref and commit + id: get_git + working-directory: ${{ env.working-directory }} # when empty, it will be determined by Makefile run: | if [[ $GITHUB_REF == refs/tags/* ]]; then @@ -63,6 +64,8 @@ jobs: elif [[ $GITHUB_REF == refs/heads/* ]]; then echo ::set-output name=GIT_REF::${GITHUB_REF/refs\/heads\//} fi + COMMIT_TIMESTAMP=`git show --no-patch --no-notes --pretty='%aI'` + echo ::set-output name=COMMIT_TIMESTAMP::$COMMIT_TIMESTAMP - name: Build for ${{ matrix.os }}-${{ matrix.arch }} id: build_tiup @@ -71,7 +74,7 @@ jobs: GOOS: ${{ matrix.os }} GOARCH: ${{ matrix.arch }} COMMIT: ${GITHUB_SHA} - GITREF: ${{ steps.get_ref.outputs.GIT_REF }} + GITREF: ${{ steps.get_git.outputs.GIT_REF }} actor: ${{ github.actor }} event: ${{ github.event_name }} run: | @@ -86,10 +89,10 @@ jobs: fi echo ::set-output name=REL_VER::$REL_VER - BUILD_FLAG='-trimpath -buildmode=pie' make build ctl && echo "Build success." + BUILD_FLAGS='-trimpath -buildmode=pie' make build ctl && echo "Build success." checksum_file=checksum.${{ matrix.os }}-${{ matrix.arch }}.txt - checksum_header="TiUP $REL_VER (${actor}@${event}) ${{ github.run_id }} `date +%s`" + checksum_header="TiUP $REL_VER (${actor}@${event}) ${{ github.run_id }}" echo ${checksum_header} > ${checksum_file} echo "sha256sum:" >> ${checksum_file} sha256sum bin/* >> ${checksum_file} @@ -118,18 +121,21 @@ jobs: mkdir -p package cp $TIUP_HOME/bin/root.json bin/root.json + # make tar reproducible + TAR="tar --sort=name --mtime=${{ steps.get_git.outputs.COMMIT_TIMESTAMP }} --owner=0 --group=0 --numeric-owner" + # package all binaries to upload to github release asset - tar -czf tiup-${REL_VER}-${ARCH}.tar.gz bin checksum.${{ matrix.os }}-${{ matrix.arch }}.txt + ${TAR} -czf tiup-${REL_VER}-${ARCH}.tar.gz bin checksum.${{ matrix.os }}-${{ matrix.arch }}.txt # package each component # tiup-ctl is destributed with other components, so not packaging / publishing here - tar -C bin -czf package/tiup-${REL_VER}-${ARCH}.tar.gz tiup - tar -C bin -czf package/cluster-${REL_VER}-${ARCH}.tar.gz tiup-cluster - tar -C bin -czf package/dm-${REL_VER}-${ARCH}.tar.gz tiup-dm - tar -C bin -czf package/playground-${REL_VER}-${ARCH}.tar.gz tiup-playground - tar -C bin -czf package/client-${REL_VER}-${ARCH}.tar.gz tiup-client - tar -C bin -czf package/bench-${REL_VER}-${ARCH}.tar.gz tiup-bench - tar -C bin -czf package/server-${REL_VER}-${ARCH}.tar.gz tiup-server + ${TAR} -C bin -czf package/tiup-${REL_VER}-${ARCH}.tar.gz tiup + ${TAR} -C bin -czf package/cluster-${REL_VER}-${ARCH}.tar.gz tiup-cluster + ${TAR} -C bin -czf package/dm-${REL_VER}-${ARCH}.tar.gz tiup-dm + ${TAR} -C bin -czf package/playground-${REL_VER}-${ARCH}.tar.gz tiup-playground + ${TAR} -C bin -czf package/client-${REL_VER}-${ARCH}.tar.gz tiup-client + ${TAR} -C bin -czf package/bench-${REL_VER}-${ARCH}.tar.gz tiup-bench + ${TAR} -C bin -czf package/server-${REL_VER}-${ARCH}.tar.gz tiup-server - name: Publish packages working-directory: ${{ env.working-directory }} @@ -173,14 +179,13 @@ jobs: ${TIUP_BIN} mirror publish server ${REL_VER} package/server-${REL_VER}-${ARCH}.tar.gz tiup-server --arch ${{ matrix.arch }} --os ${{ matrix.os }} --desc="${server_desc}" --hide --standalone - name: Upload the all-in-one tarball to GitHub release - uses: actions/upload-release-asset@v1 + uses: ncipollo/release-action@v1 if: github.event_name == 'release' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REL_VER: ${{ steps.build_tiup.outputs.REL_VER }} - ARCH: ${{ matrix.os }}-${{ matrix.arch }} with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: ./tiup-${REL_VER}-${ARCH}.tar.gz - asset_name: tiup-${REL_VER}-${ARCH}.tar.gz - asset_content_type: application/gzip + allowUpdates: true + artifacts: ${{ env.working-directory }}/tiup-${{ steps.build_tiup.outputs.REL_VER }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz + artifactContentType: application/gzip + omitBodyDuringUpdate: true + omitNameDuringUpdate: true + prerelease: ${{ github.event.release.prerelease }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/reprotest.yaml b/.github/workflows/reprotest.yaml index 7327a93662..6c6968a35f 100644 --- a/.github/workflows/reprotest.yaml +++ b/.github/workflows/reprotest.yaml @@ -60,6 +60,6 @@ jobs: GOROOT=${{ steps.prepare_env.GOROOT }} \ GOPATH=${{ steps.prepare_env.GOPATH }} \ PATH=$GOROOT/bin:$PATH \ - BUILD_FLAG='-trimpath -buildmode=pie' \ + BUILD_FLAGS='-trimpath -buildmode=pie' \ make build" \ bin diff --git a/Makefile b/Makefile index 1cba637e45..c23cdd6e1c 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ GOOS := $(if $(GOOS),$(GOOS),$(shell go env GOOS)) GOARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH)) GOENV := GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) GO := $(GOENV) go -GOBUILD := $(GO) build $(BUILD_FLAG) +GOBUILD := $(GO) build $(BUILD_FLAGS) GOTEST := GO111MODULE=on CGO_ENABLED=1 go test -p 3 SHELL := /usr/bin/env bash