mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-12-24 00:01:36 +01:00
Resolve "Automatic NPM publish."
This commit is contained in:
parent
ee5f3da093
commit
5977e675cf
|
@ -3,6 +3,7 @@ image: node:8-alpine
|
|||
stages:
|
||||
- test
|
||||
- build
|
||||
- publish
|
||||
|
||||
before_script:
|
||||
- npm install
|
||||
|
@ -24,3 +25,19 @@ build:
|
|||
artifacts:
|
||||
paths:
|
||||
- foris-*.tgz
|
||||
|
||||
publish_beta:
|
||||
stage: publish
|
||||
only:
|
||||
refs:
|
||||
- dev
|
||||
script:
|
||||
- sh scripts/publish.sh beta
|
||||
|
||||
publish_latest:
|
||||
stage: publish
|
||||
only:
|
||||
refs:
|
||||
- master
|
||||
script:
|
||||
- sh scripts/publish.sh latest
|
||||
|
|
7
Makefile
7
Makefile
|
@ -1,4 +1,4 @@
|
|||
.PHONY: all install-js watch-js build-js publish-beta lint-js test-js create-messages update-messages docs clean
|
||||
.PHONY: all install-js watch-js build-js lint-js test-js create-messages update-messages docs clean
|
||||
|
||||
all:
|
||||
@echo "make install-js"
|
||||
|
@ -7,8 +7,6 @@ all:
|
|||
@echo " Compile JS in watch mode."
|
||||
@echo "make build-js"
|
||||
@echo " Compile JS."
|
||||
@echo "make publish-beta"
|
||||
@echo " Publish package with 'beta' tag"
|
||||
@echo "make lint-js"
|
||||
@echo " Run linter"
|
||||
@echo "make test-js"
|
||||
|
@ -32,9 +30,6 @@ watch-js:
|
|||
build-js:
|
||||
npm run build
|
||||
|
||||
publish-beta:
|
||||
npm publish --tag beta
|
||||
|
||||
lint:
|
||||
npm run lint
|
||||
|
||||
|
|
17
README.md
Normal file
17
README.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
# foris-js
|
||||
|
||||
## Publishing package
|
||||
|
||||
### Beta versions
|
||||
|
||||
Each commit to `dev` branch will result in publishing a new version of library
|
||||
tagged `beta`. Versions names are based on commit SHA, e.g.
|
||||
`foris@0.1.0-d9073aa4.0`.
|
||||
|
||||
### Preparing a release
|
||||
|
||||
1. Crete a merge request to `dev` branch with version bumped
|
||||
2. When merging add `[skip ci]` to commit message to prevent publishing
|
||||
unnecessary version
|
||||
3. Create a merge request from `dev` to `master` branch
|
||||
4. New version should be published automatically
|
22
scripts/publish.sh
Executable file
22
scripts/publish.sh
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
if test -z "$NPM_TOKEN"
|
||||
then
|
||||
echo "\$NPM_TOKEN is not set"
|
||||
exit 1
|
||||
else
|
||||
# Need to replace "_" with "_" as GitLab CI won't accept secret vars with "-"
|
||||
echo "//registry.npmjs.org/:_authToken=$(echo $NPM_TOKEN | tr _ -)" > .npmrc
|
||||
echo "unsafe-perm = true" >> ~/.npmrc
|
||||
if test "$1" = "beta"
|
||||
then
|
||||
npm version prerelease --preid=$CI_COMMIT_SHORT_SHA --git-tag-version false
|
||||
npm publish --tag beta
|
||||
elif test "$1" = "latest"
|
||||
then
|
||||
npm publish
|
||||
else
|
||||
echo "Usage: publish.sh [ beta | latest ]"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
Loading…
Reference in New Issue
Block a user