-
Notifications
You must be signed in to change notification settings - Fork 10
219 lines (194 loc) Β· 8.56 KB
/
Copy pathpublishComponents.yml
File metadata and controls
219 lines (194 loc) Β· 8.56 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
name: Node.js Publish UI Packages
on:
push:
branches: [ 'develop' ]
paths:
- 'react/react-components/**'
- 'react/svg-components/**'
- 'react/ui-components/**'
- 'react/libraries/**'
jobs:
setup-python-and-build-tools:
name: Set up Python and Build Tools
runs-on: ubuntu-latest
steps:
- name: Update apt and install Python 3 and build tools
run: |
sudo apt-get update
sudo apt-get install -y python3 python3-pip python3-setuptools build-essential
sudo apt-get install -y python3-distutils || sudo apt-get install -y python3-dev
# Step 1: Publish base packages with no internal dependencies
publish-base-packages:
name: Publish Base Packages (Libraries & SVG Components)
runs-on: ubuntu-latest
needs: setup-python-and-build-tools
outputs:
libraries-version: ${{ steps.get-versions.outputs.libraries-version }}
svg-version: ${{ steps.get-versions.outputs.svg-version }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
# Get package versions for later use
- name: Get package versions
id: get-versions
run: |
LIBRARIES_VERSION=$(node -p "require('./react/libraries/package.json').version")
SVG_VERSION=$(node -p "require('./react/svg-components/package.json').version")
echo "libraries-version=$LIBRARIES_VERSION" >> $GITHUB_OUTPUT
echo "svg-version=$SVG_VERSION" >> $GITHUB_OUTPUT
echo "π¦ Libraries version: $LIBRARIES_VERSION"
echo "π¦ SVG Components version: $SVG_VERSION"
# Publish libraries package
- name: Publish Libraries Package
continue-on-error: true
run: |
echo "π Publishing @egovernments/digit-ui-libraries..."
cd react/libraries/
rm -rf node_modules yarn.lock package-lock.json
yarn install --frozen-lockfile
npm publish --tag react-19
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
# Publish SVG components package
- name: Publish SVG Components Package
continue-on-error: true
run: |
echo "π Publishing @egovernments/digit-ui-svg-components..."
cd react/svg-components/
rm -rf node_modules yarn.lock package-lock.json
yarn install --frozen-lockfile
npm publish --tag react-19
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
# Step 2: Wait for base packages to be available on npm, then publish ui-components
publish-ui-components:
name: Publish UI Components
runs-on: ubuntu-latest
needs: publish-base-packages
outputs:
ui-version: ${{ steps.get-ui-version.outputs.ui-version }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- name: Get UI Components version
id: get-ui-version
run: |
UI_VERSION=$(node -p "require('./react/ui-components/package.json').version")
echo "ui-version=$UI_VERSION" >> $GITHUB_OUTPUT
echo "π¦ UI Components version: $UI_VERSION"
# Wait for dependencies to be available on npm
- name: Wait for dependencies to be available
run: |
echo "β³ Waiting for dependencies to be available on npm..."
# Function to check if package version is available
check_package() {
local package_name=$1
local version=$2
local max_attempts=30
local attempt=1
echo "π Checking availability of $package_name@$version..."
while [ $attempt -le $max_attempts ]; do
if npm view "$package_name@$version" version &>/dev/null; then
echo "β
$package_name@$version is available!"
return 0
else
echo "β³ Attempt $attempt/$max_attempts: $package_name@$version not yet available..."
sleep 30
((attempt++))
fi
done
echo "β $package_name@$version is still not available after $max_attempts attempts"
return 1
}
# Check both dependencies
check_package "@egovernments/digit-ui-libraries" "${{ needs.publish-base-packages.outputs.libraries-version }}"
check_package "@egovernments/digit-ui-svg-components" "${{ needs.publish-base-packages.outputs.svg-version }}"
# Publish UI components package
- name: Publish UI Components Package
continue-on-error: true
run: |
echo "π Publishing @egovernments/digit-ui-components..."
cd react/ui-components/
rm -rf node_modules yarn.lock package-lock.json
yarn install --frozen-lockfile
npm publish --tag react-19
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
# Step 3: Wait for ui-components to be available, then publish react-components
publish-react-components:
name: Publish React Components
runs-on: ubuntu-latest
needs: [publish-base-packages, publish-ui-components]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
# Wait for all dependencies to be available on npm
- name: Wait for dependencies to be available
run: |
echo "β³ Waiting for all dependencies to be available on npm..."
# Function to check if package version is available
check_package() {
local package_name=$1
local version=$2
local max_attempts=30
local attempt=1
echo "π Checking availability of $package_name@$version..."
while [ $attempt -le $max_attempts ]; do
if npm view "$package_name@$version" version &>/dev/null; then
echo "β
$package_name@$version is available!"
return 0
else
echo "β³ Attempt $attempt/$max_attempts: $package_name@$version not yet available..."
sleep 30
((attempt++))
fi
done
echo "β $package_name@$version is still not available after $max_attempts attempts"
return 1
}
# Check all dependencies
check_package "@egovernments/digit-ui-svg-components" "${{ needs.publish-base-packages.outputs.svg-version }}"
check_package "@egovernments/digit-ui-components" "${{ needs.publish-ui-components.outputs.ui-version }}"
# Publish react components package
- name: Publish React Components Package
continue-on-error: true
run: |
echo "π Publishing @egovernments/digit-ui-react-components..."
cd react/react-components/
rm -rf node_modules yarn.lock package-lock.json
yarn install --frozen-lockfile
npm publish --tag react-19
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
# Final step: Summary
publish-summary:
name: Publish Summary
runs-on: ubuntu-latest
needs: [publish-base-packages, publish-ui-components, publish-react-components]
if: always()
steps:
- name: Publish Summary
run: |
echo "π Package Publishing Summary:"
echo "================================"
echo "β
@egovernments/digit-ui-libraries@${{ needs.publish-base-packages.outputs.libraries-version }}"
echo "β
@egovernments/digit-ui-svg-components@${{ needs.publish-base-packages.outputs.svg-version }}"
echo "β
@egovernments/digit-ui-components@${{ needs.publish-ui-components.outputs.ui-version }}"
echo "β
@egovernments/digit-ui-react-components - Published successfully"
echo ""
echo "π All packages published in the correct dependency order!"
echo ""
echo "π¦ Installation commands:"
echo "npm install @egovernments/digit-ui-libraries@${{ needs.publish-base-packages.outputs.libraries-version }}"
echo "npm install @egovernments/digit-ui-svg-components@${{ needs.publish-base-packages.outputs.svg-version }}"
echo "npm install @egovernments/digit-ui-components@${{ needs.publish-ui-components.outputs.ui-version }}"
echo "npm install @egovernments/digit-ui-react-components@latest"