forked from asciidoctor/asciidoctor-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·46 lines (41 loc) · 1.95 KB
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
if [ -z $RELEASE_VSCE_TOKEN ]; then
echo No Visual Studio Code Extension token specified for publishing to marketplace.visualstudio.com/VSCode. Stopping release.
exit 1
fi
if [ -z $RELEASE_VERSION ]; then
echo No release version specified. Stopping release.
exit 1
fi
RELEASE_BRANCH=$GITHUB_REF_NAME
if [ -z $RELEASE_USER ]; then
export RELEASE_USER=$GITHUB_ACTOR
fi
RELEASE_GIT_NAME=$(curl -s https://api.github.com/users/$RELEASE_USER | jq -r .name)
# configure git to push changes
git config --local user.name "$RELEASE_GIT_NAME"
git config --local user.email "$RELEASE_GIT_EMAIL"
# release!
(
set -e
# pre-release versions are unsupported by VS Code
# > We only support major.minor.patch for extension versions and semver pre-release tags are not supported.
# > Support for this will arrive in the future.
# https://code.visualstudio.com/api/working-with-extensions/publishing-extension#prerelease-extensions
RELEASE_VERSION_WITHOUT_PRERELEASE=$(node -e "console.log(require('semver').coerce('$RELEASE_VERSION').version)")
npm version $RELEASE_VERSION_WITHOUT_PRERELEASE --message "release $RELEASE_VERSION_WITHOUT_PRERELEASE [no ci]"
git push origin $(git describe --tags --exact-match)
npm run package
npx vsce publish -p $RELEASE_VSCE_TOKEN $(node -e "console.log(require('semver').parse('$RELEASE_VERSION').prerelease.length > 0 ? '--pre-release' : '')")
git push origin $RELEASE_BRANCH
node tasks/release-notes.js
gh release create v$RELEASE_VERSION_WITHOUT_PRERELEASE -t v$RELEASE_VERSION_WITHOUT_PRERELEASE -F release-notes.md -d
gh release upload v$RELEASE_VERSION_WITHOUT_PRERELEASE asciidoctor-vscode-$RELEASE_VERSION_WITHOUT_PRERELEASE.vsix
npm pkg set version="$(npx semver -i patch $RELEASE_VERSION_WITHOUT_PRERELEASE)-dev"
git commit -a -m 'prepare branch for development [no ci]'
git push origin $RELEASE_BRANCH
)
exit_code=$?
git status -s -b
exit $exit_code