1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-26 23:36:08 +03:00
vimr/bin/build_release.sh

152 lines
3.8 KiB
Bash
Raw Normal View History

2021-12-12 23:41:27 +03:00
#!/bin/bash
set -Eeuo pipefail
2022-03-24 20:08:11 +03:00
readonly create_gh_release=${create_gh_release:?"true or false"}
2021-12-12 23:41:27 +03:00
readonly upload=${upload:?"true or false"}
readonly update_appcast=${update_appcast:?"true or false"}
2022-03-24 20:08:11 +03:00
# The release spec file should export the following env vars:
# is_snapshot
# bundle_version
# marketing_version
# tag
# github_release_name
# release_notes
readonly release_spec_file=${release_spec_file:?"path to release spec sh file (output by set_new_versions.sh script"}
source "${release_spec_file}"
2021-12-12 23:41:27 +03:00
readonly build_folder_path="./build/Build/Products/Release"
readonly vimr_artifact_path="${build_folder_path}/VimR-${marketing_version}.tar.bz2"
2022-01-02 18:38:26 +03:00
declare -r -x GH_REPO="qvacua/vimr"
2021-12-12 23:41:27 +03:00
prepare_bin() {
pushd ./bin >/dev/null
if ! pyenv which python | grep -q "com.qvacua.VimR.bin"; then
echo "com.qvacua.VimR.bin virtualenv not set up!"
exit 1;
fi
pip install -r requirements.txt
popd >/dev/null
}
check_version() {
if [[ "${is_snapshot}" == true && ! "${marketing_version}" =~ ^SNAPSHOT.* ]]; then
echo "When snapshot, marketing_version should be SNAPSHOT-xyz"
exit 1
fi
if [[ "${is_snapshot}" == false && ! "${marketing_version}" =~ ^v.* ]]; then
echo "When no snapshot, marketing_version should be like v0.35.0"
exit 1
fi
}
2022-03-24 20:08:11 +03:00
check_gh_release_present() {
2021-12-12 23:41:27 +03:00
if [[ "${upload}" == true ]]; then
2022-01-02 18:38:26 +03:00
if gh release list | grep "${tag}"; then
echo "Release with tag ${tag} found"
else
echo "Release with tag ${tag} does not exist!"
2021-12-12 23:41:27 +03:00
exit 1
fi
fi
}
build_release() {
echo "### Building release"
# Check whether NvimServer submodule is clean
git submodule update
pushd NvimServer >/dev/null
if [[ ! -z "$(git status --porcelain)" ]]; then
echo "NvimServer submodule not clean!"
exit 1
fi
popd >/dev/null
2022-06-26 19:37:09 +03:00
clean=true notarize=true use_carthage_cache=false ./bin/build_vimr.sh
2021-12-12 23:41:27 +03:00
pushd "${build_folder_path}" >/dev/null
tar cjf "VimR-${marketing_version}.tar.bz2" VimR.app
popd >/dev/null
echo "### Built (signed and notarized) release: ${vimr_artifact_path}"
}
2022-03-24 20:08:11 +03:00
create_gh_release() {
if [[ "${is_snapshot}" == true ]]; then
gh release create "${tag}" \
2022-03-24 20:08:11 +03:00
--discussion-category "general" \
--prerelease \
--title "${github_release_name}" \
--notes "${release_notes}"
else
gh release create "${tag}" \
2022-03-24 20:08:11 +03:00
--discussion-category "general" \
--title "${github_release_name}" \
--notes "${release_notes}"
fi
}
2021-12-12 23:41:27 +03:00
upload_artifact() {
local -x GH_TOKEN
GH_TOKEN=$(cat ~/.local/secrets/github.qvacua.release.token)
readonly GH_TOKEN
echo "### Uploading artifact"
gh release upload "${tag}" "${vimr_artifact_path}"
echo "### Uploaded artifact"
}
update_appcast_file() {
./bin/set_appcast.py \
"${vimr_artifact_path}" \
"${bundle_version}" \
"${marketing_version}" \
"${tag}" \
"${is_snapshot}"
local app_cast_file_name="appcast.xml"
if [[ "${is_snapshot}" == true ]]; then
app_cast_file_name="appcast_snapshot.xml"
fi
readonly app_cast_file_name
cp "${build_folder_path}/${app_cast_file_name}" .
echo "### ${app_cast_file_name} updated. Commit and push"
}
main() {
2022-03-24 20:08:11 +03:00
echo "create_gh_release=${create_gh_release} \\"
echo "upload=${upload} update_appcast=${update_appcast} \\"
echo "vimr_artifact_path=${vimr_artifact_path}"
2021-12-12 23:41:27 +03:00
pushd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null
2022-03-24 20:08:11 +03:00
2022-04-16 19:32:08 +03:00
check_version
prepare_bin
build_release
2021-12-12 23:41:27 +03:00
2022-03-24 20:08:11 +03:00
if [[ "${create_gh_release}" == true ]]; then
create_gh_release
fi
2021-12-12 23:41:27 +03:00
if [[ "${upload}" == true ]]; then
2022-03-24 20:08:11 +03:00
# Give GitHub some time.
sleep 5
check_gh_release_present
2021-12-12 23:41:27 +03:00
upload_artifact
2022-03-19 13:14:59 +03:00
fi
2021-12-12 23:41:27 +03:00
2022-03-19 13:14:59 +03:00
if [[ "${update_appcast}" == true ]]; then
# Sometimes GitHub is not yet up-to-date with the uploaded asset.
sleep 5
2022-03-19 13:14:59 +03:00
update_appcast_file
2021-12-12 23:41:27 +03:00
fi
2022-03-24 20:08:11 +03:00
2021-12-12 23:41:27 +03:00
popd >/dev/null
}
2022-01-02 18:38:26 +03:00
main