release 1.0.0 | /workflows/cd #3
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
name: safe-api-plugin-cd | |
on: | |
pull_request: | |
types: [closed] | |
branches: | |
- main | |
jobs: | |
cd: | |
name: safe-api-plugin-cd | |
if: | | |
github.event.pull_request.merged && | |
endsWith(github.event.pull_request.title, '/workflows/cd') != true && | |
github.event.pull_request.user.login != 'github-actions' | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Read .nvmrc | |
run: echo ::set-output name=NVMRC::$(cat .nvmrc) | |
id: nvm | |
- name: Read VERSION into env.RELEASE_VERSION | |
run: | | |
echo RELEASE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g') >> $GITHUB_ENV | |
- name: Is Pre-Release | |
run: | | |
STR="${RELEASE_VERSION}" | |
SUB='pre.' | |
if [[ "$STR" == *"$SUB"* ]]; then | |
echo PRE_RELEASE=true >> $GITHUB_ENV | |
else | |
echo PRE_RELEASE=false >> $GITHUB_ENV | |
fi | |
- name: Setup Node.js | |
uses: actions/setup-node@master | |
with: | |
node-version: '${{ steps.nvm.outputs.NVMRC }}' | |
- name: Install dependencies | |
run: yarn install --nonInteractive --frozen-lockfile --prefer-offline | |
- name: Build | |
run: yarn build | |
- name: Auth into NPM | |
run: | | |
npm config set registry https://registry.npmjs.org/ | |
npm config set //registry.npmjs.org/:_authToken=${{secrets.POLYWRAP_BUILD_BOT_NPM_PAT}} | |
echo $(npm whoami --registry https://registry.npmjs.org/) | |
- name: Publish To NPM (Latest) | |
if: env.PRE_RELEASE == 'false' | |
run: yarn publish:npm | |
env: | |
NPM_AUTH_TOKEN: ${{secrets.POLYWRAP_BUILD_BOT_NPM_PAT}} | |
- name: Publish Node Packages To NPM (Pre-Release) | |
if: env.PRE_RELEASE == 'true' | |
run: yarn publish:pre:npm | |
env: | |
NPM_AUTH_TOKEN: ${{secrets.POLYWRAP_BUILD_BOT_NPM_PAT}} |