-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
054dba5
commit 4213a4f
Showing
2 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Build and publish | ||
on: | ||
push: | ||
branches: | ||
- stable | ||
- develop | ||
- beta | ||
|
||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- name: Set version and branch | ||
run: | | ||
export BRANCH=${GITHUB_REF##*/} | ||
export VERSION=$(bash ./scripts/calculate.sh) | ||
echo "::set-env name=VERSION::$VERSION" | ||
echo "::set-env name=BRANCH::$BRANCH" | ||
echo "Version $VERSION" | ||
echo ${{ secrets.GITHUB_TOKEN }} | ||
- name: Publish on npm | ||
if: github.ref != 'refs/heads/stable' | ||
run: | | ||
npm version --no-git-tag-version ${{ env.VERSION }} | ||
npm publish --access public --tag ${{ env.BRANCH }} | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- name: Publish on npm (stable) | ||
if: github.ref == 'refs/heads/stable' | ||
run: | | ||
npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- name: Create Release | ||
if: github.ref != 'refs/heads/stable' | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ env.VERSION }} | ||
release_name: ${{ env.VERSION }} | ||
draft: false | ||
prerelease: true | ||
- name: Create Release (stable) | ||
if: github.ref == 'refs/heads/stable' | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ env.VERSION }} | ||
release_name: ${{ env.VERSION }} | ||
draft: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
VERSION=$(npm run --silent version) | ||
USAGE_MSG='Usage: BRANCH=[BRANCH] calculate_version.sh' | ||
|
||
if [ -z "$BRANCH" ]; then | ||
(>&2 echo 'You should provide branch') | ||
echo $USAGE_MSG | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$VERSION" ]; then | ||
echo "The base version is not set." | ||
exit 1 | ||
fi | ||
|
||
if [[ $BRANCH == 'master' ]]; then | ||
echo $VERSION | ||
exit 1 | ||
fi | ||
|
||
if [[ $BRANCH == 'stable' ]]; then | ||
echo $VERSION | ||
exit 0 | ||
fi | ||
|
||
git fetch --tags > /dev/null | ||
|
||
for (( NUMBER=0; ; NUMBER++ )) | ||
do | ||
FULL_VERSION="$VERSION-$BRANCH.$NUMBER" | ||
if ! [[ $(git tag -l | grep $FULL_VERSION) ]]; then | ||
echo "$FULL_VERSION" | tr / - | ||
break | ||
fi | ||
done |