-
Notifications
You must be signed in to change notification settings - Fork 40
73 lines (61 loc) · 2.44 KB
/
publish_design_tokens.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Publish @bcgov/design-tokens to npm @next
on:
pull_request:
paths:
- packages/design-tokens/**
branches: [main]
types: [closed]
jobs:
publish-design-tokens:
name: Publish @bcgov/design-tokens@next
# Only run on merge, not close without merge AND
# only run in bcgov/design-system repo, not forks.
if: ${{ github.event.pull_request.merged == true && github.repository == 'bcgov/design-system' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Read .nvmrc
run: echo "GITHUB_NVMRC_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV
working-directory: ./packages/design-tokens
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.GITHUB_NVMRC_VERSION }}
- name: Install dependencies
run: npm install
working-directory: ./packages/design-tokens
- name: Install jq
run: sudo apt-get install -y jq
- name: Run build script
run: npm run build
working-directory: ./packages/design-tokens
- name: Prepare npm package for publishing
run: npm run prepare-npm-package
working-directory: ./packages/design-tokens
- name: Set up .npmrc configuration
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
# Use `jq` to change the package.json version to look like:
#
# <version in package.json>-pr<PR # that caused the workflow run>
#
# So package.json version v1.2.3 with a run caused by merging PR #456 to
# `main` causes the version of the package on npm to look like:
#
# 1.2.3-pr456
#
# This is to ensure that it's easy to map an npm version to a particular PR.
#
- name: Update version in dist/package.json
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
CURRENT_VERSION=$(jq -r '.version' package.json)
NEW_VERSION="${CURRENT_VERSION}-pr${PR_NUMBER}"
jq --arg new_version "$NEW_VERSION" '.version = $new_version' package.json > tmp.json && mv tmp.json package.json
shell: bash
working-directory: ./packages/design-tokens/dist
- name: Publish to npm with @next tag
run: npm run publish-npm-package -- --access public --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: ./packages/design-tokens