8
8
jobs :
9
9
publish_to_npm :
10
10
name : Publish to NPM
11
- runs-on : ubuntu-latest
12
- if : ${{ github.event_name == 'workflow_dispatch' || !github.event.release.draft }}
13
- steps :
14
- - name : Checkout branch
15
- uses : actions/checkout@v4
11
+ uses : ./.github/workflows/common-publish.yml
12
+ with :
13
+ registry-url : ' https://registry.npmjs.org/'
14
+ node-auth-token : ${{ secrets.NPM_PUBLISH_TOKEN }}
15
+ browserstack-username : ${{ secrets.BROWSERSTACK_USERNAME }}
16
+ browserstack-access-key : ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
16
17
17
- - name : Setup Node
18
- uses : actions/setup-node@v3
19
- with :
20
- node-version : 16
21
- registry-url : " https://registry.npmjs.org/"
22
- always-auth : " true"
23
- env :
24
- NODE_AUTH_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
25
-
26
- - name : Install dependencies
27
- run : npm install
28
-
29
- - id : latest-release
30
- name : Export latest release git tag
31
- run : |
32
- echo "latest-release-tag=$(curl -qsSL \
33
- -H "Accept: application/vnd.github+json" \
34
- -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
35
- "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/latest" \
36
- | jq -r .tag_name)" >> $GITHUB_OUTPUT
37
-
38
- - id : npm-tag
39
- name : Determine NPM tag
40
- env :
41
- GITHUB_RELEASE_TAG : ${{ github.event.release.tag_name }}
42
- run : |
43
- VERSION=$(jq -r '.version' package.json)
44
- LATEST_RELEASE_TAG="${{ steps.latest-release.outputs['latest-release-tag']}}"
45
-
46
- if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
47
- RELEASE_TAG=${GITHUB_REF#refs/tags/}
48
- else
49
- RELEASE_TAG=$GITHUB_RELEASE_TAG
50
- fi
51
-
52
- if [[ $RELEASE_TAG == $LATEST_RELEASE_TAG ]]; then
53
- echo "npm-tag=latest" >> "$GITHUB_OUTPUT"
54
- elif [[ "$VERSION" == *"-beta"* ]]; then
55
- echo "npm-tag=beta" >> "$GITHUB_OUTPUT"
56
- elif [[ "$VERSION" == *"-alpha"* ]]; then
57
- echo "npm-tag=alpha" >> "$GITHUB_OUTPUT"
58
- elif [[ "$VERSION" == *"-rc"* ]]; then
59
- echo "npm-tag=rc" >> "$GITHUB_OUTPUT"
60
- else
61
- echo "npm-tag=v$(echo $VERSION | awk -F. '{print $1}')-latest" >> "$GITHUB_OUTPUT"
62
- fi
63
-
64
- - id : release
65
- name : Test, build and publish to npm
66
- env :
67
- BROWSERSTACK_USERNAME : ${{ secrets.BROWSERSTACK_USERNAME }}
68
- BROWSERSTACK_ACCESS_KEY : ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
69
- NODE_AUTH_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
70
- run : |
71
- if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
72
- DRY_RUN="--dry-run"
73
- fi
74
- npm publish --tag=${{ steps.npm-tag.outputs['npm-tag'] }} $DRY_RUN
75
-
76
18
publish_to_gpr :
77
19
name : Publish to GitHub Package Registry
78
- runs-on : ubuntu-latest
79
- if : ${{ github.event_name == 'workflow_dispatch' || !github.event.release.draft }}
80
- steps :
81
- - name : Checkout branch
82
- uses : actions/checkout@v4
83
-
84
- - name : Setup Node.js for GPR
85
- uses : actions/setup-node@v3
86
- with :
87
- node-version : 16
88
- registry-url : ' https://npm.pkg.github.com/'
89
- always-auth : true
90
- env :
91
- NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
92
-
93
- - name : Install dependencies
94
- run : npm install
95
-
96
- - id : latest-release
97
- name : Export latest release git tag
98
- run : |
99
- echo "latest-release-tag=$(curl -qsSL \
100
- -H "Accept: application/vnd.github+json" \
101
- -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
102
- "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/latest" \
103
- | jq -r .tag_name)" >> $GITHUB_OUTPUT
104
-
105
- - id : npm-tag
106
- name : Determine NPM tag
107
- env :
108
- GITHUB_RELEASE_TAG : ${{ github.event.release.tag_name }}
109
- run : |
110
- VERSION=$(jq -r '.version' package.json)
111
- LATEST_RELEASE_TAG="${{ steps.latest-release.outputs['latest-release-tag']}}"
112
-
113
- if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
114
- RELEASE_TAG=${GITHUB_REF#refs/tags/}
115
- else
116
- RELEASE_TAG=$GITHUB_RELEASE_TAG
117
- fi
118
-
119
- if [[ $RELEASE_TAG == $LATEST_RELEASE_TAG ]]; then
120
- echo "npm-tag=latest" >> "$GITHUB_OUTPUT"
121
- elif [[ "$VERSION" == *"-beta"* ]]; then
122
- echo "npm-tag=beta" >> "$GITHUB_OUTPUT"
123
- elif [[ "$VERSION" == *"-alpha"* ]]; then
124
- echo "npm-tag=alpha" >> "$GITHUB_OUTPUT"
125
- elif [[ "$VERSION" == *"-rc"* ]]; then
126
- echo "npm-tag=rc" >> "$GITHUB_OUTPUT"
127
- else
128
- echo "npm-tag=v$(echo $VERSION | awk -F. '{print $1}')-latest" >> "$GITHUB_OUTPUT"
129
- fi
130
-
131
- - id : release
132
- name : Test, build and publish to gpr
133
- env :
134
- BROWSERSTACK_USERNAME : ${{ secrets.BROWSERSTACK_USERNAME }}
135
- BROWSERSTACK_ACCESS_KEY : ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
136
- NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
137
- run : |
138
- if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
139
- DRY_RUN="--dry-run"
140
- fi
141
- npm publish --tag=${{ steps.npm-tag.outputs['npm-tag'] }} --registry=https://npm.pkg.github.com/ $DRY_RUN
20
+ uses : ./.github/workflows/common-publish.yml
21
+ with :
22
+ registry-url : ' https://npm.pkg.github.com/'
23
+ node-auth-token : ${{ secrets.GITHUB_TOKEN }}
24
+ browserstack-username : ${{ secrets.BROWSERSTACK_USERNAME }}
25
+ browserstack-access-key : ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
0 commit comments