fix for polywrap binary artifact upload in CD #276
Workflow file for this run
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: CD-Javascript | |
on: | |
# When Pull Request is merged | |
pull_request_target: | |
types: [closed] | |
jobs: | |
Publish-NPM: | |
name: Publish javascript packages to npmjs.com | |
if: | | |
github.event.pull_request.user.login == 'polywrap-build-bot' && | |
github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.base.ref }} | |
- name: Read VERSION into env.RELEASE_VERSION | |
run: echo RELEASE_VERSION=$(cat VERSION) >> $GITHUB_ENV | |
- name: Read .nvmrc into env.NVMRC | |
run: echo NVMRC=$(cat .nvmrc) >> $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@v1 | |
with: | |
node-version: '${{env.NVMRC}}' | |
- 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: Install JS dependencies | |
run: yarn install --nonInteractive --frozen-lockfile | |
- name: Build JS packages | |
run: yarn build | |
- name: Publish Node Packages 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}} | |
- uses: actions/github-script@0.8.0 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
github.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '**[NPM Release Published](https://www.npmjs.com/search?q=polywrap) `${{env.RELEASE_VERSION}}`** 🎉' | |
}) |