1
- name : Publish SDK to NPM
1
+ name : Publish SDK to NPM and GPR
2
2
3
3
on :
4
4
release :
5
- types : [published, edited ]
5
+ types : [published]
6
6
workflow_dispatch : {}
7
7
8
8
jobs :
9
- publish :
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
16
-
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
- run : |
41
- VERSION=$(jq -r '.version' package.json)
42
- LATEST_RELEASE_TAG="${{ steps.latest-release.outputs['latest-release-tag']}}"
43
-
44
- if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
45
- GITHUB_REF=${{ github.ref }}
46
- RELEASE_TAG=${GITHUB_REF#refs/tags/}
47
- else
48
- RELEASE_TAG="${{ github.event.release.tag_name }}"
49
- fi
50
-
51
- if [[ $RELEASE_TAG == $LATEST_RELEASE_TAG ]]; then
52
- echo "npm-tag=latest" >> "$GITHUB_OUTPUT"
53
- elif [[ "$VERSION" == *"-beta"* ]]; then
54
- echo "npm-tag=beta" >> "$GITHUB_OUTPUT"
55
- elif [[ "$VERSION" == *"-alpha"* ]]; then
56
- echo "npm-tag=alpha" >> "$GITHUB_OUTPUT"
57
- elif [[ "$VERSION" == *"-rc"* ]]; then
58
- echo "npm-tag=rc" >> "$GITHUB_OUTPUT"
59
- else
60
- echo "npm-tag=v$(echo $VERSION | awk -F. '{print $1}')-latest" >> "$GITHUB_OUTPUT"
61
- fi
62
-
63
- - id : release
64
- name : Test, build and publish to npm
65
- env :
66
- BROWSERSTACK_USERNAME : ${{ secrets.BROWSERSTACK_USERNAME }}
67
- BROWSERSTACK_ACCESS_KEY : ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
68
- NODE_AUTH_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
69
- run : |
70
- if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
71
- DRY_RUN="--dry-run"
72
- fi
73
- npm publish --tag=${{ steps.npm-tag.outputs['npm-tag'] }} $DRY_RUN
74
-
75
- # - name: Report results to Jellyfish
76
- # uses: optimizely/jellyfish-deployment-reporter-action@main
77
- # if: ${{ always() && github.event_name == 'release' && (steps.release.outcome == 'success' || steps.release.outcome == 'failure') }}
78
- # with:
79
- # jellyfish_api_token: ${{ secrets.JELLYFISH_API_TOKEN }}
80
- # is_successful: ${{ steps.release.outcome == 'success' }}
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 }}
17
+
18
+ publish_to_gpr :
19
+ name : Publish to GitHub Package Registry
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