1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-23 19:21:53 +03:00

Create release automatically

This commit is contained in:
Tae Won Ha 2022-03-24 18:08:11 +01:00
parent 141109c396
commit fdb869e010
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
3 changed files with 83 additions and 20 deletions

View File

@ -63,20 +63,20 @@ then continuously invoke the `build_nvimserver_for_local_dev` script.
* Set a new version of VimR via
```bash
is_snapshot=true ./bin/set_new_versions.sh
is_snapshot=true ./bin/set_new_versions.sh # for snapshot or
is_snapshot=false marketing_version=0.38.3 ./bin/set_new_versions.sh # for release
```
and commit. This will print out some environment variables you can use when invoking the
`build_release.sh` script later.
and commit. This will create a `${bundle_version}-snapshot/release.sh` file to be used
with `build_release.sh`.
* Tag with the name
- Snapshot: `snapshot/yyyymmdd.HHMMSS`
- Release: `vX.Y.Z-yyyymmdd.HHMMSS`
* Push, create a release and add release notes.
* Push
* Build, package and upload via
```bash
is_snapshot=true \
bundle_version=20211212.213543 tag=snapshot/20211212.213543 marketing_version=SNAPSHOT-20211212.213543 \
upload=true update_appcast=true \
create_gh_release=true upload=true update_appcast=true \
release_spec_file=....sh \
./bin/build_release.sh
```
* The `appcast{-snapshot}.xml` file is modified. Check and push.

View File

@ -1,12 +1,21 @@
#!/bin/bash
set -Eeuo pipefail
readonly is_snapshot=${is_snapshot:?"true or false"}
readonly bundle_version=${bundle_version:?"date '+%Y%m%d.%H%M%S'"}
readonly tag=${tag:?"snapshot/xyz or v0.35.0"}
readonly marketing_version=${marketing_version:?"SNAPSHOT-xyz or v0.35.0 (mind the v-prefix when not snapshot"}
readonly create_gh_release=${create_gh_release:?"true or false"}
readonly upload=${upload:?"true or false"}
readonly update_appcast=${update_appcast:?"true or false"}
# 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}"
readonly build_folder_path="./build/Build/Products/Release"
readonly vimr_artifact_path="${build_folder_path}/VimR-${marketing_version}.tar.bz2"
declare -r -x GH_REPO="qvacua/vimr"
@ -34,7 +43,7 @@ check_version() {
fi
}
check_upload() {
check_gh_release_present() {
if [[ "${upload}" == true ]]; then
if gh release list | grep "${tag}"; then
echo "Release with tag ${tag} found"
@ -57,6 +66,23 @@ build_release() {
echo "### Built (signed and notarized) release: ${vimr_artifact_path}"
}
create_gh_release() {
if [[ "${is_snapshot}" == true ]]; then
gh release create \
--discussion-category "general" \
--prerelease \
--target "${tag}" \
--title "${github_release_name}" \
--notes "${release_notes}"
else
gh release create \
--discussion-category "general" \
--target "${tag}" \
--title "${github_release_name}" \
--notes "${release_notes}"
fi
}
upload_artifact() {
local -x GH_TOKEN
GH_TOKEN=$(cat ~/.local/secrets/github.qvacua.release.token)
@ -86,18 +112,24 @@ update_appcast_file() {
}
main() {
echo "is_snapshot=${is_snapshot} bundle_version=${bundle_version}" \
"tag=${tag} marketing_version=${marketing_version}" \
"upload=${upload} update_appcast=${update_appcast}" \
"vimr_artifact_path=${vimr_artifact_path}"
echo "create_gh_release=${create_gh_release} \\"
echo "upload=${upload} update_appcast=${update_appcast} \\"
echo "vimr_artifact_path=${vimr_artifact_path}"
pushd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null
check_version
check_upload
prepare_bin
build_release
if [[ "${create_gh_release}" == true ]]; then
create_gh_release
fi
if [[ "${upload}" == true ]]; then
# Give GitHub some time.
sleep 5
check_gh_release_present
upload_artifact
fi
@ -106,6 +138,7 @@ main() {
sleep 5
update_appcast_file
fi
popd >/dev/null
}

View File

@ -37,13 +37,43 @@ main() {
echo "### Set versions of VimR"
local tag
local github_release_name
local version_marker
if [[ "${is_snapshot}" == true ]]; then
tag="snapshot/${bundle_version}"
echo "bundle_version=${bundle_version} marketing_version=${marketing_version} tag=${tag}"
github_release_name="${marketing_version}"
version_marker="snapshot"
else
tag="v${marketing_version}-${bundle_version}"
echo "bundle_version=${bundle_version} marketing_version=v${marketing_version} tag=${tag}"
github_release_name="$tag"
version_marker="release"
fi
readonly tag
readonly github_release_name
readonly version_marker
local output
output=$(cat <<-END
declare -r -x is_snapshot=${is_snapshot}
declare -r -x bundle_version=${bundle_version}
declare -r -x marketing_version=${marketing_version}
declare -r -x tag=${tag}
declare -r -x github_release_name=${github_release_name}
declare -r -x release_notes=\$(cat <<-ENDRN
replace-me
ENDRN
)
END
)
readonly output
echo "${output}" > "${bundle_version}-${version_marker}.sh"
echo "### Tag, commit and push with ${tag}"
echo "### Use the following to build a release:"
echo "release_spec_file=${bundle_version}-${version_marker}.sh \\"
echo "create_gh_release=true upload=true update_appcast=true \\"
echo "./bin/build_release.sh"
}
main