PWABuilder CLI Main CI/CD #18
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: PWABuilder CLI Main CI/CD | |
on: | |
push: | |
paths: | |
-"apps/cli/**" | |
branches: | |
-main | |
-starter-cli-dev | |
pull_request: | |
paths: | |
-"apps/cli/**" | |
branches: | |
-main | |
-starter-cli-dev | |
workflow_dispatch: | |
jobs: | |
version: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: apps/cli | |
outputs: | |
latest-version: ${{steps.latest-version.outputs.version}} | |
package-version: ${{steps.package-version.outputs.current-version}} | |
strategy: | |
matrix: | |
node-version: [16.x] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
registry-url: 'https://registry.npmjs.org' | |
- name: Get latest version from npm | |
id: latest-version | |
run: echo ::set-output name=version::$(npm show @pwabuilder/cli version) | |
- name: Get current package version | |
id: package-version | |
uses: martinbeentjes/npm-get-version-action@master | |
publish: | |
runs-on: ubuntu-latest | |
needs: version | |
if: needs.version.outputs.latest-version != needs.version.outputs.package-version | |
defaults: | |
run: | |
working-directory: apps/cli | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
# Setup .npmrc file to publish to npm | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '16.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Replace tokens | |
# You may pin to the exact commit or the version. | |
# uses: cschleiden/replace-tokens@4f7e3d67f3ff2317ae650842145cdbaefba65189 | |
uses: cschleiden/replace-tokens@v1.1 | |
with: | |
files: '["**/usage-analytics.ts"]' | |
env: | |
ANALYTICS_CODE: ${{secrets.CLI_ANALYTICS_CODE}} | |
- name: Build | |
run: | | |
npm install | |
- name: Publish | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH }} |