2020-12-29 09:22:27 +00:00
|
|
|
name: "publish-release"
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- "main"
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
npm-publish:
|
|
|
|
name: "Publish"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
### Calculate FINAL_VERSION
|
|
|
|
- name: Install jq
|
|
|
|
run: sudo apt-get update && sudo apt-get --yes --force-yes install jq
|
|
|
|
|
|
|
|
- name: Get version from npm and increment
|
|
|
|
run: |
|
2020-12-29 09:44:29 +00:00
|
|
|
set -x
|
2020-12-29 09:22:27 +00:00
|
|
|
yarn global add semver
|
|
|
|
PATH="$(yarn global bin):$PATH"
|
2020-12-29 09:54:17 +00:00
|
|
|
|
|
|
|
# take npm version and increment it
|
2020-12-29 09:58:15 +00:00
|
|
|
PKG_NAME="$(cat package.json | jq -r .name)"
|
2020-12-29 09:22:27 +00:00
|
|
|
NPM_VERSION="$(yarn info --silent "$PKG_NAME" version || true)"
|
2020-12-29 09:54:17 +00:00
|
|
|
NEXT_NPM_VERSION="$(semver --increment patch "$NPM_VERSION")"
|
|
|
|
|
|
|
|
# take local version
|
|
|
|
LOCAL_VERSION="$(cat package.json | jq -r .version)"
|
|
|
|
|
|
|
|
# take maximum of the local and NEXT_NPM versions
|
|
|
|
MAX_VERSION="$(semver "$LOCAL_VERSION" "$NEXT_NPM_VERSION" "0.0.0" | tail -n1)"
|
|
|
|
|
|
|
|
# save version to env
|
|
|
|
echo "FINAL_VERSION=$MAX_VERSION" | tee -a $GITHUB_ENV
|
2020-12-29 09:22:27 +00:00
|
|
|
|
|
|
|
### Set version
|
|
|
|
- name: Set version to ${{ env.FINAL_VERSION }}
|
|
|
|
run: yarn version --new-version ${{ env.FINAL_VERSION }} --no-git-tag-version
|
|
|
|
|
2020-12-29 09:39:48 +00:00
|
|
|
### Publish to NPM registry
|
|
|
|
- uses: actions/setup-node@v1
|
2020-12-29 09:22:27 +00:00
|
|
|
with:
|
2020-12-29 09:39:48 +00:00
|
|
|
node-version: '14'
|
|
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
|
|
|
|
- run: npm publish --access public
|
|
|
|
env:
|
|
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
2020-12-29 09:22:27 +00:00
|
|
|
|
|
|
|
### Create a pre-release
|
|
|
|
- name: Create Release
|
|
|
|
id: create_release
|
|
|
|
uses: actions/create-release@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
tag_name: ${{ env.FINAL_VERSION }}
|
|
|
|
release_name: Fluence Network ${{ env.FINAL_VERSION }}
|
|
|
|
body: |
|
2020-12-29 10:07:15 +00:00
|
|
|
[${{ env.FINAL_VERSION }} @ NPM registry](https://www.npmjs.com/package/@fluencelabs/fluence-network-environment/v/${{ env.FINAL_VERSION }})
|
|
|
|
draft: false
|
|
|
|
prerelease: false
|