Skip to content

Commit 2667b0c

Browse files
committed
ci: add workflow dispatch for now
1 parent 15f6143 commit 2667b0c

1 file changed

Lines changed: 38 additions & 10 deletions

File tree

.github/workflows/cd.yml

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Filename (cd.yml) should match the workflow filename in Trusted Publisher setting on npmjs
22
name: Publish to NPM & Github
33
on:
4+
workflow_dispatch:
45
pull_request:
56
types:
67
- closed
@@ -15,8 +16,9 @@ permissions:
1516
jobs:
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
@@ -27,19 +29,45 @@ jobs:
2729
with:
2830
node-version: "24"
2931
registry-url: "https://registry.npmjs.org"
32+
cache: ""
3033

3134
- name: Determine npm tag
3235
id: npm-tag
3336
run: |
3437
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
38+
echo "Detected version: $VERSION"
39+
TAG=""
40+
if echo "$VERSION" | grep -qi "alpha"; then
41+
TAG="alpha"
42+
elif echo "$VERSION" | grep -qi "beta"; then
43+
TAG="beta"
3944
fi
45+
echo "tag=$TAG" >> $GITHUB_OUTPUT
46+
echo "Using tag: [$TAG]"
4047
41-
- run: npm publish com.onesignal.unity.core --access public --provenance ${{ steps.npm-tag.outputs.tag }}
42-
43-
- run: npm publish com.onesignal.unity.android --access public --provenance ${{ steps.npm-tag.outputs.tag }}
48+
- name: Debug tag output
49+
run: |
50+
echo "Tag from output: [${{ steps.npm-tag.outputs.tag }}]"
4451
45-
- run: npm publish com.onesignal.unity.ios --access public --provenance ${{ steps.npm-tag.outputs.tag }}
52+
- name: Publish packages
53+
run: |
54+
publish_pkg() {
55+
local pkg=$1
56+
cd "$pkg"
57+
VERSION=$(node -p "require('./package.json').version")
58+
echo "Publishing $pkg@$VERSION"
59+
if npm view "$pkg@$VERSION" version 2>/dev/null; then
60+
echo "Version $VERSION already published, skipping"
61+
else
62+
TAG="${{ steps.npm-tag.outputs.tag }}"
63+
if [ -n "$TAG" ]; then
64+
npm publish --access public --provenance --tag "$TAG"
65+
else
66+
npm publish --access public --provenance
67+
fi
68+
fi
69+
cd ..
70+
}
71+
publish_pkg com.onesignal.unity.core
72+
publish_pkg com.onesignal.unity.android
73+
publish_pkg com.onesignal.unity.ios

0 commit comments

Comments
 (0)