save #298
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: Publish | |
on: | |
push: | |
branches: | |
- master | |
- develop | |
pull_request: | |
branches: | |
- master | |
- develop | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: 18 | |
- name: Install | |
run: yarn | |
- name: Build | |
run: yarn build | |
- name: Test | |
run: yarn test --detectOpenHandles --forceExit | |
- name: Setup Custom Contexts | |
shell: bash | |
run: | | |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})" | |
echo "##[set-output name=version;]$(cat ./package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')" | |
echo "##[set-output name=short_sha;]$(git rev-parse --short HEAD)" | |
id: job_context | |
- name: Make snapshot version | |
if: steps.job_context.outputs.branch != 'master' | |
run: | | |
npm version prerelease --preid=${{ steps.job_context.outputs.short_sha }} --git-tag-version false | |
working-directory: ${{env.working-directory}} | |
- name: Publish package to latest | |
if: steps.job_context.outputs.branch == 'master' | |
working-directory: ${{env.working-directory}} | |
run: | | |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} | |
npm publish --ignore-scripts --access public | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Publish package to branch-tag | |
if: steps.job_context.outputs.branch != 'master' | |
working-directory: ${{env.working-directory}} | |
run: | | |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} | |
npm publish --ignore-scripts --access public --tag $(echo "develop-${{ steps.job_context.outputs.version }}-rc" | sed 's/[.]//g') | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |