1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-01 01:32:04 +03:00
vimr/bin/build.sh

144 lines
4.4 KiB
Bash
Raw Normal View History

2016-10-14 13:31:51 +03:00
#!/bin/bash
2019-12-22 23:45:42 +03:00
set -Eeuo pipefail
2016-10-14 13:31:51 +03:00
2019-12-22 23:45:42 +03:00
echo "### Building in Jenkins"
pushd "$( dirname "${BASH_SOURCE[0]}" )/.." > /dev/null
2016-10-14 13:31:51 +03:00
2016-10-22 11:06:54 +03:00
# for utf-8 for python script
export LC_CTYPE=en_US.UTF-8
2016-10-14 13:31:51 +03:00
export PATH=/usr/local/bin:$PATH
2019-12-22 23:45:42 +03:00
readonly publish=${publish:?"true or false"}
readonly branch=${branch:?"Eg develop"}
readonly is_snapshot=${is_snapshot:?"true or false"}
readonly update_appcast=${update_appcast:?"true or false"}
readonly update_snapshot_appcast_for_release=${update_snapshot_appcast_for_release:?"true or false"}
2020-02-14 22:19:55 +03:00
export marketing_version=${marketing_version:-"SNAPSHOT"}
readonly release_notes=${release_notes:-""}
2019-12-22 23:45:42 +03:00
2020-02-14 22:19:55 +03:00
readonly use_cache_carthage=${use_cache_carthage:?"true of false"}
2016-10-14 13:31:51 +03:00
2019-12-22 23:45:42 +03:00
if [[ "${is_snapshot}" = false ]] && [[ "${marketing_version}" == "" ]] ; then
echo "### ERROR If not snapshot, then the marketing version must be set!"
exit 1
fi
2019-12-22 23:45:42 +03:00
if [[ "${publish}" == true ]] && [[ "${release_notes}" == "" ]] ; then
2017-04-30 10:45:24 +03:00
echo "### ERROR No release notes, but publishing to Github!"
exit 1
fi
2019-12-22 23:45:42 +03:00
if [[ "${is_snapshot}" == false ]] && [[ "${update_appcast}" == false ]] ; then
echo "### ERROR Not updating appcast for release!"
exit 1
fi
2020-03-05 21:40:29 +03:00
if [[ "${publish}" == true ]] && [[ "${use_cache_carthage}" == true ]] ; then
2020-02-15 00:30:41 +03:00
echo "### ERROR Publishing, but using cache for Carthage!"
exit 1
fi
2019-12-22 23:45:42 +03:00
if [[ "${is_snapshot}" == false ]] && [[ "${branch}" != "master" ]] ; then
echo "### ERROR Not building master for release!"
exit 1
fi
2020-02-07 01:22:44 +03:00
git lfs install
2016-10-22 11:12:39 +03:00
echo "### Installing some python packages"
2018-03-10 18:37:17 +03:00
pip3 install requests
pip3 install Markdown
2019-12-22 23:45:42 +03:00
pip3 install waiting
2016-10-22 11:12:39 +03:00
2016-10-15 10:38:09 +03:00
echo "### Building VimR"
2020-04-05 19:30:58 +03:00
git lfs pull
2016-10-14 13:46:15 +03:00
./bin/prepare_repositories.sh
2016-10-14 13:51:49 +03:00
./bin/clean_old_builds.sh
2019-12-22 23:45:42 +03:00
if [[ "${is_snapshot}" == false ]] || [[ "${publish}" == true ]] ; then
./bin/set_new_versions.sh
else
echo "Not publishing and no release => not incrementing the version..."
fi
2020-02-14 22:19:55 +03:00
code_sign=true use_carthage_cache=${use_cache_carthage} ./bin/build_vimr.sh
2016-10-14 13:31:51 +03:00
2019-12-22 23:45:42 +03:00
pushd VimR > /dev/null
export readonly bundle_version=$(agvtool what-version | sed '2q;d' | sed -E 's/ +(.+)/\1/')
export marketing_version=$(agvtool what-marketing-version | tail -n 1 | sed -E 's/.*of "(.*)" in.*/\1/')
popd > /dev/null
2017-12-03 11:59:15 +03:00
2016-12-18 13:24:06 +03:00
2019-12-22 23:45:42 +03:00
if [[ "${is_snapshot}" == true ]]; then
export readonly compound_version="SNAPSHOT-${bundle_version}"
export readonly tag="snapshot/${bundle_version}"
else
export readonly compound_version="v${marketing_version}-${bundle_version}"
export readonly tag=${compound_version}
2016-10-15 01:09:57 +03:00
fi
2016-12-18 13:24:06 +03:00
2017-04-30 11:15:33 +03:00
echo "### Compressing the app"
2019-12-22 23:45:42 +03:00
export readonly vimr_file_name="VimR-${compound_version}.tar.bz2"
pushd build/Build/Products/Release > /dev/null
tar cjf ${vimr_file_name} VimR.app
popd > /dev/null
echo "### Bundle version: ${bundle_version}"
echo "### Marketing version: ${marketing_version}"
echo "### Compund version: ${compound_version}"
echo "### Tag: ${tag}"
echo "### VimR archive file name: ${vimr_file_name}"
echo "### Notarizing"
pushd ./build/Build/Products/Release > /dev/null
ditto -c -k --keepParent VimR.app VimR.app.zip
echo "### Uploading"
export readonly request_uuid=$(xcrun \
altool --notarize-app --primary-bundle-id "com.qvacua.VimR" \
--username "hataewon@gmail.com" --password "@keychain:dev-notar" \
--file VimR.app.zip | grep RequestUUID | sed -E 's/.* = (.*)/\1/')
popd > /dev/null
echo "### Waiting for notarization ${request_uuid} to finish"
./bin/wait_for_notarization.py
echo "### Notarization finished"
pushd ./build/Build/Products/Release > /dev/null
rm -rf ${vimr_file_name}
xcrun stapler staple VimR.app
tar cjf ${vimr_file_name} VimR.app
popd > /dev/null
2020-01-23 21:06:53 +03:00
if [[ "${publish}" == false ]] ; then
echo "Do not publish => exiting now..."
exit 0
fi
2019-12-22 23:45:42 +03:00
./bin/commit_and_push_tags.sh
./bin/create_github_release.sh
if [[ "${update_appcast}" == true ]]; then
./bin/set_appcast.py "build/Build/Products/Release/${vimr_file_name}" "${bundle_version}" "${marketing_version}" "${tag}" ${is_snapshot}
./bin/commit_and_push_appcast.sh "${branch}" "${compound_version}" ${is_snapshot} ${update_snapshot_appcast_for_release}
else
echo "Not updating appcast on develop => exiting now..."
exit 0
2016-11-03 22:23:41 +03:00
fi
2016-10-15 10:38:09 +03:00
2019-12-22 23:45:42 +03:00
if [[ "${is_snapshot}" == false ]] ; then
echo "### Merging ${branch} back to develop"
git reset --hard @
git fetch origin
git checkout -b for_master_to_develop origin/develop
git merge --ff-only for_build
git push origin HEAD:develop
fi
2019-12-22 23:45:42 +03:00
popd > /dev/null
2016-10-15 10:38:09 +03:00
echo "### Built VimR"