66 - ' master'
77 workflow_dispatch :
88
9+ permissions :
10+ contents : write
11+ pull-requests : write
12+ id-token : write
13+
914jobs :
10- release :
15+ release-please :
1116 runs-on : ubuntu-latest
12- permissions :
13- contents : write
14- pull-requests : write
1517 outputs :
1618 release_created : ${{ steps.release.outputs.release_created }}
1719 tag_name : ${{ steps.release.outputs.tag_name }}
@@ -25,17 +27,93 @@ jobs:
2527 with :
2628 token : ${{ secrets.BOT_TOKEN }}
2729
28- publish :
29- needs : release
30- if : ${{ needs.release.outputs.release_created == 'true' }}
31- permissions :
32- contents : read
33- id-token : write
34- uses : ./.github/workflows/npm-publish.yml
30+ publish-stable :
31+ needs : release-please
32+ if : needs.release-please.outputs.release_created == 'true'
33+ runs-on : ubuntu-latest
34+
35+ steps :
36+ - uses : actions/checkout@v4
37+
38+ - uses : actions/setup-node@v4
39+ with :
40+ node-version : ' 24.x'
41+ registry-url : ' https://registry.npmjs.org'
42+
43+ - run : npm ci
44+
45+ - run : npm run build-all
46+
47+ - name : Publish to NPM
48+ run : npm publish --provenance --access public
49+
50+ publish-edge :
51+ needs : release-please
52+ if : needs.release-please.outputs.release_created != 'true'
53+ runs-on : ubuntu-latest
54+ outputs :
55+ new_version : ${{ steps.bump_version.outputs.new_version }}
56+
57+ steps :
58+ - uses : actions/checkout@v4
59+ with :
60+ fetch-depth : 0
61+
62+ - uses : actions/setup-node@v4
63+ with :
64+ node-version : ' 24.x'
65+ registry-url : ' https://registry.npmjs.org'
66+
67+ - run : npm ci
68+
69+ - name : Get current version from package.json
70+ id : get_version
71+ run : |
72+ current_version=$(node -p "require('./package.json').version")
73+ echo "current_version=${current_version}" >> $GITHUB_OUTPUT
74+
75+ - name : Calculate next version
76+ id : get_next_version
77+ run : |
78+ next_version=$(npx semver ${{ steps.get_version.outputs.current_version }} -i patch)
79+ echo "Next patch version: $next_version"
80+ echo "version=$next_version" >> $GITHUB_OUTPUT
81+
82+ - name : Configure Git
83+ run : |
84+ git config user.name "${{ github.actor }}"
85+ git config user.email "${{ github.actor }}@users.noreply.github.com"
86+
87+ - name : Checkout or create edge branch
88+ run : |
89+ if git rev-parse --verify origin/${{ steps.get_next_version.outputs.version }}-edge; then
90+ git checkout ${{ steps.get_next_version.outputs.version }}-edge
91+ git merge master -X ours --no-edit
92+ else
93+ git checkout master -b ${{ steps.get_next_version.outputs.version }}-edge
94+ fi
95+
96+ - name : Bump version
97+ id : bump_version
98+ run : |
99+ new_version=$(npm version prerelease --preid=edge)
100+ echo "New edge version: $new_version"
101+ echo "new_version=${new_version}" >> $GITHUB_OUTPUT
102+
103+ - name : Push version
104+ env :
105+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
106+ run : |
107+ git push origin ${{ steps.get_next_version.outputs.version }}-edge
108+
109+ - run : npm run build-all
110+
111+ - name : Publish to NPM
112+ run : npm publish --tag edge --provenance --access public
35113
36114 notify :
37- needs : [release, publish]
38- if : ${{ always() && needs.release.outputs.release_created == 'true' }}
115+ needs : [release-please , publish-stable, publish-edge ]
116+ if : always() && ( needs.publish-stable.result != null || needs.publish-edge.result != null)
39117 runs-on : ubuntu-latest
40118
41119 steps :
@@ -44,14 +122,30 @@ jobs:
44122 - name : Set Notification Messages
45123 id : set-messages
46124 run : |
47- if [[ "${{ needs.publish.result }}" == "success" ]]; then
48- echo "SLACK_TITLE=Video Player ${{ needs.release.outputs.tag_name }} Deployed" >> $GITHUB_OUTPUT
49- echo "SLACK_MESSAGE=Success :rocket: cloudinary-video-player version ${{ needs.release.outputs.tag_name }} deployed successfully" >> $GITHUB_OUTPUT
50- echo "SLACK_FOOTER=Check it out at https://cloudinary.github.io/cloudinary-video-player/?ver=latest&min=true" >> $GITHUB_OUTPUT
125+ # Determine version and result based on release type
126+ if [[ "${{ needs.release-please.outputs.release_created }}" == "true" ]]; then
127+ VERSION="${{ needs.release-please.outputs.tag_name }}"
128+ PUBLISH_RESULT="${{ needs.publish-stable.result }}"
129+ VER_PARAM="latest"
130+ else
131+ VERSION="${{ needs.publish-edge.outputs.new_version }}"
132+ # Fallback if version output is empty (e.g., if job failed before bump_version)
133+ if [[ -z "$VERSION" ]]; then
134+ VERSION="edge"
135+ fi
136+ PUBLISH_RESULT="${{ needs.publish-edge.result }}"
137+ VER_PARAM="edge"
138+ fi
139+
140+ # Set messages based on publish result
141+ if [[ "$PUBLISH_RESULT" == "success" ]]; then
142+ echo "SLACK_TITLE=Video Player $VERSION Deployed" >> $GITHUB_OUTPUT
143+ echo "SLACK_MESSAGE=Success :rocket: cloudinary-video-player version $VERSION deployed successfully" >> $GITHUB_OUTPUT
144+ echo "SLACK_FOOTER=Check it out at https://cloudinary.github.io/cloudinary-video-player/?ver=$VER_PARAM&min=true" >> $GITHUB_OUTPUT
51145 echo "SLACK_COLOR=good" >> $GITHUB_OUTPUT
52146 else
53147 echo "SLACK_TITLE=Video Player Deployment Failed" >> $GITHUB_OUTPUT
54- echo "SLACK_MESSAGE=:alert: Failed to deploy cloudinary-video-player version ${{ needs.release.outputs.tag_name }} " >> $GITHUB_OUTPUT
148+ echo "SLACK_MESSAGE=:alert: Failed to deploy cloudinary-video-player version $VERSION " >> $GITHUB_OUTPUT
55149 echo "SLACK_FOOTER=See log here https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_OUTPUT
56150 echo "SLACK_COLOR=danger" >> $GITHUB_OUTPUT
57151 fi
@@ -67,8 +161,21 @@ jobs:
67161 SLACK_MESSAGE : ${{ steps.set-messages.outputs.SLACK_MESSAGE }}
68162 SLACK_FOOTER : ${{ steps.set-messages.outputs.SLACK_FOOTER }}
69163
164+ - name : Determine Package for Cache Purge
165+ id : purge-cache
166+ run : |
167+ if [[ "${{ needs.release-please.outputs.release_created }}" == "true" ]]; then
168+ if [[ "${{ needs.publish-stable.result }}" == "success" ]]; then
169+ echo "package=cloudinary-video-player" >> $GITHUB_OUTPUT
170+ fi
171+ else
172+ if [[ "${{ needs.publish-edge.result }}" == "success" ]]; then
173+ echo "package=cloudinary-video-player@edge" >> $GITHUB_OUTPUT
174+ fi
175+ fi
176+
70177 - name : Purge jsDelivr Cache
71- if : ${{ needs.publish.result == 'success' }}
178+ if : steps.purge-cache.outputs.package != ''
72179 uses : ./.github/actions/purge-jsdelivr
73180 with :
74- package : cloudinary-video-player
181+ package : ${{ steps.purge-cache.outputs.package }}
0 commit comments