From 7214c4518b9d7da953aa8e281454d740787a8bd9 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano <2082148+abeltrano@users.noreply.github.com> Date: Fri, 11 Jun 2021 10:00:35 -0600 Subject: [PATCH] Update release script to use git archive (#5) * Add .gitattributes. * Use git archive to create tarball. * Add newline to EOF. --- .gitattributes | 3 +++ scripts/release-wifi-telemetryd.sh | 18 +++++++----------- 2 files changed, 10 insertions(+), 11 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..067f7d3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +.gitattributes export-ignore +.gitignore export-ignore +.vscode/ export-ignore diff --git a/scripts/release-wifi-telemetryd.sh b/scripts/release-wifi-telemetryd.sh index 9351412..48bcb37 100755 --- a/scripts/release-wifi-telemetryd.sh +++ b/scripts/release-wifi-telemetryd.sh @@ -20,7 +20,7 @@ function usage() { echo " (default=${RELEASE_BRANCH_SOURCE_DEFAULT})" echo " -r " echo " The git repo url to use." - echo " (default=${GIT_REPO_DEFAULT}" + echo " (default=${GIT_REPO_DEFAULT})" echo " -f" echo " Determines whether or not release tags should be forcibly pushed." echo " Note that this will overwrite any existing tags; use with caution." @@ -75,7 +75,7 @@ function main() { local RELEASE_NAME=${FEATURE}-${RELEASE_VERSION} local RELEASE_DIR_SOURCE=${FEATURE}-release-${RELEASE_VERSION} local RELEASE_DIR=${RELEASE_NAME} - local RELEASE_ARCHIVE=${RELEASE_NAME} + local RELEASE_ARCHIVE=${RELEASE_NAME}.tar.xz TEMPDIR=$(mktemp -d) pushd ${TEMPDIR} >& ${REDIRECT} @@ -85,17 +85,13 @@ function main() { echo "tagging as ${RELEASE_VERSION_TAG}" git tag ${RELEASE_VERSION_TAG} ${FORCE} >& ${REDIRECT} git push origin refs/tags/${RELEASE_VERSION_TAG} ${FORCE} >& ${REDIRECT} - popd >& ${REDIRECT} + pushd -0 >& ${REDIRECT} && dirs -c >& ${REDIRECT} echo "preparing release archive" - git clone --depth 1 --branch ${RELEASE_VERSION_TAG} ${GIT_REPO} ${RELEASE_DIR} >& ${REDIRECT} - pushd ${RELEASE_DIR} >& ${REDIRECT} - rm -rf .vscode .git .gitignore >& ${REDIRECT} - popd >& ${REDIRECT} - popd >& ${REDIRECT} - tar cJf ${PWD}/${RELEASE_NAME}.tar.xz -C ${TEMPDIR} ${RELEASE_DIR} >& ${REDIRECT} - echo "created release archive ${RELEASE_NAME}.tar.xz -> $(sha256sum ${RELEASE_NAME}.tar.xz | awk '{print $1}')" + git config tar.tar.xz.command "xz -c" + git archive --format=tar.xz --prefix=${RELEASE_NAME}/ ${RELEASE_VERSION_TAG} > ${RELEASE_ARCHIVE} + echo "created release archive ${RELEASE_ARCHIVE} -> $(sha256sum ${RELEASE_ARCHIVE} | awk '{print $1}')" } main "$@" -finish \ No newline at end of file +finish