mirror of
https://github.com/keymanapp/keyman.git
synced 2026-11-04 18:17:51 +00:00
Fixes #6320. Part 1 of moving from lerna to a simpler, maintained monorepo solution, using TypeScript Projects and NPM Workspaces. There is more work to be done here. At this point, KeymanWeb builds and runs without errors, but the built file is substantially different, mostly in include order. Using TypeScript Projects, we move away from the need to run build scripts in various locations for almost all the Typescript modules. TODO: Embedded versions and tests have not been verified. TODO: developer/server is not yet verified. TODO: developer/js (needs a rename!) is not yet verified. TODO: Currently, the predictive-text folder needs refactoring to move the construction of the worker wrapper out of the Predictive Text build and into the final assembly of keymanweb.js (as it should be valid to run it as a separate .js anyway). TODO: Most of the `<reference>` paths need to be re-verified. Ideally there should be no references outside the current module for any given .ts. TODO: The embedded vs browser vs node (headless) builds should be tidied up for consistency so that it's obvious what depends on what. This is currently messiest in the predictive-text folder, where the output names diverge from the filenames and the various files are mixed in the same folder (as evidenced by the exclusions listed in each tsconfig.json). TODO: `npm install` should be removed from most build scripts and instead `npm ci` (#6196) should be run only once from the top-level folder for any given build. I've had eliminated side-effects from the `install` action for npm, which makes it easier to reason about state. TODO: verify_npm_setup and related functions can probably be eliminated. TODO: most of the build scripts should be largely eliminated for web. TODO: several ts projects use inconsistent output folders. TODO: it may be possible to generate a .d.ts for models/types so that we can use a consistent reference for those as well. TODO: build.sh, tsconfig.json should always be in the module's top-level folder, not in a subfolder such as src (e.g. see input-processor/src, keyboard-processor/src, web/source). TODO: resources/web-environment should be in common/web. TODO: other js node_modules imports should be wrapped like es6-shim. TODO: fix up the publish code for npm modules TODO: eliminate version numbers from package.json if possible? Whew, that's most of the stuff I noticed!
179 lines
4.6 KiB
Bash
Executable file
179 lines
4.6 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -e
|
|
set -u
|
|
|
|
#
|
|
# Usage: increment-version.sh [-f] [commit base]
|
|
#
|
|
# Increments the patch version on VERSION.md
|
|
#
|
|
# If -f is specified, triggers a build even with
|
|
# no detected changes.
|
|
#
|
|
# If commit is specified, pushes the new version
|
|
# to the repository. base snould be either
|
|
# master or beta.
|
|
#
|
|
|
|
## START STANDARD BUILD SCRIPT INCLUDE
|
|
# adjust relative paths as necessary
|
|
THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")"
|
|
. "$(dirname "$THIS_SCRIPT")/build-utils.sh"
|
|
## END STANDARD BUILD SCRIPT INCLUDE
|
|
|
|
. "$(dirname "$THIS_SCRIPT")/trigger-definitions.inc.sh"
|
|
. "$(dirname "$THIS_SCRIPT")/trigger-builds.inc.sh"
|
|
. "$(dirname "$THIS_SCRIPT")/sentry-control.inc.sh"
|
|
|
|
gitbranch=`git branch --show-current`
|
|
|
|
FORCE=0
|
|
HISTORY_FORCE=
|
|
|
|
if [[ "$1" == "-f" ]]; then
|
|
FORCE=1
|
|
HISTORY_FORCE=--force
|
|
shift
|
|
fi
|
|
|
|
if [[ $# -gt 0 ]]; then
|
|
# We want the action to specify the branch as a consistency check
|
|
# for now at least.
|
|
|
|
action=$1
|
|
if [[ $# -gt 1 ]]; then
|
|
base=$2
|
|
else
|
|
action=help
|
|
fi
|
|
|
|
if [[ $action == commit ]]; then
|
|
if [ "$base" != "master" ] && [ "$base" != "beta" ] && [[ ! "$base" =~ ^stable-[0-9]+\.[0-9]+$ ]]; then
|
|
echo "Invalid branch $base specified: must be master, beta, or stable-x.y."
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$base" != "$gitbranch" ]; then
|
|
echo "Branch doesn't match currently checked out branch."
|
|
exit 2
|
|
fi
|
|
fi
|
|
else
|
|
action="increment"
|
|
base="$gitbranch"
|
|
fi
|
|
|
|
if [[ $action == help ]]; then
|
|
echo "Usage: increment-version.sh [-f] [commit base]"
|
|
echo " -f forces a build even with no changes"
|
|
echo " base must be either master, beta or stable-x.y."
|
|
echo " base must be equal to currently checked-out"
|
|
echo " branch (this may not be required in future)"
|
|
exit 1
|
|
fi
|
|
|
|
# Let's ensure our base is up to date with GitHub to
|
|
# avoid transient errors
|
|
git pull origin $base
|
|
|
|
#
|
|
# Run the increment + history refresh
|
|
#
|
|
|
|
pushd "$KEYMAN_ROOT/resources/build/version" > /dev/null
|
|
npm install
|
|
npm run build:ts
|
|
popd > /dev/null
|
|
|
|
pushd "$KEYMAN_ROOT" > /dev/null
|
|
ABORT=0
|
|
node resources/build/version/lib/index.js history version -t "$GITHUB_TOKEN" -b "$base" $HISTORY_FORCE || ABORT=$?
|
|
|
|
if [[ $ABORT = 1 ]]; then
|
|
if [[ $FORCE = 0 ]]; then
|
|
echo "Skipping version increment from $VERSION: no recently merged pull requests were found"
|
|
if [ ! -z "${TEAMCITY_VERSION-}" ]; then
|
|
# Send TeamCity a build status
|
|
echo "##teamcity[buildStatus status='SUCCESS' text='Skipping version increment from $VERSION: no recently merged pull requests were found']"
|
|
fi
|
|
exit 0
|
|
else
|
|
echo "Force specified; building even though no changes were detected"
|
|
fi
|
|
elif [[ $ABORT != 0 ]]; then
|
|
echo "Failed to complete version history check"
|
|
exit $ABORT
|
|
fi
|
|
popd > /dev/null
|
|
|
|
#
|
|
# Push the result
|
|
#
|
|
|
|
if [ "$action" == "commit" ]; then
|
|
VERSION_MD="$KEYMAN_ROOT/VERSION.md"
|
|
NEWVERSION=`cat $VERSION_MD | tr -d "[:space:]"`
|
|
|
|
pushd "$KEYMAN_ROOT" > /dev/null
|
|
message="auto: increment $base version to $NEWVERSION"
|
|
branch="auto/version-$base-$NEWVERSION"
|
|
git tag -a "release-$VERSION_WITH_TAG" -m "Keyman release $VERSION_WITH_TAG"
|
|
git checkout -b "$branch"
|
|
git add VERSION.md HISTORY.md
|
|
|
|
# Also updates package versions, committing those changes
|
|
# Uses the 'version' run script defined in the base package.json.
|
|
npm install
|
|
|
|
npm run version -- "$NEWVERSION"
|
|
|
|
# Version info will be updated in package.json and all workspace package.json files.
|
|
git add package.json package-lock.json
|
|
npm add **/package.json **/package-lock.json
|
|
|
|
# Now that all version-related changes are ready and git-added, it's time to commit.
|
|
git commit -m "$message"
|
|
git push --tags origin "$branch"
|
|
git checkout $base
|
|
|
|
#
|
|
# Tell Sentry about this (previous version)
|
|
#
|
|
|
|
makeSentryRelease
|
|
popd > /dev/null
|
|
|
|
#
|
|
# Trigger builds for the previous version on TeamCity and Jenkins
|
|
#
|
|
|
|
triggerBuilds
|
|
|
|
#
|
|
# Now, create the PR on GitHub which will be merged when ready
|
|
#
|
|
|
|
cd "$KEYMAN_ROOT"
|
|
git checkout "$branch"
|
|
hub pull-request -f --no-edit -b $base -l auto
|
|
|
|
#
|
|
# Done
|
|
#
|
|
|
|
echo "Version was incremented and pull request was created, and builds were triggered"
|
|
if [ ! -z "${TEAMCITY_VERSION-}" ]; then
|
|
# Send TeamCity a build status
|
|
echo "##teamcity[buildStatus status='SUCCESS' text='Version was incremented from $VERSION to $NEWVERSION and pull request was created']"
|
|
fi
|
|
|
|
#
|
|
# After this script finishes in CI, we will be pushing the new history to
|
|
# downloads.keyman.com, so we need to finish with the branch here that has the
|
|
# latest history in it. We don't need to cleanup the branch because the CI will
|
|
# do that for us.
|
|
#
|
|
fi
|
|
|
|
exit 0
|