-
Notifications
You must be signed in to change notification settings - Fork 600
215 lines (187 loc) · 7 KB
/
packages_publishing.yml
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
name: Publishing to GitHub Packages
on:
workflow_dispatch:
inputs:
tag:
description: "Choose a tag: 'daily' when publishing a daily build with a timestamp version, 'stable' when publishing a stable build from a release branch"
type: choice
options:
- daily
- stable
default: 'daily'
required: false
filter:
type: string
description: Package file filter pattern
required: false
env:
NX_SKIP_NX_CACHE: true
FILTER: ${{ github.event_name == 'workflow_dispatch' && inputs.filter || '' }}
SET_TIMESTAMP_VERSION: ${{ inputs.tag == 'daily' }}
MOVE_DAILY_TAG: ${{ inputs.tag == 'daily' }}
MOVE_STABLE_TAG: ${{ inputs.tag == 'stable' }}
jobs:
build:
name: Build packages
runs-on: windows-latest
outputs:
packages: ${{ steps.filter.outputs.packages }}
steps:
- name: Get sources
uses: actions/checkout@v4
- name: Set up nodejs
uses: actions/setup-node@v4
with:
node-version: '20'
- uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: |
${{ env.STORE_PATH }}
.nx/cache
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store
- name: Install dependencies
run: |
corepack enable
pnpm install
- name: Set timestamp version
if: ${{ env.SET_TIMESTAMP_VERSION == 'true' }}
run: pnpx ts-node tools/scripts/set-timestamp-version
- name: Build npm packages
env:
BUILD_INTERNAL_PACKAGE: true
run: pnpm run all:build
# - name: Clone deps scanner
# uses: actions/checkout@v4
# with:
# repository: DevExpress/npmdeps-scanner
# token: ${{ secrets.NPM_DEPS_SCANNER_PAT }}
# path: deps-scanner
#
# - name: Run deps scanner
# run: |
# ./deps-scanner/exe/npmDepsScanner.exe scan_cache ${{ github.workspace }} reportGithub.json
# mkdir -p ./artifacts/deps-scanner
# cp reportGithub.json ./artifacts/deps-scanner/
- name: Build artifacts package
run: npx ts-node tools/scripts/make-artifacts-package
- uses: actions/upload-artifact@v3
with:
name: packages
path: artifacts/npm/*.tgz
retention-days: 2
- name: Filter packages
id: filter
working-directory: artifacts/npm
shell: bash
run: ls *.tgz | grep -E -i "$FILTER" | sed -r 's/^(.*).tgz$/"\1"/g' | paste -sd "," - | sed -r 's/(.*)/packages=[\1]/' >> "$GITHUB_OUTPUT"
publish:
name: Publish package
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
package: ${{ fromJSON(needs.build.outputs.packages) }}
steps:
- name: Get sources
uses: actions/checkout@v4
with:
sparse-checkout: |
/tools
/packages/devextreme-monorepo-tools
package.json
sparse-checkout-cone-mode: false
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: packages
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: |
${{ env.STORE_PATH }}
.nx/cache
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store
- name: Install dependencies
run: |
corepack enable
pnpm install
- name: Change package scope
id: scopedPackage
env:
PACKAGE: ${{ matrix.package }}
run: |
SCOPE=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]');
PACKAGE_DIR=$(npx ts-node tools/scripts/change-package-scope --tgz $PACKAGE.tgz --scope $SCOPE)
echo "packageDir=$PACKAGE_DIR" >> "$GITHUB_OUTPUT";
cd $PACKAGE_DIR;
pnpm pkg get name --workspaces=false | tr -d '"' | sed -r 's/(.*)/name=\1/' >> "$GITHUB_OUTPUT";
pnpm pkg get version --workspaces=false | tr -d '"' | sed -r 's/(.*)/version=\1/' >> "$GITHUB_OUTPUT";
pnpm pkg get version --workspaces=false | tr -d '"' | sed -r 's/([0-9]+\.[0-9]+).*/majorVersion=\1/' >> "$GITHUB_OUTPUT";
# --ignore-scripts is required for publishing devextreme-angular which fails with error:
# 'Trying to publish a package that has been compiled by Ivy in full compilation mode.'
# Should be removed.
- name: Publish to npm.pkg.github.com
working-directory: ${{ steps.scopedPackage.outputs.packageDir }}
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pnpm set //npm.pkg.github.com/:_authToken="$NODE_AUTH_TOKEN";
pnpm publish --no-git-checks --quiet --ignore-scripts --registry https://npm.pkg.github.com;
- name: Move 'daily' tag
if: ${{ env.MOVE_DAILY_TAG == 'true' }}
env:
PACKAGE_NAME: ${{ steps.scopedPackage.outputs.name }}
PACKAGE_VERSION: ${{ steps.scopedPackage.outputs.version }}
PACKAGE_VERSION_MAJOR: ${{ steps.scopedPackage.outputs.majorVersion }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pnpm set //npm.pkg.github.com/:_authToken="$NODE_AUTH_TOKEN"
pnpm dist-tag add $PACKAGE_NAME@$PACKAGE_VERSION $PACKAGE_VERSION_MAJOR-daily --registry=https://npm.pkg.github.com
- name: Move 'stable' tag
if: ${{ env.MOVE_STABLE_TAG == 'true' }}
env:
PACKAGE_NAME: ${{ steps.scopedPackage.outputs.name }}
PACKAGE_VERSION: ${{ steps.scopedPackage.outputs.version }}
PACKAGE_VERSION_MAJOR: ${{ steps.scopedPackage.outputs.majorVersion }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pnpm set //npm.pkg.github.com/:_authToken="$NODE_AUTH_TOKEN"
pnpm dist-tag add $PACKAGE_NAME@$PACKAGE_VERSION $PACKAGE_VERSION_MAJOR-stable --registry=https://npm.pkg.github.com
notify:
runs-on: devextreme-shr2
name: Send notifications
needs: [ build, publish ]
if: failure()
steps:
- uses: actions/checkout@v4
- uses: DevExpress/github-actions/send-teams-notification@v1
with:
hook_url: ${{secrets.TEAMS_ALERT}}
bearer_token: ${{secrets.GITHUB_TOKEN}}
specific_repo: DevExpress/DevExtreme