@@ -699,3 +699,112 @@ jobs:
699
699
path : |
700
700
*.deb
701
701
# End build and sign Debian package
702
+
703
+ create-github-release :
704
+ runs-on : ubuntu-latest
705
+ permissions :
706
+ contents : write
707
+ needs :
708
+ - create-linux-artifacts
709
+ - create-macos-artifacts
710
+ - windows_artifacts
711
+ - prereqs
712
+ if : |
713
+ success() ||
714
+ (needs.create-linux-artifacts.result == 'skipped' &&
715
+ needs.create-macos-artifacts.result == 'success' &&
716
+ needs.windows_artifacts.result == 'success')
717
+ steps :
718
+ - name : Download Windows portable (x86_64)
719
+ uses : actions/download-artifact@v4
720
+ with :
721
+ name : win-portable-x86_64
722
+ path : win-portable-x86_64
723
+
724
+ - name : Download Windows portable (aarch64)
725
+ uses : actions/download-artifact@v4
726
+ with :
727
+ name : win-portable-aarch64
728
+ path : win-portable-aarch64
729
+
730
+ - name : Download Windows installer (x86_64)
731
+ uses : actions/download-artifact@v4
732
+ with :
733
+ name : win-installer-x86_64
734
+ path : win-installer-x86_64
735
+
736
+ - name : Download Windows installer (aarch64)
737
+ uses : actions/download-artifact@v4
738
+ with :
739
+ name : win-installer-aarch64
740
+ path : win-installer-aarch64
741
+
742
+ - name : Download macOS artifacts
743
+ uses : actions/download-artifact@v4
744
+ with :
745
+ name : macos-artifacts
746
+ path : macos-artifacts
747
+
748
+ - name : Download Debian package
749
+ uses : actions/download-artifact@v4
750
+ with :
751
+ name : linux-artifacts
752
+ path : deb-package
753
+
754
+ - uses : actions/github-script@v6
755
+ with :
756
+ script : |
757
+ const fs = require('fs');
758
+ const path = require('path');
759
+
760
+ var releaseMetadata = {
761
+ owner: context.repo.owner,
762
+ repo: context.repo.repo
763
+ };
764
+
765
+ // Create the release
766
+ var tagName = "${{ needs.prereqs.outputs.tag_name }}";
767
+ var createdRelease = await github.rest.repos.createRelease({
768
+ ...releaseMetadata,
769
+ draft: true,
770
+ tag_name: tagName,
771
+ name: tagName
772
+ });
773
+ releaseMetadata.release_id = createdRelease.data.id;
774
+
775
+ // Uploads contents of directory to the release created above
776
+ async function uploadDirectoryToRelease(directory, includeExtensions=[]) {
777
+ return fs.promises.readdir(directory)
778
+ .then(async(files) => Promise.all(
779
+ files.filter(file => {
780
+ return includeExtensions.length==0 || includeExtensions.includes(path.extname(file).toLowerCase());
781
+ })
782
+ .map(async (file) => {
783
+ var filePath = path.join(directory, file);
784
+ github.rest.repos.uploadReleaseAsset({
785
+ ...releaseMetadata,
786
+ name: file,
787
+ headers: {
788
+ "content-length": (await fs.promises.stat(filePath)).size
789
+ },
790
+ data: fs.createReadStream(filePath)
791
+ });
792
+ }))
793
+ );
794
+ }
795
+
796
+ await Promise.all([
797
+ // Upload Windows x86_64 artifacts
798
+ uploadDirectoryToRelease('win-installer-x86_64', ['.exe']),
799
+ uploadDirectoryToRelease('win-portable-x86_64', ['.exe']),
800
+
801
+ // Upload Windows aarch64 artifacts
802
+ uploadDirectoryToRelease('win-installer-aarch64', ['.exe']),
803
+ uploadDirectoryToRelease('win-portable-aarch64', ['.exe']),
804
+
805
+ // Upload Mac artifacts
806
+ uploadDirectoryToRelease('macos-artifacts'),
807
+
808
+ // Upload Ubuntu artifacts
809
+ uploadDirectoryToRelease('deb-package')
810
+ ]);
0 commit comments