-
Notifications
You must be signed in to change notification settings - Fork 3.2k
1816 lines (1551 loc) · 75.5 KB
/
publish.yml
File metadata and controls
1816 lines (1551 loc) · 75.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: Publish
on:
workflow_dispatch:
push:
branches:
- 'release/**' # Must match RELEASE_BRANCH_PREFIX
release:
types: [created]
workflow_run:
workflows: ['Tests']
types: [completed]
branches: [develop]
env:
RELEASE_BRANCH_PREFIX: 'release/'
DOCS_BRANCH_PREFIX: 'prod-docs/'
LTS_BRANCH_PREFIX: 'lts/'
NPM_PUBLISH_VERSION: '11.6' # npm >= 11.5.1 required for trusted publishing (OIDC)
permissions:
id-token: write # Required for OIDC
contents: write
actions: read
jobs:
# ============================================================
# Scenario A — Pre-release (workflow_dispatch from non-release branch or automatically ran on develop after testing)
# ============================================================
pre-release:
name: Build and publish a pre-release
runs-on: ubuntu-latest
if: |
(github.event_name == 'workflow_dispatch' &&
!startsWith(github.ref_name, 'release/') &&
!startsWith(github.ref_name, 'lts/')) ||
(github.event_name == 'workflow_run' &&
github.event.workflow_run.conclusion == 'success')
steps:
- name: Determine branch
id: branch
run: |
if [ "${{ github.event_name }}" = "workflow_run" ]; then
echo "ref=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_OUTPUT
else
echo "ref=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # https://github.com/actions/checkout/releases/tag/v6.0.2
with:
ref: ${{ steps.branch.outputs.ref }}
- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # https://github.com/pnpm/action-setup/releases/tag/v4.2.0
name: Install pnpm
- name: Use Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # https://github.com/actions/setup-node/releases/tag/v6.2.0
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: |
pnpm install
npm install -g npm@11.6 # Ensure npm 11.5.1 or later for trusted publishing
- name: Publish pre-release
run: npm run pre-release
# ============================================================
# Scenario B — First RC (release event with prerelease flag)
# ============================================================
first-rc-build:
name: Build first RC
runs-on: ubuntu-latest
if: |
github.event_name == 'release' &&
github.event.release.prerelease == true
outputs:
release-branch: ${{ steps.create-branch.outputs.release-branch }}
rc-version: ${{ steps.version.outputs.rc-version }}
steps:
- name: Extract version from release name
id: version
run: |
# Release name is like "1.0.0-rc" → strip "-rc" to get "1.0.0"
RELEASE_NAME='${{ github.event.release.name }}'
VERSION="${RELEASE_NAME%-rc}"
RC_VERSION="${VERSION}-rc1"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "rc-version=${RC_VERSION}" >> $GITHUB_OUTPUT
echo "Extracted version: ${VERSION} (RC: ${RC_VERSION})"
- name: Checkout develop
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # https://github.com/actions/checkout/releases/tag/v6.0.2
with:
ref: develop
fetch-depth: 0
- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # https://github.com/pnpm/action-setup/releases/tag/v4.2.0
name: Install pnpm
- name: Use Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # https://github.com/actions/setup-node/releases/tag/v6.2.0
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Validate version
run: |
VERSION='${{ steps.version.outputs.version }}'
node -e "
import { isVersionValid } from './scripts/utils/pre-release.mjs';
if (!isVersionValid('${VERSION}')) {
console.error('Error: Invalid version format: ${VERSION}');
process.exit(1);
}
"
- name: Check npm version
run: |
NPM_VERSION=$(npm --version)
echo "npm version: $NPM_VERSION"
node -e "
import semver from 'semver';
if (!semver.satisfies('${NPM_VERSION}'.trim(), '>=7.17.0')) {
console.error('Error: npm >= 7.17.0 required (found ${NPM_VERSION})');
process.exit(1);
}
"
- name: Create release branch
id: create-branch
run: |
VERSION='${{ steps.version.outputs.version }}'
RELEASE_BRANCH="${RELEASE_BRANCH_PREFIX}${VERSION}"
echo "release-branch=${RELEASE_BRANCH}" >> $GITHUB_OUTPUT
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "${RELEASE_BRANCH}"
- name: Set version and release date
run: |
VERSION='${{ steps.version.outputs.version }}'
RC_VERSION="${VERSION}-rc1"
RELEASE_DATE=$(date +%d/%m/%Y)
node -e "
import { setVersion, setReleaseDate } from './scripts/utils/pre-release.mjs';
setVersion('${RC_VERSION}');
setReleaseDate('${RELEASE_DATE}');
"
- name: Clean node_modules and lock files
run: |
node -e "
import { cleanNodeModules } from './scripts/utils/filesystem.mjs';
cleanNodeModules();
"
- name: Install fresh dependencies
run: pnpm install --force
- name: Clean old package builds
run: npm run all clean -- --e examples
- name: Build all packages
run: npm run all build -- --e examples visual-tests
- name: Install next package for examples
run: npm run examples:install next
- name: Build examples
run: npm run in examples build
- name: Run Examples tests
run: npm run in examples test
- name: Verify bundles
run: node ./scripts/verify-bundles.mjs
- name: Pack tarballs
run: mkdir _tmp_packs && npm run all create-package -- --e examples --cmdArgs pack-destination="$(pwd)/_tmp_packs/"
- name: Upload build artifacts
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # https://github.com/actions/upload-artifact/releases/tag/v7.0.0
with:
name: npm_packs_${{ steps.version.outputs.rc-version }}
path: _tmp_packs/
- name: Clean up tarballs
run: rm -rf _tmp_packs
- name: Generate changelog
run: npm run changelog consume < /dev/null
- name: Extract changelog for this version
id: changelog
run: |
RC_VERSION='${{ steps.version.outputs.rc-version }}'
CONTENT=$(node .github/scripts/extract-changelog.mjs "$RC_VERSION")
{
echo "content<<EOF"
printf '%s\n' "$CONTENT"
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Update docs changelog
env:
CHANGELOG_CONTENT: ${{ steps.changelog.outputs.content }}
run: node .github/scripts/update-docs-changelog.mjs '${{ steps.version.outputs.rc-version }}'
- name: Commit and push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION='${{ steps.version.outputs.version }}'
RC_VERSION="${VERSION}-rc1"
RELEASE_BRANCH='${{ steps.create-branch.outputs.release-branch }}'
git add .
git commit -m "${RC_VERSION}" || echo "No changes to commit"
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git"
git push -u origin "${RELEASE_BRANCH}"
# Create tag via GitHub API so it's automatically verified
gh api repos/${{ github.repository }}/git/refs \
-f ref="refs/tags/${RC_VERSION}" \
-f sha="$(git rev-parse HEAD)"
- name: Update GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NOTES: ${{ steps.changelog.outputs.content }}
run: |
VERSION='${{ steps.version.outputs.version }}'
RC_VERSION="${VERSION}-rc1"
RELEASE_TAG="${VERSION}-rc"
printf '%s' "$RELEASE_NOTES" > /tmp/release-notes.md
gh release edit "${RELEASE_TAG}" --tag "${RC_VERSION}" --repo "${{ github.repository }}" --notes-file /tmp/release-notes.md
echo "Updated release '${RELEASE_TAG}' to point to tag '${RC_VERSION}'"
- name: Publication summary
run: |
VERSION='${{ steps.version.outputs.version }}'
RC_VERSION="${VERSION}-rc1"
RELEASE_BRANCH='${{ steps.create-branch.outputs.release-branch }}'
RELEASE_NAME='${{ github.event.release.name }}'
cat >> $GITHUB_STEP_SUMMARY <<EOF
# 🚀 Pre-release Publication Summary
> The following release candidate is ready to be published to npm.
## 📦 Package Details
| Property | Value |
|----------|-------|
| **Version** | \`${RC_VERSION}\` |
| **npm Tag** | \`rc\` |
| **Branch** | \`${RELEASE_BRANCH}\` |
| **Release Name** | ${RELEASE_NAME} |
## ⏳ Awaiting Approval
This job will proceed once approved by the \`approvers\` environment.
Review the details above and approve the deployment to publish to npm.
---
_Triggered by **${{ github.actor }}** on **${{ github.ref_name }}**_
EOF
first-rc-test:
name: Run tests (first RC)
needs: [first-rc-build]
uses: ./.github/workflows/test.yml
with:
test-all: true
secrets: inherit
first-rc-publish:
name: Publish first RC
runs-on: ubuntu-latest
if: ${{ !cancelled() && needs.first-rc-build.result == 'success' && needs.first-rc-test.result == 'success' }}
needs: [first-rc-build, first-rc-test]
environment: approvers
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # https://github.com/actions/checkout/releases/tag/v6.0.2
with:
ref: ${{ needs.first-rc-build.outputs.release-branch }}
- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # https://github.com/pnpm/action-setup/releases/tag/v4.2.0
name: Install pnpm
- name: Use Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # https://github.com/actions/setup-node/releases/tag/v6.2.0
with:
node-version-file: '.nvmrc'
registry-url: https://registry.npmjs.org/
- name: Download build artifacts
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # https://github.com/actions/download-artifact/releases/tag/v8.0.0
with:
name: npm_packs_${{ needs.first-rc-build.outputs.rc-version }}
path: _tmp_packs/
- name: Publish
run: |
npm install -g npm@${{ env.NPM_PUBLISH_VERSION }} # Ensure npm 11.5.1 or later for trusted publishing
echo "Publishing packages from _tmp_packs/ with tag: rc"
for TARBALL in _tmp_packs/*.tgz; do
echo "Publishing: $(basename "$TARBALL")"
npm publish "./$TARBALL" --tag rc
done
echo "All packages published successfully."
# ============================================================
# Scenario B.1 — First RC NuGet build and publish
# ============================================================
first-rc-build-nuget:
name: Build NuGet package (first RC)
runs-on: ubuntu-latest
needs: [first-rc-build]
if: ${{ !cancelled() && needs.first-rc-build.result == 'success' }}
outputs:
rc-version: ${{ needs.first-rc-build.outputs.rc-version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # https://github.com/actions/checkout/releases/tag/v6.0.2
with:
ref: ${{ needs.first-rc-build.outputs.release-branch }}
- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # https://github.com/pnpm/action-setup/releases/tag/v4.2.0
name: Install pnpm
- name: Use Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # https://github.com/actions/setup-node/releases/tag/v6.2.0
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Download npm build artifacts
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # https://github.com/actions/download-artifact/releases/tag/v8.0.0
with:
name: npm_packs_${{ needs.first-rc-build.outputs.rc-version }}
path: _tmp_packs/
- name: Unpack handsontable tarball
run: |
mkdir -p handsontable/tmp
tar -xzf _tmp_packs/handsontable-${{ needs.first-rc-build.outputs.rc-version }}.tgz \
-C handsontable/tmp --strip-components=1
- name: Install nuget
run: |
sudo apt-get update
sudo apt-get install -y mono-complete
curl -o /tmp/nuget.exe https://dist.nuget.org/win-x86-commandline/v7.3.0/nuget.exe
sudo bash -c 'echo "#!/bin/bash" > /usr/local/bin/nuget && echo "exec mono /tmp/nuget.exe \"\$@\"" >> /usr/local/bin/nuget && chmod +x /usr/local/bin/nuget'
- name: Generate NuGet package
run: node .github/scripts/generate-nuget-package.mjs
- name: Upload NuGet package artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # https://github.com/actions/upload-artifact/releases/tag/v7.0.0
with:
name: nuget_pack_${{ needs.first-rc-build.outputs.rc-version }}
path: Handsontable.*.nupkg
- name: Clean up NuGet package
run: rm -f Handsontable.*.nupkg
first-rc-publish-nuget:
name: Publish NuGet package (first RC)
runs-on: ubuntu-latest
if: ${{ !cancelled() && needs.first-rc-build.result == 'success' && needs.first-rc-test.result == 'success' && needs.first-rc-build-nuget.result == 'success' }}
needs: [first-rc-build, first-rc-test, first-rc-build-nuget]
environment: approvers
steps:
- name: Download NuGet package artifact
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # https://github.com/actions/download-artifact/releases/tag/v8.0.0
with:
name: nuget_pack_${{ needs.first-rc-build.outputs.rc-version }}
- name: NuGet login (OIDC trusted publishing)
uses: NuGet/login@d22cc5f58ff5b88bf9bd452535b4335137e24544 # https://github.com/NuGet/login/releases/tag/v1.0.0
id: nuget-login
with:
user: ${{ secrets.NUGET_USER }}
- name: Publish NuGet package
run: |
NUPKG=$(ls *.nupkg)
echo "Publishing: $NUPKG"
dotnet nuget push "$NUPKG" \
--api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" \
--source https://api.nuget.org/v3/index.json
first-rc-notify:
name: Notify Slack (first RC)
runs-on: ubuntu-latest
if: ${{ !cancelled() && needs.first-rc-publish.result != 'skipped' }}
needs: [first-rc-build, first-rc-publish, first-rc-publish-nuget]
steps:
- name: Prepare and send Slack message
env:
RC_VERSION: ${{ needs.first-rc-build.outputs.rc-version }}
RELEASE_BRANCH: ${{ needs.first-rc-build.outputs.release-branch }}
NPM_RESULT: ${{ needs.first-rc-publish.result }}
NUGET_RESULT: ${{ needs.first-rc-publish-nuget.result }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
run: |
if [ "$NPM_RESULT" = "success" ]; then
STATUS=":white_check_mark: Success"; NPM_STATUS=":white_check_mark: :npm: *npm*"; NPM_OK="true"
else
STATUS=":x: Failed"; NPM_STATUS=":x: :npm: *npm*"; NPM_OK="false"
fi
if [ "$NUGET_RESULT" = "success" ]; then NUGET_STATUS=":white_check_mark: :nuget: *NuGet*"; else NUGET_STATUS=":x: :nuget: *NuGet*"; fi
CHANGELOG_URL="${REPO_URL}/blob/${RELEASE_BRANCH}/CHANGELOG.md"
jq -n \
--arg version "${RC_VERSION}" \
--arg branch "${RELEASE_BRANCH}" \
--arg status "$STATUS" \
--arg npm_status "$NPM_STATUS" \
--arg npm_ok "$NPM_OK" \
--arg nuget_status "$NUGET_STATUS" \
--arg changelog_url "$CHANGELOG_URL" \
--arg repo_url "${REPO_URL}" \
--arg run_url "${RUN_URL}" \
'{
text: (if $npm_ok == "true" then "🚀 Version " + $version + " released!" else "❌ Release of version " + $version + " failed." end),
blocks: [
(if $npm_ok == "true" then
{ type: "header", text: { type: "plain_text", text: ("🚀 Version " + $version + " released!"), emoji: true } }
else
{ type: "section", text: { type: "mrkdwn", text: (":x: *Release of version " + $version + " failed.* Check the <" + $run_url + "|GitHub Actions run> for details.") } }
end),
{
type: "section",
text: { type: "mrkdwn", text: "⚠️ *This is a pre-release.* Not intended for production use." }
},
{
type: "section",
fields: [
{ type: "mrkdwn", text: ("*Status*\n" + $status) },
{ type: "mrkdwn", text: "*Type*\n🔖 Pre-release" },
{ type: "mrkdwn", text: ("*Version*\n<https://www.npmjs.com/package/handsontable/v/" + $version + "|" + $version + ">") },
{ type: "mrkdwn", text: ("*Branch*\n<" + $repo_url + "/tree/" + $branch + "|" + $branch + ">") }
]
},
{ type: "divider" },
{
type: "section",
fields: [
{ type: "mrkdwn", text: ":white_check_mark: :github: *GitHub*" },
{ type: "mrkdwn", text: $npm_status },
{ type: "mrkdwn", text: $nuget_status }
]
},
{ type: "divider" },
{
type: "section",
text: {
type: "mrkdwn",
text: ("*📋 Changelog*\n<" + $changelog_url + "|View CHANGELOG.md>" + if $npm_ok == "true" then "\n\n*🎮 Demos*\n• :javascript: <https://handsontable.com/codesandbox-browser?example-dir=javascript&handsontable-version=" + $version + "|JS>\n• :react: <https://handsontable.com/codesandbox-browser?example-dir=react&handsontable-version=" + $version + "|React>\n• :angular: <https://handsontable.com/codesandbox-vm?example-dir=angular&handsontable-version=" + $version + "|Angular>\n• :vue: <https://handsontable.com/codesandbox-vm?example-dir=vue&handsontable-version=" + $version + "|Vue>\n• :typescript: <https://handsontable.com/codesandbox-browser?example-dir=typescript&handsontable-version=" + $version + "|TypeScript>" else "" end)
}
},
{
type: "context",
elements: [{ type: "mrkdwn", text: ("<" + $run_url + "|🔗 View GitHub Actions run>") }]
}
]
}' > /tmp/slack-payload.json
echo "Slack payload:"
cat /tmp/slack-payload.json
- name: Notify Slack
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
with:
webhook: ${{ secrets.SLACK_RELEASE_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload-file-path: /tmp/slack-payload.json
# ============================================================
# Scenario C — Subsequent RC (push to release/**)
# ============================================================
rc-check:
name: Guard RC build
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/')
outputs:
allowed: ${{ steps.check.outputs.allowed }}
steps:
- name: Extract version from branch name
id: version
run: |
REF_NAME='${{ github.ref_name }}'
VERSION="${REF_NAME#${RELEASE_BRANCH_PREFIX}}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Check if stable release already exists
id: check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION='${{ steps.version.outputs.version }}'
STABLE_COUNT=$(gh release list --repo "${{ github.repository }}" --json tagName,isPrerelease \
--jq "[.[] | select(.tagName == \"${VERSION}\" and (.isPrerelease | not))] | length")
if [ "$STABLE_COUNT" -gt 0 ]; then
echo "::notice::Stable release ${VERSION} already exists — skipping RC build."
echo "allowed=false" >> $GITHUB_OUTPUT
else
echo "allowed=true" >> $GITHUB_OUTPUT
fi
rc-build:
name: Build RC
runs-on: ubuntu-latest
needs: [rc-check]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/') && needs.rc-check.outputs.allowed == 'true'
outputs:
rc-version: ${{ steps.rc-version.outputs.rc-version }}
changelog-synced: ${{ steps.sync-changelog.outputs.synced }}
steps:
- name: Extract version from branch name
id: version
run: |
REF_NAME='${{ github.ref_name }}'
VERSION="${REF_NAME#${RELEASE_BRANCH_PREFIX}}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Version from branch: ${VERSION}"
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # https://github.com/actions/checkout/releases/tag/v6.0.2
with:
ref: ${{ github.ref_name }}
fetch-depth: 0
- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # https://github.com/pnpm/action-setup/releases/tag/v4.2.0
name: Install pnpm
- name: Use Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # https://github.com/actions/setup-node/releases/tag/v6.2.0
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check npm version
run: |
NPM_VERSION=$(npm --version)
echo "npm version: $NPM_VERSION"
node -e "
import semver from 'semver';
if (!semver.satisfies('${NPM_VERSION}'.trim(), '>=7.17.0')) {
console.error('Error: npm >= 7.17.0 required (found ${NPM_VERSION})');
process.exit(1);
}
"
- name: Determine next RC version
id: rc-version
run: |
VERSION='${{ steps.version.outputs.version }}'
echo "Determining next RC version for ${VERSION}..."
git fetch --tags
HIGHEST_RC=$(git tag --list "${VERSION}-rc*" | sed -n "s/^${VERSION}-rc\([0-9]\+\)$/\1/p" | sort -n | tail -n 1)
if [ -z "$HIGHEST_RC" ]; then
echo "No existing RC tags found for ${VERSION}, starting at rc1"
RC_VERSION="${VERSION}-rc1"
else
echo "Highest existing RC tag: ${VERSION}-rc${HIGHEST_RC}"
RC_VERSION="${VERSION}-rc$((HIGHEST_RC + 1))"
fi
echo "rc-version=${RC_VERSION}" >> $GITHUB_OUTPUT
echo "Next RC version: ${RC_VERSION}"
- name: Set version and release date
run: |
RC_VERSION='${{ steps.rc-version.outputs.rc-version }}'
RELEASE_DATE=$(date +%d/%m/%Y)
node -e "
import { setVersion, setReleaseDate } from './scripts/utils/pre-release.mjs';
setVersion('${RC_VERSION}');
setReleaseDate('${RELEASE_DATE}');
"
- name: Update lockfile for version change
run: pnpm install --lockfile-only
- name: Clean old package builds
run: npm run all clean -- --e examples
- name: Build all packages
run: npm run all build -- --e examples visual-tests
- name: Verify bundles
run: node ./scripts/verify-bundles.mjs
- name: Pack tarballs
run: mkdir _tmp_packs && npm run all create-package -- --e examples --cmdArgs pack-destination="$(pwd)/_tmp_packs/"
- name: Upload build artifacts
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # https://github.com/actions/upload-artifact/releases/tag/v7.0.0
with:
name: npm_packs_${{ steps.rc-version.outputs.rc-version }}
path: _tmp_packs/
- name: Clean up tarballs
run: rm -rf _tmp_packs
- name: Update changelog RC version and date
run: |
VERSION='${{ steps.version.outputs.version }}'
RC_VERSION='${{ steps.rc-version.outputs.rc-version }}'
TODAY=$(date +%Y-%m-%d)
PATTERN="^## \[${VERSION}-rc[0-9]\+\] - [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}$"
MATCHES=$(grep -c "$PATTERN" CHANGELOG.md || true)
if [ "$MATCHES" -ne 1 ]; then
echo "::error::Expected exactly 1 matching line in CHANGELOG.md for version ${VERSION}-rcX, found ${MATCHES}"
exit 1
fi
sed -i "s/${PATTERN}/## [${RC_VERSION}] - ${TODAY}/" CHANGELOG.md
echo "Updated CHANGELOG.md: ## [${RC_VERSION}] - ${TODAY}"
- name: Sync pending changelog entries
id: sync-changelog
run: |
if ls .changelogs/*.json 2>/dev/null | grep -q .; then
npm run changelog sync < /dev/null
echo "synced=true" >> $GITHUB_OUTPUT
else
echo "No pending changelog entries to sync."
echo "synced=false" >> $GITHUB_OUTPUT
fi
- name: Extract changelog for this version
id: changelog
run: |
RC_VERSION='${{ steps.rc-version.outputs.rc-version }}'
CONTENT=$(node .github/scripts/extract-changelog.mjs "$RC_VERSION")
{
echo "content<<EOF"
printf '%s\n' "$CONTENT"
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Update docs changelog
env:
CHANGELOG_CONTENT: ${{ steps.changelog.outputs.content }}
run: node .github/scripts/update-docs-changelog.mjs '${{ steps.rc-version.outputs.rc-version }}'
- name: Commit and push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RC_VERSION='${{ steps.rc-version.outputs.rc-version }}'
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "${RC_VERSION}" || echo "No changes to commit"
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git"
git push origin HEAD:${{ github.ref_name }}
# Create tag via GitHub API so it's automatically verified
gh api repos/${{ github.repository }}/git/refs \
-f ref="refs/tags/${RC_VERSION}" \
-f sha="$(git rev-parse HEAD)"
- name: Update GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NOTES: ${{ steps.changelog.outputs.content }}
run: |
VERSION='${{ steps.version.outputs.version }}'
RC_VERSION='${{ steps.rc-version.outputs.rc-version }}'
RC_NUMBER=$(echo "$RC_VERSION" | sed -n "s/^${VERSION}-rc\([0-9]\+\)$/\1/p")
PREVIOUS_TAG="${VERSION}-rc$((RC_NUMBER - 1))"
printf '%s' "$RELEASE_NOTES" > /tmp/release-notes.md
gh release edit "${PREVIOUS_TAG}" --tag "${RC_VERSION}" --repo "${{ github.repository }}" --notes-file /tmp/release-notes.md
echo "Updated release '${PREVIOUS_TAG}' to point to tag '${RC_VERSION}'"
- name: Publication summary
run: |
RC_VERSION='${{ steps.rc-version.outputs.rc-version }}'
BRANCH='${{ github.ref_name }}'
cat >> $GITHUB_STEP_SUMMARY <<EOF
# 🚀 Pre-release Publication Summary
> The following release candidate is ready to be published to npm.
## 📦 Package Details
| Property | Value |
|----------|-------|
| **Version** | \`${RC_VERSION}\` |
| **npm Tag** | \`rc\` |
| **Branch** | \`${BRANCH}\` |
## ⏳ Awaiting Approval
This job will proceed once approved by the \`approvers\` environment.
Review the details above and approve the deployment to publish to npm.
---
_Triggered by **${{ github.actor }}** on **${{ github.ref_name }}**_
EOF
rc-test:
name: Run tests (RC)
needs: [rc-build]
uses: ./.github/workflows/test.yml
with:
test-all: true
secrets: inherit
rc-publish:
name: Publish RC
runs-on: ubuntu-latest
if: ${{ !cancelled() && needs.rc-build.result == 'success' && needs.rc-test.result == 'success' }}
needs: [rc-build, rc-test]
environment: approvers
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # https://github.com/actions/checkout/releases/tag/v6.0.2
with:
ref: ${{ github.ref_name }}
- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # https://github.com/pnpm/action-setup/releases/tag/v4.2.0
name: Install pnpm
- name: Use Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # https://github.com/actions/setup-node/releases/tag/v6.2.0
with:
node-version-file: '.nvmrc'
registry-url: https://registry.npmjs.org/
- name: Download build artifacts
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # https://github.com/actions/download-artifact/releases/tag/v8.0.0
with:
name: npm_packs_${{ needs.rc-build.outputs.rc-version }}
path: _tmp_packs/
- name: Publish
run: |
npm install -g npm@${{ env.NPM_PUBLISH_VERSION }} # Ensure npm 11.5.1 or later for trusted publishing
echo "Publishing packages from _tmp_packs/ with tag: rc"
for TARBALL in _tmp_packs/*.tgz; do
echo "Publishing: $(basename "$TARBALL")"
npm publish "./$TARBALL" --tag rc
done
echo "All packages published successfully."
# ============================================================
# Scenario C.1 — Subsequent RC NuGet build and publish
# ============================================================
rc-build-nuget:
name: Build NuGet package (RC)
runs-on: ubuntu-latest
needs: [rc-build]
if: ${{ !cancelled() && needs.rc-build.result == 'success' }}
outputs:
rc-version: ${{ needs.rc-build.outputs.rc-version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # https://github.com/actions/checkout/releases/tag/v6.0.2
with:
ref: ${{ github.ref_name }}
- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # https://github.com/pnpm/action-setup/releases/tag/v4.2.0
name: Install pnpm
- name: Use Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # https://github.com/actions/setup-node/releases/tag/v6.2.0
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Download npm build artifacts
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # https://github.com/actions/download-artifact/releases/tag/v8.0.0
with:
name: npm_packs_${{ needs.rc-build.outputs.rc-version }}
path: _tmp_packs/
- name: Unpack handsontable tarball
run: |
mkdir -p handsontable/tmp
tar -xzf _tmp_packs/handsontable-${{ needs.rc-build.outputs.rc-version }}.tgz \
-C handsontable/tmp --strip-components=1
- name: Install nuget
run: |
sudo apt-get update
sudo apt-get install -y mono-complete
curl -o /tmp/nuget.exe https://dist.nuget.org/win-x86-commandline/v7.3.0/nuget.exe
sudo bash -c 'echo "#!/bin/bash" > /usr/local/bin/nuget && echo "exec mono /tmp/nuget.exe \"\$@\"" >> /usr/local/bin/nuget && chmod +x /usr/local/bin/nuget'
- name: Generate NuGet package
run: node .github/scripts/generate-nuget-package.mjs
- name: Upload NuGet package artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # https://github.com/actions/upload-artifact/releases/tag/v7.0.0
with:
name: nuget_pack_${{ needs.rc-build.outputs.rc-version }}
path: Handsontable.*.nupkg
- name: Clean up NuGet package
run: rm -f Handsontable.*.nupkg
rc-publish-nuget:
name: Publish NuGet package (RC)
runs-on: ubuntu-latest
if: ${{ !cancelled() && needs.rc-build.result == 'success' && needs.rc-test.result == 'success' && needs.rc-build-nuget.result == 'success' }}
needs: [rc-build, rc-test, rc-build-nuget]
environment: approvers
steps:
- name: Download NuGet package artifact
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # https://github.com/actions/download-artifact/releases/tag/v8.0.0
with:
name: nuget_pack_${{ needs.rc-build.outputs.rc-version }}
- name: NuGet login (OIDC trusted publishing)
uses: NuGet/login@d22cc5f58ff5b88bf9bd452535b4335137e24544 # https://github.com/NuGet/login/releases/tag/v1.0.0
id: nuget-login
with:
user: ${{ secrets.NUGET_USER }}
- name: Publish NuGet package
run: |
NUPKG=$(ls *.nupkg)
echo "Publishing: $NUPKG"
dotnet nuget push "$NUPKG" \
--api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" \
--source https://api.nuget.org/v3/index.json
rc-notify:
name: Notify Slack (RC)
runs-on: ubuntu-latest
if: ${{ !cancelled() && needs.rc-publish.result != 'skipped' }}
needs: [rc-build, rc-publish, rc-publish-nuget]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # https://github.com/actions/checkout/releases/tag/v6.0.2
with:
ref: ${{ github.ref_name }}
fetch-depth: 0
- name: Prepare and send Slack message
env:
RC_VERSION: ${{ needs.rc-build.outputs.rc-version }}
CHANGELOG_SYNCED: ${{ needs.rc-build.outputs.changelog-synced }}
NPM_RESULT: ${{ needs.rc-publish.result }}
NUGET_RESULT: ${{ needs.rc-publish-nuget.result }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
run: |
if [ "$NPM_RESULT" = "success" ]; then
STATUS=":white_check_mark: Success"; NPM_STATUS=":white_check_mark: :npm: *npm*"; NPM_OK="true"
else
STATUS=":x: Failed"; NPM_STATUS=":x: :npm: *npm*"; NPM_OK="false"
fi
if [ "$NUGET_RESULT" = "success" ]; then NUGET_STATUS=":white_check_mark: :nuget: *NuGet*"; else NUGET_STATUS=":x: :nuget: *NuGet*"; fi
BASE_VERSION=$(echo "$RC_VERSION" | sed 's/-rc[0-9]*//')
RC_NUMBER=$(echo "$RC_VERSION" | sed -n 's/.*-rc\([0-9]*\)/\1/p')
PREV_TAG="${BASE_VERSION}-rc$((RC_NUMBER - 1))"
RELEASE_BRANCH="${{ github.ref_name }}"
CHANGELOG_URL="${REPO_URL}/blob/${RELEASE_BRANCH}/CHANGELOG.md"
git fetch --unshallow 2>/dev/null || true
git fetch --tags --quiet
COMMITS_TEXT=""
if git rev-parse "$PREV_TAG" >/dev/null 2>&1; then
COMMITS=$(git log "${PREV_TAG}..HEAD" --pretty=format:"%H %s" --no-merges)
if [ -n "$COMMITS" ]; then
while IFS= read -r line; do
SHA=$(echo "$line" | cut -d' ' -f1)
MSG=$(echo "$line" | cut -d' ' -f2-)
COMMITS_TEXT="${COMMITS_TEXT}• <${REPO_URL}/commit/${SHA}|${MSG}>"$'\n'
done <<< "$COMMITS"
fi
fi
if [ -z "$COMMITS_TEXT" ]; then
COMMITS_TEXT="No commits found since \`${PREV_TAG}\`."
fi
jq -n \
--arg version "${RC_VERSION}" \
--arg branch "${RELEASE_BRANCH}" \
--arg status "$STATUS" \
--arg npm_status "$NPM_STATUS" \
--arg npm_ok "$NPM_OK" \
--arg nuget_status "$NUGET_STATUS" \
--arg prev_tag "${PREV_TAG}" \
--arg commits "$COMMITS_TEXT" \
--arg changelog_synced "${CHANGELOG_SYNCED}" \
--arg changelog_url "$CHANGELOG_URL" \
--arg run_url "${RUN_URL}" \
--arg repo_url "${REPO_URL}" \
'{
text: (if $npm_ok == "true" then "🚀 Version " + $version + " released!" else "❌ Release of version " + $version + " failed." end),
blocks: [
(if $npm_ok == "true" then
{ type: "header", text: { type: "plain_text", text: ("🚀 Version " + $version + " released!"), emoji: true } }
else
{ type: "section", text: { type: "mrkdwn", text: (":x: *Release of version " + $version + " failed.* Check the <" + $run_url + "|GitHub Actions run> for details.") } }
end),
{
type: "section",
text: { type: "mrkdwn", text: "⚠️ *This is a pre-release.* Not intended for production use." }
},
{
type: "section",
fields: [
{ type: "mrkdwn", text: ("*Status*\n" + $status) },
{ type: "mrkdwn", text: "*Type*\n🔖 Pre-release" },
{ type: "mrkdwn", text: ("*Version*\n<https://www.npmjs.com/package/handsontable/v/" + $version + "|" + $version + ">") },
{ type: "mrkdwn", text: ("*Branch*\n<" + $repo_url + "/tree/" + $branch + "|" + $branch + ">") }
]
},
{ type: "divider" },
{
type: "section",
fields: [
{ type: "mrkdwn", text: ":white_check_mark: :github: *GitHub*" },
{ type: "mrkdwn", text: $npm_status },
{ type: "mrkdwn", text: $nuget_status }
]
},
{ type: "divider" },
{
type: "section",
text: { type: "mrkdwn", text: ("*Commits since `" + $prev_tag + "`*\n" + $commits) }
},
if $changelog_synced == "true" then
{
type: "context",
elements: [{ type: "mrkdwn", text: "❗ *Changelog extended with new entries!*" }]
}
else empty end,
{ type: "divider" },
{
type: "section",
text: {
type: "mrkdwn",
text: ("*📋 Changelog*\n<" + $changelog_url + "|View CHANGELOG.md>" + if $npm_ok == "true" then "\n\n*🎮 Demos*\n• :javascript: <https://handsontable.com/codesandbox-browser?example-dir=javascript&handsontable-version=" + $version + "|JS>\n• :react: <https://handsontable.com/codesandbox-browser?example-dir=react&handsontable-version=" + $version + "|React>\n• :angular: <https://handsontable.com/codesandbox-vm?example-dir=angular&handsontable-version=" + $version + "|Angular>\n• :vue: <https://handsontable.com/codesandbox-vm?example-dir=vue&handsontable-version=" + $version + "|Vue>\n• :typescript: <https://handsontable.com/codesandbox-browser?example-dir=typescript&handsontable-version=" + $version + "|TypeScript>" else "" end)
}
},
{
type: "context",
elements: [{ type: "mrkdwn", text: ("<" + $run_url + "|🔗 View GitHub Actions run>") }]
}
]
}' > /tmp/slack-payload.json
echo "Slack payload:"
cat /tmp/slack-payload.json
- name: Notify Slack
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
with:
webhook: ${{ secrets.SLACK_RELEASE_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload-file-path: /tmp/slack-payload.json
# ============================================================
# Scenario D — Stable release (release event, not prerelease)
# ============================================================
stable-prepare:
name: Prepare stable release
runs-on: ubuntu-latest
if: |