Skip to content

Commit dca6e7a

Browse files
Add release script
1 parent 53e3039 commit dca6e7a

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

azure-pipelines.yaml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ stages:
108108
versionSpec: '18.x'
109109
- script: |
110110
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
111-
yarn
111+
jlpm
112112
displayName: 'Save npm token & install labextension dependencies'
113113
env:
114114
NPM_TOKEN: $(NPM_TOKEN)
@@ -138,18 +138,7 @@ stages:
138138
- script: python -m twine upload -r "pypi-upload" --config-file $(PYPIRC_PATH) dist/*.whl
139139
displayName: 'Release to Pypi'
140140

141-
- script: |
142-
latestGitTag=$(git describe --tags --abbrev=0)
143-
latestGitTag="${latestGitTag:1}"
144-
echo $latestGitTag
145-
if [[ $latestGitTag == *"beta"* ]];
146-
then
147-
echo "Publishing beta version";
148-
yarn publish --new-version $latestGitTag --no-git-tag-version --access public --tag beta
149-
else
150-
echo "Publishing new version";
151-
yarn publish --new-version $(./node_modules/.bin/git-tag-version) --no-git-tag-version --access public
152-
fi
141+
- script: ./scripts/publish.sh
153142
env:
154143
GITHUB_TOKEN: $(GITHUB_TOKEN)
155144
NPM_TOKEN: $(NPM_TOKEN)

scripts/publish.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
LATEST_GIT_TAG=$(git describe --tags --abbrev=0)
4+
# Remove "v" from the start of the tag e.g. v1.0.0 -> 1.0.0
5+
LATEST_GIT_TAG="${LATEST_GIT_TAG:1}"
6+
# Update package.json's version field
7+
npm version $LATEST_GIT_TAG --no-commit-hooks --no-git-tag-version
8+
9+
echo "Updating package.json with version $LATEST_GIT_TAG"
10+
if [[ $LATEST_GIT_TAG == *"beta"* ]];
11+
then
12+
echo "Publishing beta version $LATEST_GIT_TAG to npm";
13+
yarn publish --new-version $LATEST_GIT_TAG --no-git-tag-version --no-commit-hooks --access public --tag beta
14+
elif [[ $LATEST_GIT_TAG == *"alpha"* ]];
15+
then
16+
echo "Publishing alpha version $LATEST_GIT_TAG to npm";
17+
yarn publish --new-version $LATEST_GIT_TAG --no-git-tag-version --no-commit-hooks --access public --tag alpha
18+
else
19+
echo "Publishing new version $LATEST_GIT_TAG to npm";
20+
yarn publish --new-version $LATEST_GIT_TAG --no-git-tag-version --no-commit-hooks --access public
21+
fi

0 commit comments

Comments
 (0)