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,43 @@ 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 -qi "alpha"; then
40+ TAG="alpha"
41+ elif echo "$VERSION" | grep -qi "beta"; then
42+ TAG="beta"
3943 fi
44+ echo "tag=$TAG" >> $GITHUB_OUTPUT
45+ echo "Using tag: [$TAG]"
46+
47+ - name : Debug tag output
48+ run : |
49+ echo "Tag from output: [${{ steps.npm-tag.outputs.tag }}]"
4050
41- - run : npm publish com.onesignal.unity.core --access public --provenance ${{ steps.npm-tag.outputs.tag }}
51+ - name : Publish core
52+ run : |
53+ TAG="${{ steps.npm-tag.outputs.tag }}"
54+ if [ -n "$TAG" ]; then
55+ npm publish com.onesignal.unity.core --access public --provenance --tag "$TAG"
56+ else
57+ npm publish com.onesignal.unity.core --access public --provenance
58+ fi
4259
43- - run : npm publish com.onesignal.unity.android --access public --provenance ${{ steps.npm-tag.outputs.tag }}
60+ - name : Publish android
61+ run : |
62+ TAG="${{ steps.npm-tag.outputs.tag }}"
63+ if [ -n "$TAG" ]; then
64+ npm publish com.onesignal.unity.android --access public --provenance --tag "$TAG"
65+ else
66+ npm publish com.onesignal.unity.android --access public --provenance
67+ fi
4468
45- - run : npm publish com.onesignal.unity.ios --access public --provenance ${{ steps.npm-tag.outputs.tag }}
69+ - name : Publish ios
70+ run : |
71+ TAG="${{ steps.npm-tag.outputs.tag }}"
72+ if [ -n "$TAG" ]; then
73+ npm publish com.onesignal.unity.ios --access public --provenance --tag "$TAG"
74+ else
75+ npm publish com.onesignal.unity.ios --access public --provenance
76+ fi
0 commit comments