Skip to content

Rush publish to NPM #220

Rush publish to NPM

Rush publish to NPM #220

Workflow file for this run

name: Rush publish to NPM
on: workflow_dispatch
env:
BROWSERSLIST_IGNORE_OLD_DATA: 1
jobs:
# Set the job key. The key is displayed as the job name
# when a job name is not provided
npm-publish:
# Name the Job
name: Rush publish apply
# Set the type of machine to run on
runs-on: ubuntu-latest
environment: Production
outputs:
changedPackages: ${{ steps.list-changed.outputs.changedPackages }}
numChangedPackages: ${{ steps.list-changed.outputs.numChangedPackages }}
steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
token: ${{ secrets.GH_PAT }}
- uses: actions/setup-node@v3
with:
node-version: 18.x
- name: PNPM cache via actions/cache@v3
id: pnpm-cache
uses: actions/cache@v3
with:
path: /home/runner/work/design-system/design-system/common/temp/pnpm-store/v3
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Install dependencies
run: node common/scripts/install-run-rush.js install
- name: Build components
run: node common/scripts/install-run-rush.js build --timeline
- name: Git set author name
run: git config --global user.name "Priceline DS Publish Bot"
- name: Git set author email
run: git config --global user.email "uxplatformdevs@priceline.com"
# Apply changes and git add so the list-changed step detects projects that have changes. MUST NOT
# commit changes back to main branch before detecting changed projects.
- name: rush apply versions
run: |
node common/scripts/install-run-rush.js publish --apply --add-commit-details
git add -A
# List projects with changes then git reset. We'll apply changes and merge them to main in the next step.
- name: List changed packages
id: list-changed
run: |
node common/scripts/install-run-rush.js list-changed-packages
git reset --hard
- name: publish npm-package
run: |
node common/scripts/install-run-rush.js publish --apply --add-commit-details --target-branch="main"
node common/scripts/install-run-rush.js publish --publish --include-all --target-branch="main" --npm-auth-token="${{ secrets.NPM_AUTOMATION_TOKEN }}"
create-github-releases:
needs: npm-publish
runs-on: ubuntu-latest
if: ${{ fromJSON(needs.npm-publish.outputs.numChangedPackages) }} > 0
strategy:
matrix: ${{ fromJSON(needs.npm-publish.outputs.changedPackages) }}
steps:
- uses: actions/github-script@v6
name: Create GitHub release for ${{ matrix.projects }}
env:
project: ${{ matrix.projects }}
with:
github-token: ${{ secrets.DS_RELEASE_PAT }}
script: |
const { project } = process.env
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/heads/main',
workflow_id: 'release-branch.yaml',
inputs: {
packageName: project
}
});