|
1 | 1 | #!/usr/bin/env bash |
2 | | -set -eu |
| 2 | +set -eux |
3 | 3 |
|
4 | | -if [ -z "$1" ]; then |
5 | | - echo "Missing version argument; this script should be invoked as:" |
6 | | - echo "$ ./dev/bump-version M.N.P" |
7 | | - exit 1 |
8 | | -fi |
| 4 | +# Assert that current branch is main |
| 5 | +git rev-parse --abbrev-ref HEAD | grep -q main |
9 | 6 |
|
10 | | -if [ -z "$GITHUB_TOKEN" ]; then |
11 | | - echo "Missing GitHub Token environment variable." |
12 | | - exit 1 |
13 | | -fi |
| 7 | +# Assert that there are no uncommitted changes |
| 8 | +git diff-index --quiet HEAD -- |
14 | 9 |
|
15 | | -echo "Updating package.json." |
16 | | -yarn version --no-git-tag-version --new-version $1 |
17 | | -echo "Updating CHANGELOG.md." |
18 | | -npx github-changes --only-pulls --branch main --owner sourcegraph --repository scip-typescript --tag-name "v$1" --token "$GITHUB_TOKEN" |
19 | | - |
20 | | -# HACK: github-changes doesn't seem to have a good way to get a delta since |
21 | | -# a particular tag to a _future_ tag; the --between-tags argument expects |
22 | | -# that the second tag in the range to already exist, whereas what we want |
23 | | -# to do here is first merge the ChangeLog and then add the new tag. |
24 | | - |
25 | | -# ✅ -f, -n and -s are supported on GNU csplit and BSD csplit. |
26 | | -csplit -f CL -n 1 -s CHANGELOG.md '/### v0.1.17/' |
27 | | - |
28 | | -# ✅ -i<ext> works on both GNU sed and BSD sed. |
29 | | -# See https://stackoverflow.com/a/22084103/2682729 |
30 | | -sed -i.bak -e 's/scip-typescript/lsif-typescript/g' CL1 && rm CL1.bak |
31 | | - |
32 | | -cat CL0 CL1 > CHANGELOG.md && rm CL0 CL1 |
| 10 | +NEW_VERSION="$1" |
33 | 11 |
|
34 | | -yarn run prettier |
| 12 | +echo "Updating package.json." |
| 13 | +yarn version --no-git-tag-version --new-version "$NEW_VERSION" |
| 14 | +git commit -am "Release v$NEW_VERSION." |
35 | 15 |
|
| 16 | +# Commit and tag new version |
| 17 | +VERSION_TAG="v$NEW_VERSION" |
36 | 18 | git add . |
37 | | -TITLE="Update ChangeLog and bump version for releasing $1." |
38 | | -git commit -m "$TITLE" |
39 | | - |
40 | | -gh pr create --base main --title "$TITLE" --body ' |
41 | | -### Test plan |
42 | | -
|
43 | | -Ran automated tests.' |
44 | | - |
45 | | -echo "-------------------------------------------------------------------------" |
46 | | -echo "Don't forget to push a version tag v$1 to main once the PR is merged!" |
47 | | -echo "-------------------------------------------------------------------------" |
| 19 | +git commit -m "Bump version to $VERSION_TAG" --allow-empty |
| 20 | +git push origin main |
| 21 | +git tag -af "$VERSION_TAG" -m "Version $NEW_VERSION" |
| 22 | +git push -f origin "$VERSION_TAG" |
0 commit comments