Skip to content

Upgrade yarn to v4.10.3 (#297) #125

Upgrade yarn to v4.10.3 (#297)

Upgrade yarn to v4.10.3 (#297) #125

Workflow file for this run

name: publish-npm
on:
push:
branches:
- main
permissions: {}
jobs:
npm-publish:
name: Publish to NPM & GitHub Package Registry
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# id-token: write required for get-vault-secrets and trusted publishing
id-token: write
outputs:
new_version: ${{ steps.version_check.outputs.version }}
version_changed: ${{ steps.version_check.outputs.changed }}
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
ref: main
persist-credentials: false
# limit releases to version changes - https://github.com/EndBug/version-check
- name: Check version changes
uses: EndBug/version-check@5102328418c0130d66ca712d755c303e93368ce2 # v2.1.7
id: version_check
with:
file-url: https://unpkg.com/@grafana/aws-sdk@latest/package.json
static-checking: localIsNew
- name: Version update detected
env:
VERSION: ${{ steps.version_check.outputs.version }}
TYPE: ${{ steps.version_check.outputs.type }}
if: steps.version_check.outputs.changed == 'true'
run: 'echo "Version change found! New version: ${VERSION} (${TYPE})"'
- name: Setup .npmrc file for NPM registry
if: steps.version_check.outputs.changed == 'true'
uses: actions/setup-node@v5
with:
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
run: npm install -g npm@^11.5.1
- name: Install dependencies
if: steps.version_check.outputs.changed == 'true'
run: yarn
- name: Build library
if: steps.version_check.outputs.changed == 'true'
run: yarn build
- name: Publish package to NPM
if: steps.version_check.outputs.changed == 'true'
run: npm publish --access public --scope grafana
- name: Setup .npmrc file for GitHub Packages
if: steps.version_check.outputs.changed == 'true'
uses: actions/setup-node@v5
with:
node-version-file: '.nvmrc'
registry-url: 'https://npm.pkg.github.com'
scope: '@grafana'
- name: Publish package to Github Packages
if: steps.version_check.outputs.changed == 'true'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: npm-publish
if: needs.npm-publish.outputs.version_changed == 'true'
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Create Release Notes
uses: actions/[email protected]
env:
TAG_NAME: 'v${{ needs.npm-publish.outputs.new_version }}'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { TAG_NAME } = process.env
await github.request(`POST /repos/${{ github.repository }}/releases`, {
tag_name: `${TAG_NAME}`,
generate_release_notes: true
});