@@ -625,3 +625,112 @@ jobs:
625
625
path : |
626
626
*.deb
627
627
# End build and sign Debian package
628
+
629
+ create-github-release :
630
+ runs-on : ubuntu-latest
631
+ permissions :
632
+ contents : write
633
+ needs :
634
+ - create-linux-artifacts
635
+ - create-macos-artifacts
636
+ - windows_artifacts
637
+ - prereqs
638
+ if : |
639
+ success() ||
640
+ (needs.create-linux-artifacts.result == 'skipped' &&
641
+ needs.create-macos-artifacts.result == 'success' &&
642
+ needs.windows_artifacts.result == 'success')
643
+ steps :
644
+ - name : Download Windows portable (x86_64)
645
+ uses : actions/download-artifact@v4
646
+ with :
647
+ name : win-portable-x86_64
648
+ path : win-portable-x86_64
649
+
650
+ - name : Download Windows portable (aarch64)
651
+ uses : actions/download-artifact@v4
652
+ with :
653
+ name : win-portable-aarch64
654
+ path : win-portable-aarch64
655
+
656
+ - name : Download Windows installer (x86_64)
657
+ uses : actions/download-artifact@v4
658
+ with :
659
+ name : win-installer-x86_64
660
+ path : win-installer-x86_64
661
+
662
+ - name : Download Windows installer (aarch64)
663
+ uses : actions/download-artifact@v4
664
+ with :
665
+ name : win-installer-aarch64
666
+ path : win-installer-aarch64
667
+
668
+ - name : Download macOS artifacts
669
+ uses : actions/download-artifact@v4
670
+ with :
671
+ name : macos-artifacts
672
+ path : macos-artifacts
673
+
674
+ - name : Download Debian package
675
+ uses : actions/download-artifact@v4
676
+ with :
677
+ name : linux-artifacts
678
+ path : deb-package
679
+
680
+ - uses : actions/github-script@v6
681
+ with :
682
+ script : |
683
+ const fs = require('fs');
684
+ const path = require('path');
685
+
686
+ var releaseMetadata = {
687
+ owner: context.repo.owner,
688
+ repo: context.repo.repo
689
+ };
690
+
691
+ // Create the release
692
+ var tagName = "${{ needs.prereqs.outputs.tag_name }}";
693
+ var createdRelease = await github.rest.repos.createRelease({
694
+ ...releaseMetadata,
695
+ draft: true,
696
+ tag_name: tagName,
697
+ name: tagName
698
+ });
699
+ releaseMetadata.release_id = createdRelease.data.id;
700
+
701
+ // Uploads contents of directory to the release created above
702
+ async function uploadDirectoryToRelease(directory, includeExtensions=[]) {
703
+ return fs.promises.readdir(directory)
704
+ .then(async(files) => Promise.all(
705
+ files.filter(file => {
706
+ return includeExtensions.length==0 || includeExtensions.includes(path.extname(file).toLowerCase());
707
+ })
708
+ .map(async (file) => {
709
+ var filePath = path.join(directory, file);
710
+ github.rest.repos.uploadReleaseAsset({
711
+ ...releaseMetadata,
712
+ name: file,
713
+ headers: {
714
+ "content-length": (await fs.promises.stat(filePath)).size
715
+ },
716
+ data: fs.createReadStream(filePath)
717
+ });
718
+ }))
719
+ );
720
+ }
721
+
722
+ await Promise.all([
723
+ // Upload Windows x86_64 artifacts
724
+ uploadDirectoryToRelease('win-installer-x86_64', ['.exe']),
725
+ uploadDirectoryToRelease('win-portable-x86_64', ['.exe']),
726
+
727
+ // Upload Windows aarch64 artifacts
728
+ uploadDirectoryToRelease('win-installer-aarch64', ['.exe']),
729
+ uploadDirectoryToRelease('win-portable-aarch64', ['.exe']),
730
+
731
+ // Upload Mac artifacts
732
+ uploadDirectoryToRelease('macos-artifacts'),
733
+
734
+ // Upload Ubuntu artifacts
735
+ uploadDirectoryToRelease('deb-package')
736
+ ]);
0 commit comments