-
Notifications
You must be signed in to change notification settings - Fork 43
170 lines (149 loc) · 6.16 KB
/
Copy pathpublish_design_tokens.yaml
File metadata and controls
170 lines (149 loc) · 6.16 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Publish @bcgov/design-tokens to npm and GitHub Packages
on:
pull_request:
paths:
- packages/design-tokens/**
branches: [main]
types: [closed]
release:
types: [published]
jobs:
build:
if: ${{ (github.event.pull_request.merged == true && github.repository == 'bcgov/design-system') || (github.event_name == 'release' && contains(github.event.release.tag_name, 'bcgov/design-tokens')) }}
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
node-version: ${{ steps.nvmrc.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Read .nvmrc
id: nvmrc
run: echo "version=$(cat .nvmrc)" >> $GITHUB_OUTPUT
working-directory: ./packages/design-tokens
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ steps.nvmrc.outputs.version }}
- name: Install dependencies
run: npm ci
working-directory: ./packages/design-tokens
- name: Install jq
if: ${{ github.event.pull_request.merged == true }}
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
# Append PR number to version number in dist/package.json
- name: Update version in dist/package.json
if: ${{ github.event.pull_request.merged == true }}
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: Upload build artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: design-tokens-build
path: packages/design-tokens/dist
publish-design-tokens-npm-next:
name: Publish @bcgov/design-tokens@next to npm
needs: build
if: ${{ github.event.pull_request.merged == true && github.repository == 'bcgov/design-system' }}
permissions:
contents: read
id-token: write # Required for OIDC
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: design-tokens-build
path: packages/design-tokens/dist
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ needs.build.outputs.node-version }}
registry-url: "https://registry.npmjs.org/"
- name: Publish to npm @next
run: npm publish --tag next --provenance
working-directory: ./packages/design-tokens/dist
publish-design-tokens-github-packages-next:
name: Publish @bcgov/design-tokens@next to GitHub Packages
needs: build
if: ${{ github.event.pull_request.merged == true && github.repository == 'bcgov/design-system' }}
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: design-tokens-build
path: packages/design-tokens/dist
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ needs.build.outputs.node-version }}
registry-url: "https://npm.pkg.github.com/"
scope: "@bcgov"
- name: Publish to GitHub Packages @next
run: npm publish --tag next --registry=https://npm.pkg.github.com/
working-directory: ./packages/design-tokens/dist
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-design-tokens-npm-latest:
name: Publish @bcgov/design-tokens@latest to npm
needs: build
if: ${{ github.event_name == 'release' && contains(github.event.release.tag_name, 'bcgov/design-tokens') }}
permissions:
contents: read
id-token: write # Required for OIDC
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: design-tokens-build
path: packages/design-tokens/dist
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ needs.build.outputs.node-version }}
registry-url: "https://registry.npmjs.org/"
- name: Publish to npm @latest
run: npm publish --tag latest --provenance
working-directory: ./packages/design-tokens/dist
publish-design-tokens-github-packages-latest:
name: Publish @bcgov/design-tokens@latest to GitHub Packages
needs: build
if: ${{ github.event_name == 'release' && contains(github.event.release.tag_name, 'bcgov/design-tokens') }}
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: design-tokens-build
path: packages/design-tokens/dist
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ needs.build.outputs.node-version }}
registry-url: "https://npm.pkg.github.com/"
scope: "@bcgov"
- name: Publish to GitHub Packages
run: npm publish --registry=https://npm.pkg.github.com/
working-directory: ./packages/design-tokens/dist
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}