Skip to content

Commit

Permalink
*: make tarballs reproducible
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis committed Mar 31, 2021
1 parent b884d1c commit 164caed
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 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 @@ -89,7 +92,7 @@ jobs:
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

0 comments on commit 164caed

Please sign in to comment.