Update release script to use git archive (#5)

* Add .gitattributes.
* Use git archive to create tarball.
* Add newline to EOF.
This commit is contained in:
Andrew Beltrano 2021-06-11 10:00:35 -06:00 коммит произвёл GitHub
Родитель 9d253b36ac
Коммит 7214c4518b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 10 добавлений и 11 удалений

3
.gitattributes поставляемый Normal file
Просмотреть файл

@ -0,0 +1,3 @@
.gitattributes export-ignore
.gitignore export-ignore
.vscode/ export-ignore

Просмотреть файл

@ -20,7 +20,7 @@ function usage() {
echo " (default=${RELEASE_BRANCH_SOURCE_DEFAULT})"
echo " -r <git repo url>"
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
finish