Skip to content

Build and Deploy Packages to NPM manually #13

Build and Deploy Packages to NPM manually

Build and Deploy Packages to NPM manually #13

name: Build and Deploy Packages to NPM manually
on:
workflow_dispatch:
permissions:
contents: read
jobs:
build-and-publish-to-npm:
runs-on: ubuntu-latest
steps:
#############################################################################
# common steps
#############################################################################
- uses: actions/checkout@v7.0.0
- name: use node.js 24.x
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24.x"
registry-url: https://registry.npmjs.org/ # Needed for auth
- name: yarn install
run: |
yarn install
- name: validate config
run: yarn backstage-cli config:check --lax
- name: lint
run: yarn backstage-cli repo lint
- name: type checking and declarations
run: yarn tsc:full
- name: build
run: yarn workspaces foreach --all -v --no-private run build
- name: verify type dependencies
run: yarn tsc:full && yarn lint:all
#############################################################################
# publish a plugin to npm
#############################################################################
- name: change infrakitchen plugin version to `semver-sha` for PR
working-directory: ./plugins/infrakitchen
run: |
VERSION=$(npm pkg get version --workspaces=false | tr -d \")
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
npm pkg set version=$VERSION
else
npm pkg set version=$VERSION-$(echo ${{ github.sha }} | cut -c 1-7)
fi
- name: publish
run: |
yarn config set -H 'npmAuthToken' "${{secrets.NPM_TOKEN}}"
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
yarn workspaces foreach -v -A --no-private npm publish --access public --tolerate-republish
else
yarn workspaces foreach -v -A --no-private npm publish --access public --tolerate-republish --tag rc
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}