-
Notifications
You must be signed in to change notification settings - Fork 7
163 lines (148 loc) · 5.27 KB
/
publish-web.yml
File metadata and controls
163 lines (148 loc) · 5.27 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
name: Publish Web
on:
workflow_dispatch:
inputs:
package:
description: 'Select the package you want to publish'
required: true
default: 'dialtone'
type: 'choice'
options:
- dialtone
- dialtone-css
- dialtone-emojis
- dialtone-icons
- dialtone-tokens
- dialtone-vue
- eslint-plugin-dialtone
- stylelint-plugin-dialtone
- postcss-responsive-variations
- dialtone-mcp-server
push:
branches:
- production
- alpha
- beta
- next
paths:
- '**/package.json'
env:
HUSKY: 0
jobs:
variables-setup:
runs-on: ubuntu-latest
outputs:
current_branch: ${{ steps.branch-name.outputs.current_branch }}
release_tag: ${{ steps.branch-name.outputs.current_branch == 'production' && 'latest' || steps.branch-name.outputs.current_branch }}
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v8
filter-actions:
runs-on: ubuntu-latest
outputs:
packages: ${{ github.event_name == 'push' && steps.filter-path.outputs.changes || steps.filter-input.outputs.package }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Filter actions by path
if: ${{ github.event_name == 'push' }}
uses: dorny/paths-filter@v3
id: filter-path
with:
base: ${{ github.ref }}
list-files: 'json'
filters: |
dialtone:
- 'package.json'
dialtone-css:
- 'packages/dialtone-css/package.json'
dialtone-emojis:
- 'packages/dialtone-emojis/package.json'
dialtone-icons:
- 'packages/dialtone-icons/package.json'
dialtone-tokens:
- 'packages/dialtone-tokens/package.json'
dialtone-vue:
- 'packages/dialtone-vue/package.json'
eslint-plugin-dialtone:
- 'packages/eslint-plugin-dialtone/package.json'
stylelint-plugin-dialtone:
- 'packages/stylelint-plugin-dialtone/package.json'
postcss-responsive-variations:
- 'packages/postcss-responsive-variations/package.json'
dialtone-mcp-server:
- 'packages/dialtone-mcp-server/package.json'
- name: Filter actions by input
if: ${{ github.event_name == 'workflow_dispatch' }}
id: filter-input
run: |
echo 'package=["${{ github.event.inputs.package }}"]' >> $GITHUB_OUTPUT
check-dialpad-member:
runs-on: ubuntu-latest
steps:
# Will prevent the rest of the steps from running on fail
- name: Check if user is a dialpad member
uses: octokit/request-action@v2.x
with:
route: GET /orgs/dialpad/members/${{ github.actor }}
env:
GITHUB_TOKEN: ${{ secrets.DIALTONE_CI_TOKEN }}
publish:
needs: [ variables-setup, check-dialpad-member, filter-actions ]
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && needs.filter-actions.outputs.packages != '[]') }}
strategy:
fail-fast: false
matrix:
package: ${{ fromJSON(needs.filter-actions.outputs.packages) }}
registry: [ npm, GitHub ]
include:
- registry: GitHub
registry_url: //npm.pkg.github.com/
- registry: npm
registry_url: //registry.npmjs.org/
runs-on: ubuntu-latest
permissions:
packages: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Environment
uses: ./.github/actions/setup-environment
- name: Configure npm registry for publishing
if: matrix.registry == 'npm'
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
registry-url: "https://registry.npmjs.org"
- name: Remove @dialpad scope configuration for npm
if: matrix.registry == 'npm'
run: |
# Remove @dialpad scope configuration to use default npm registry instead of GitHub Packages
npm config delete @dialpad:registry || true
- name: Configure GitHub Packages for publishing
if: matrix.registry == 'GitHub'
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
registry-url: "https://npm.pkg.github.com"
scope: "@dialpad"
- name: Configure @dialpad scope for GitHub Packages
if: matrix.registry == 'GitHub'
run: |
# Set @dialpad scope to use GitHub Packages instead of npm
npm config set @dialpad:registry https://npm.pkg.github.com/
- name: Delay job to avoid npm rate limits
if: matrix.package == 'dialtone-vue'
run: sleep 15s
shell: bash
# Publish npm/GitHub
- name: Publish ${{ matrix.package }}@${{ env.RELEASE_TAG }}
env:
RELEASE_TAG: ${{ needs.variables-setup.outputs.release_tag }}
NODE_AUTH_TOKEN: ${{ matrix.registry == 'GitHub' && secrets.GITHUB_TOKEN || '' }}
run: >
pnpm nx run ${{ matrix.package }}:publish
--publish-branch=${{ needs.variables-setup.outputs.current_branch }}
--tag=${{ env.RELEASE_TAG }}