@@ -582,3 +582,96 @@ jobs:
582
582
path : |
583
583
*.deb
584
584
# End build and sign Debian package
585
+
586
+ create-github-release :
587
+ runs-on : ubuntu-latest
588
+ permissions :
589
+ contents : write
590
+ needs :
591
+ - create-linux-artifacts
592
+ - create-macos-artifacts
593
+ - windows_artifacts
594
+ - prereqs
595
+ if : |
596
+ success() ||
597
+ (needs.create-linux-artifacts.result == 'skipped' &&
598
+ needs.create-macos-artifacts.result == 'success' &&
599
+ needs.windows_artifacts.result == 'success')
600
+ steps :
601
+ - name : Download Windows portable installer
602
+ uses : actions/download-artifact@v4
603
+ with :
604
+ name : win-portable-x86_64
605
+ path : win-portable-x86_64
606
+
607
+ - name : Download Windows x86_64 installer
608
+ uses : actions/download-artifact@v4
609
+ with :
610
+ name : win-installer-x86_64
611
+ path : win-installer-x86_64
612
+
613
+ - name : Download macOS artifacts
614
+ uses : actions/download-artifact@v4
615
+ with :
616
+ name : macos-artifacts
617
+ path : macos-artifacts
618
+
619
+ - name : Download Debian package
620
+ uses : actions/download-artifact@v4
621
+ with :
622
+ name : linux-artifacts
623
+ path : deb-package
624
+
625
+ - uses : actions/github-script@v6
626
+ with :
627
+ script : |
628
+ const fs = require('fs');
629
+ const path = require('path');
630
+
631
+ var releaseMetadata = {
632
+ owner: context.repo.owner,
633
+ repo: context.repo.repo
634
+ };
635
+
636
+ // Create the release
637
+ var tagName = "${{ needs.prereqs.outputs.tag_name }}";
638
+ var createdRelease = await github.rest.repos.createRelease({
639
+ ...releaseMetadata,
640
+ draft: true,
641
+ tag_name: tagName,
642
+ name: tagName
643
+ });
644
+ releaseMetadata.release_id = createdRelease.data.id;
645
+
646
+ // Uploads contents of directory to the release created above
647
+ async function uploadDirectoryToRelease(directory, includeExtensions=[]) {
648
+ return fs.promises.readdir(directory)
649
+ .then(async(files) => Promise.all(
650
+ files.filter(file => {
651
+ return includeExtensions.length==0 || includeExtensions.includes(path.extname(file).toLowerCase());
652
+ })
653
+ .map(async (file) => {
654
+ var filePath = path.join(directory, file);
655
+ github.rest.repos.uploadReleaseAsset({
656
+ ...releaseMetadata,
657
+ name: file,
658
+ headers: {
659
+ "content-length": (await fs.promises.stat(filePath)).size
660
+ },
661
+ data: fs.createReadStream(filePath)
662
+ });
663
+ }))
664
+ );
665
+ }
666
+
667
+ await Promise.all([
668
+ // Upload Windows artifacts
669
+ uploadDirectoryToRelease('win-installer-x86_64', ['.exe']),
670
+ uploadDirectoryToRelease('win-portable-x86_64', ['.exe']),
671
+
672
+ // Upload Mac artifacts
673
+ uploadDirectoryToRelease('macos-artifacts'),
674
+
675
+ // Upload Ubuntu artifacts
676
+ uploadDirectoryToRelease('deb-package')
677
+ ]);
0 commit comments