Skip to content

Commit 982d729

Browse files
authored
address pr comments, added alpha, beta tags
1 parent 9b84436 commit 982d729

1 file changed

Lines changed: 37 additions & 22 deletions

File tree

.github/workflows/publish-npm.yml

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,36 @@ jobs:
1919
with:
2020
fetch-depth: 0
2121

22-
- name: Extract version from branch name
23-
id: version
24-
run: |
25-
BRANCH_NAME="${{ github.ref_name }}"
26-
27-
# Extract version from release-X.X.X branch name
28-
if [[ $BRANCH_NAME =~ ^release-(.+)$ ]]; then
29-
VERSION="${BASH_REMATCH[1]}"
30-
echo "version=$VERSION" >> $GITHUB_OUTPUT
31-
else
32-
echo "❌ Error: Branch must be named 'release-X.X.X'"
33-
exit 1
34-
fi
35-
3622
- name: Setup Node.js
3723
uses: actions/setup-node@v6
3824
with:
3925
node-version: '22'
4026
registry-url: 'https://registry.npmjs.org'
4127

4228
- name: Install dependencies
43-
run: npm install
29+
run: |
30+
npm ci
31+
npm run prepare
32+
33+
- name: Determine NPM tag
34+
id: npm-tag
35+
run: |
36+
VERSION="${{ github.ref_name }}"
37+
if [[ $VERSION == *"-alpha"* ]]; then
38+
echo "tag=alpha" >> $GITHUB_OUTPUT
39+
echo "📦 Publishing with tag: alpha"
40+
elif [[ $VERSION == *"-beta"* ]]; then
41+
echo "tag=beta" >> $GITHUB_OUTPUT
42+
echo "📦 Publishing with tag: beta"
43+
else
44+
echo "tag=" >> $GITHUB_OUTPUT
45+
echo "📦 Publishing without explicit tag (npm default)"
46+
fi
4447
4548
- name: Verify version matches package.json
4649
run: |
4750
PACKAGE_VERSION=$(npm run version:local --silent)
48-
BRANCH_VERSION="${{ steps.version.outputs.version }}"
51+
BRANCH_VERSION="${{ github.ref_name }}"
4952
5053
if [ "$PACKAGE_VERSION" != "$BRANCH_VERSION" ]; then
5154
echo "❌ Error: Version mismatch!"
@@ -55,7 +58,7 @@ jobs:
5558
5659
- name: Check if version already published
5760
run: |
58-
VERSION="${{ steps.version.outputs.version }}"
61+
VERSION="${{ github.ref_name }}"
5962
PUBLISHED_VERSION=$(npm run version:published --silent 2>/dev/null || echo "")
6063
6164
if [ "$PUBLISHED_VERSION" == "$VERSION" ]; then
@@ -67,25 +70,37 @@ jobs:
6770
if: inputs.dry_run == true
6871
run: |
6972
echo "🔍 DRY RUN MODE"
70-
npm publish --dry-run
73+
TAG="${{ steps.npm-tag.outputs.tag }}"
74+
if [ -n "$TAG" ]; then
75+
echo "📦 Tag: $TAG"
76+
npm publish --dry-run --tag "$TAG"
77+
else
78+
echo "📦 No explicit tag (using npm default)"
79+
npm publish --dry-run
80+
fi
7181
7282
- name: Publish to NPM
7383
if: inputs.dry_run == false
74-
run: npm publish
84+
run: |
85+
TAG="${{ steps.npm-tag.outputs.tag }}"
86+
if [ -n "$TAG" ]; then
87+
npm publish --tag "$TAG"
88+
else
89+
npm publish
90+
fi
7591
env:
7692
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
7793

7894
- name: Verify publication
7995
if: inputs.dry_run == false
8096
run: |
8197
sleep 10
82-
npm view opentok-react-native@${{ steps.version.outputs.version }} version
98+
npm view opentok-react-native@${{ github.ref_name }} version
8399
84100
- name: Summary
85101
if: always()
86102
run: |
87103
echo "## Publish Summary" >> $GITHUB_STEP_SUMMARY
88104
echo "" >> $GITHUB_STEP_SUMMARY
89-
echo "- **Version**: ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
90-
echo "- **Branch**: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
105+
echo "- **Version**: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
91106
echo "- **Dry Run**: ${{ inputs.dry_run }}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)