Skip to content

Algoan PubSub Test and Publish Workflow #261

Algoan PubSub Test and Publish Workflow

Algoan PubSub Test and Publish Workflow #261

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Algoan PubSub Test and Publish Workflow
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
inputs:
ref:
description: 'Branch, tag or commit SHA1 to build'
required: false
type: string
default: master
jobs:
test:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
version: [
{ node: "16.x", npm: "8" },
{ node: "18.x", npm: "10" },
{ node: "20.x", npm: "10" }
]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.version.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.version.node }}
cache: 'npm'
- name: Get GCloud CLI to install pubsub emulator
uses: google-github-actions/setup-gcloud@v0
- name: Update GCloud Components
run: gcloud components update --quiet
- name: Install GCloud beta
run: gcloud components install beta --quiet
- name: Install pubsub-emulator
run: gcloud components install pubsub-emulator --quiet
- run: npm i -g npm@${{ matrix.version.npm }}
- run: npm i
- run: npm run cover
publish:
runs-on: ubuntu-latest
name: Publish @algoan/pubsub to NPM
needs:
- test
if: ${{ github.event_name == 'workflow_dispatch' }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ inputs.ref }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'npm'
- run: npm i -g npm
- run: npm ci
- run: npm run compile
- run: npm run semantic-release
name: Run Semantic Release
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT_SEMANTIC_RELEASE }}
GITHUB_NPM_CONFIG_REGISTRY: https://npm.pkg.github.com/
GITHUB_NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_NPM_CONFIG_REGISTRY: https://registry.npmjs.org/
NPM_NPM_TOKEN: ${{ secrets.NPM_TOKEN }}