Skip to content

Commit 2e8c527

Browse files
committed
ci: add workflow dispatch for now
- add create github release job
1 parent 15f6143 commit 2e8c527

1 file changed

Lines changed: 48 additions & 9 deletions

File tree

.github/workflows/cd.yml

Lines changed: 48 additions & 9 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,9 +16,12 @@ 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
23+
outputs:
24+
version: ${{ steps.npm-tag.outputs.version }}
2125
steps:
2226
- name: Checkout
2327
uses: actions/checkout@v5
@@ -27,19 +31,54 @@ jobs:
2731
with:
2832
node-version: "24"
2933
registry-url: "https://registry.npmjs.org"
34+
cache: ""
3035

3136
- name: Determine npm tag
3237
id: npm-tag
3338
run: |
3439
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
40+
echo "Detected version: $VERSION"
41+
echo "version=$VERSION" >> $GITHUB_OUTPUT
42+
TAG=""
43+
if echo "$VERSION" | grep -qi "alpha"; then
44+
TAG="alpha"
45+
elif echo "$VERSION" | grep -qi "beta"; then
46+
TAG="beta"
3947
fi
48+
echo "tag=$TAG" >> $GITHUB_OUTPUT
49+
echo "Using tag: [$TAG]"
4050
41-
- run: npm publish com.onesignal.unity.core --access public --provenance ${{ steps.npm-tag.outputs.tag }}
51+
- name: Debug tag output
52+
run: |
53+
echo "Tag from output: [${{ steps.npm-tag.outputs.tag }}]"
4254
43-
- run: npm publish com.onesignal.unity.android --access public --provenance ${{ steps.npm-tag.outputs.tag }}
55+
- name: Publish packages
56+
run: |
57+
publish_pkg() {
58+
local pkg=$1
59+
cd "$pkg"
60+
VERSION=$(node -p "require('./package.json').version")
61+
echo "Publishing $pkg@$VERSION"
62+
if npm view "$pkg@$VERSION" version 2>/dev/null; then
63+
echo "Version $VERSION already published, skipping"
64+
else
65+
TAG="${{ steps.npm-tag.outputs.tag }}"
66+
if [ -n "$TAG" ]; then
67+
npm publish --access public --provenance --tag "$TAG"
68+
else
69+
npm publish --access public --provenance
70+
fi
71+
fi
72+
cd ..
73+
}
74+
publish_pkg com.onesignal.unity.core
75+
publish_pkg com.onesignal.unity.android
76+
publish_pkg com.onesignal.unity.ios
4477
45-
- run: npm publish com.onesignal.unity.ios --access public --provenance ${{ steps.npm-tag.outputs.tag }}
78+
create_github_release:
79+
needs: publish
80+
uses: OneSignal/sdk-actions/.github/workflows/github-release.yml@main
81+
secrets:
82+
GH_PUSH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }}
83+
with:
84+
version: ${{ needs.publish.outputs.version }}

0 commit comments

Comments
 (0)