Skip to content

Commit 202772b

Browse files
Renamed release to release_npm
Added a new workflow release_gpr for release in GPR
1 parent 69e3f6f commit 202772b

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

.github/workflows/release_gpr.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Publish SDK to GitHub Package Registry
2+
3+
on:
4+
release:
5+
types: [published, edited]
6+
workflow_dispatch: {}
7+
8+
jobs:
9+
publish:
10+
name: Publish to GitHub Package Registry
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://npm.pkg.github.com/"
22+
always-auth: "true"
23+
env:
24+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_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 GitHub Package Registry
66+
env:
67+
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
68+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
69+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_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'] }} --registry=https://npm.pkg.github.com/ $DRY_RUN
File renamed without changes.

0 commit comments

Comments
 (0)