Skip to content

Publish Package to npmjs #42

Publish Package to npmjs

Publish Package to npmjs #42

Workflow file for this run

name: Publish Package to npmjs
on:
push:
tags:
- 'v*'
env:
VAULT_ADDR: https://vault.eng.aserto.com/
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Read Configuration
uses: hashicorp/vault-action@v3
id: vault
with:
url: ${{ env.VAULT_ADDR }}
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
kv/data/npmjs "NPM_TOKEN" | NODE_AUTH_TOKEN;
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
**/node_modules
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-cache-
- run: yarn install --immutable
- run: yarn npm publish --access public
bump_version:
runs-on: ubuntu-latest
needs: release
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.CODEGEN_APP_ID }}
private-key: ${{ secrets.CODEGEN_APP_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
ref: 'main'
# bump to the next patch version
- name: Bump version
id: bump_version
run: |
VERSION=$(npm version patch --no-git-tag-version)
echo $VERSION
echo "::set-output name=next_version::$VERSION"
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: 'Bump to ${{ steps.bump_version.outputs.next_version }} (CI)'
add: 'package.json'