# Copyright 2022 Google LLC # # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file or at # https://developers.google.com/open-source/licenses/bsd # A workflow to release Shaka Packager to NPM. name: NPM Release # Runs when a new release is published on GitHub. # Creates a corresponding NPM release and publishes it. # # Can also be run manually for debugging purposes. on: release: types: [published] # For manual debugging: workflow_dispatch: inputs: ref: description: "The tag to release to NPM." required: True jobs: publish_npm: name: Publish to NPM runs-on: ubuntu-latest steps: - name: Compute ref id: ref # We could be building from a workflow dispatch (manual run), or a # release event. Subsequent steps can refer to $TARGET_REF to # determine the correct ref in all cases. run: | echo "TARGET_REF=${{ github.event.inputs.ref || github.event.release.tag_name }}" >> $GITHUB_ENV - name: Checkout code uses: actions/checkout@v2 with: ref: ${{ env.TARGET_REF }} - name: Setup NodeJS uses: actions/setup-node@v1 with: node-version: 10 - name: Set package name and version run: | cd npm sed package.json -i \ -e 's/"name": ""/"name": "${{ secrets.NPM_PACKAGE_NAME }}"/' \ -e 's/"version": ""/"version": "${{ env.TARGET_REF }}"/' - name: Publish NPM package uses: JS-DevTools/npm-publish@v1 with: token: ${{ secrets.NPM_CI_TOKEN }} package: npm/package.json check-version: false access: public