Skip to content

Commit

Permalink
Add logic to handle proper taging
Browse files Browse the repository at this point in the history
  • Loading branch information
mikechu-optimizely committed Sep 26, 2023
1 parent 369fa09 commit 08dbf4e
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion .github/workflows/react_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Publish React SDK to NPM
on:
release:
types: [ published ]
push:
branches:
- mike/tag-correctly-during-publish

jobs:
publish:
Expand All @@ -11,15 +14,34 @@ jobs:
steps:
- name: Checkout branch
uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: "https://registry.npmjs.org/"
always-auth: "true"
env:
NODE_AUTH_TOKEN: ${{ secrets.PUBLISH_REACT_TO_NPM_FROM_GITHUB }}

- name: Install dependencies
run: yarn install

- id: npm-tag
name: Determine NPM Tag
run: |
version=$(jq -r '.version' package.json)
if [[ "$version" == *"-beta"* ]]; then
echo "npm-tag=beta" >> "$GITHUB_OUTPUT"
elif [[ "$version" == *"-alpha"* ]]; then
echo "npm-tag=alpha" >> "$GITHUB_OUTPUT"
elif [[ "$version" == *"-rc"* ]]; then
echo "npm-tag=rc" >> "$GITHUB_OUTPUT"
else
echo "npm-tag=latest" >> "$GITHUB_OUTPUT"
fi
- name: Test, build, then publish
env:
NODE_AUTH_TOKEN: ${{ secrets.PUBLISH_REACT_TO_NPM_FROM_GITHUB }}
run: npm publish
run: npm publish --tag ${{ steps.npm-tag.outputs['npm-tag'] }} --dry-run

0 comments on commit 08dbf4e

Please sign in to comment.