11# Filename (cd.yml) should match the workflow filename in Trusted Publisher setting on npmjs
22name : Publish to NPM & Github
33on :
4+ workflow_dispatch :
45 pull_request :
56 types :
67 - closed
@@ -15,8 +16,9 @@ permissions:
1516jobs :
1617 publish :
1718 if : |
18- github.event.pull_request.merged == true &&
19- contains(github.event.pull_request.title, 'chore: Release')
19+ github.event_name == 'workflow_dispatch' ||
20+ (github.event.pull_request.merged == true &&
21+ contains(github.event.pull_request.title, 'chore: Release'))
2022 runs-on : ubuntu-latest
2123 steps :
2224 - name : Checkout
@@ -32,14 +34,39 @@ jobs:
3234 id : npm-tag
3335 run : |
3436 VERSION=$(node -p "require('./com.onesignal.unity.core/package.json').version")
35- if [[ "$VERSION" == *"alpha"* ]]; then
36- echo "tag=--tag alpha" >> $GITHUB_OUTPUT
37- elif [[ "$VERSION" == *"beta"* ]]; then
38- echo "tag=--tag beta" >> $GITHUB_OUTPUT
37+ echo "Detected version: $VERSION"
38+ TAG=""
39+ if echo "$VERSION" | grep -q "alpha"; then
40+ TAG="alpha"
41+ elif echo "$VERSION" | grep -q "beta"; then
42+ TAG="beta"
3943 fi
44+ echo "tag=$TAG" >> $GITHUB_OUTPUT
45+ echo "Using tag: $TAG"
4046
41- - run : npm publish com.onesignal.unity.core --access public --provenance ${{ steps.npm-tag.outputs.tag }}
47+ - name : Publish core
48+ run : |
49+ TAG="${{ steps.npm-tag.outputs.tag }}"
50+ if [ -n "$TAG" ]; then
51+ npm publish com.onesignal.unity.core --access public --provenance --tag "$TAG"
52+ else
53+ npm publish com.onesignal.unity.core --access public --provenance
54+ fi
4255
43- - run : npm publish com.onesignal.unity.android --access public --provenance ${{ steps.npm-tag.outputs.tag }}
56+ - name : Publish android
57+ run : |
58+ TAG="${{ steps.npm-tag.outputs.tag }}"
59+ if [ -n "$TAG" ]; then
60+ npm publish com.onesignal.unity.android --access public --provenance --tag "$TAG"
61+ else
62+ npm publish com.onesignal.unity.android --access public --provenance
63+ fi
4464
45- - run : npm publish com.onesignal.unity.ios --access public --provenance ${{ steps.npm-tag.outputs.tag }}
65+ - name : Publish ios
66+ run : |
67+ TAG="${{ steps.npm-tag.outputs.tag }}"
68+ if [ -n "$TAG" ]; then
69+ npm publish com.onesignal.unity.ios --access public --provenance --tag "$TAG"
70+ else
71+ npm publish com.onesignal.unity.ios --access public --provenance
72+ fi
0 commit comments