Skip to content

Commit

Permalink
*: fix releasing workflow (#1257)
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis committed Mar 31, 2021
1 parent ab63be2 commit eb335e6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
49 changes: 27 additions & 22 deletions .github/workflows/release-tiup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,18 @@ 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
echo ::set-output name=GIT_REF::${GITHUB_REF/refs\/tags\//}
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
Expand All @@ -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: |
Expand All @@ -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}
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion .github/workflows/reprotest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit eb335e6

Please sign in to comment.