Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ on:
branches:
- main

permissions: {}

jobs:
npm-publish:
name: Publish to NPM & GitHub Package Registry
runs-on: ubuntu-latest
# Required for this workflow to have permission to publish NPM packages
environment: release
outputs:
new_version: ${{ steps.version_check.outputs.version }}
version_changed: ${{ steps.version_check.outputs.changed }}
permissions:
contents: write
# id-token: write is required for the get-vault-secrets step
# id-token: write required for npm trusted publishing
id-token: write
steps:
- name: Checkout repository
Expand Down Expand Up @@ -43,6 +47,10 @@ jobs:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'

- name: Install npm version ^11.5.1 # npm trusted publishing requires version ^11.5.1
if: steps.version_check.outputs.changed == 'true'
run: npm install -g npm@^11.5.1

- name: Install dependencies
if: steps.version_check.outputs.changed == 'true'
run: yarn
Expand All @@ -51,18 +59,9 @@ jobs:
if: steps.version_check.outputs.changed == 'true'
run: yarn build

- name: Get secrets from vault
id: get-secrets
uses: grafana/shared-workflows/actions/get-vault-secrets@main
with:
repo_secrets: |
NPM_TOKEN=npm-release:npm_token

- name: Publish package to NPM
if: steps.version_check.outputs.changed == 'true'
run: npm publish --access public --scope grafana
env:
NODE_AUTH_TOKEN: ${{ env.NPM_TOKEN }}
run: npm publish --access public

- name: Setup .npmrc file for GitHub Packages
if: steps.version_check.outputs.changed == 'true'
Expand Down