-
Notifications
You must be signed in to change notification settings - Fork 607
132 lines (115 loc) · 4.69 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
name: Publishing to GitHub Packages
on:
schedule:
- cron: '0 0 * * 1-5'
workflow_dispatch:
inputs:
filter:
type: string
description: Package file filter pattern
required: false
timestamp-version:
type: boolean
description: Set timestamp version
required: false
default: true
next-tag:
type: boolean
description: Move 'next' tag
required: false
default: true
stable-tag:
type: boolean
description: Move 'stable' tag
required: false
default: false
env:
FILTER: ${{ github.event_name == 'workflow_dispatch' && inputs.filter || '' }}
SET_TIMESTAMP_VERSION: ${{ (github.event_name == 'workflow_dispatch' && inputs.timestamp-version) || (github.event_name != 'workflow_dispatch' && true) }}
MOVE_NEXT_TAG: ${{ (github.event_name == 'workflow_dispatch' && inputs.next-tag) || (github.event_name != 'workflow_dispatch' && true) }}
MOVE_STABLE_TAG: ${{ (github.event_name == 'workflow_dispatch' && inputs.stable-tag) || (github.event_name != 'workflow_dispatch' && false) }}
jobs:
build:
name: Build packages
runs-on: ubuntu-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'
- name: Install dependencies
run: npm install --no-audit --no-fund
- name: Set timestamp version
if: ${{ env.SET_TIMESTAMP_VERSION == 'true' }}
run: npm run ts-script build/set-timestamp-version
- name: Build npm packages
env:
BUILD_INTERNAL_PACKAGE: true
run: npm run all:build
- name: Build artifacts package
run: npm run ts-script build/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
run: ls *.tgz | grep -E -i "$FILTER" | sed -r 's/^(.*)$/"\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: Download Artifacts
uses: actions/download-artifact@v3
with:
name: packages
- name: Publish to npm.pkg.github.com
id: publish
env:
PACKAGE: ${{ matrix.package }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AUTHOR: ${{ github.repository_owner }}
# --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.
run: |
tar -xzf $PACKAGE
cd package
npm init -y --scope $AUTHOR
npm pkg delete repository
npm set //npm.pkg.github.com/:_authToken="$NODE_AUTH_TOKEN"
npm publish --quiet --ignore-scripts --registry https://npm.pkg.github.com
npm pkg get name --workspaces=false | tr -d '"' | sed -r 's/(.*)/name=\1/' >> "$GITHUB_OUTPUT"
npm pkg get version --workspaces=false | tr -d '"' | sed -r 's/(.*)/version=\1/' >> "$GITHUB_OUTPUT"
npm pkg get version --workspaces=false | tr -d '"' | sed -r 's/([0-9]+\.[0-9]+).*/majorVersion=\1/' >> "$GITHUB_OUTPUT"
- name: Move 'next' tag
if: ${{ env.MOVE_NEXT_TAG == 'true' }}
env:
PACKAGE_NAME: ${{ steps.publish.outputs.name }}
PACKAGE_VERSION: ${{ steps.publish.outputs.version }}
PACKAGE_VERSION_MAJOR: ${{ steps.publish.outputs.majorVersion }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm set //npm.pkg.github.com/:_authToken="$NODE_AUTH_TOKEN"
npm --registry=https://npm.pkg.github.com dist-tag add $PACKAGE_NAME@$PACKAGE_VERSION $PACKAGE_VERSION_MAJOR-next
- name: Move 'stable' tag
if: ${{ env.MOVE_STABLE_TAG == 'true' }}
env:
PACKAGE_NAME: ${{ steps.publish.outputs.name }}
PACKAGE_VERSION: ${{ steps.publish.outputs.version }}
PACKAGE_VERSION_MAJOR: ${{ steps.publish.outputs.majorVersion }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm set //npm.pkg.github.com/:_authToken="$NODE_AUTH_TOKEN"
npm --registry=https://npm.pkg.github.com dist-tag add $PACKAGE_NAME@$PACKAGE_VERSION $PACKAGE_VERSION_MAJOR-stable