@@ -680,3 +680,99 @@ jobs:
680680 name : deb-package-signed
681681 path : signed
682682 # End build & sign Ubuntu package
683+
684+ create-github-release :
685+ runs-on : ubuntu-latest
686+ needs : [prereqs, windows_artifacts, osx_publish_dmg, ubuntu_sign-artifacts]
687+ if : |
688+ success() ||
689+ (needs.ubuntu_sign-artifacts.result == 'skipped' &&
690+ needs.osx_publish_dmg.result == 'success' &&
691+ needs.windows_artifacts.result == 'success')
692+ steps :
693+ - name : Download Windows portable installer
694+ uses : actions/download-artifact@v2
695+ with :
696+ name : win-portable-x86_64
697+ path : win-portable-x86_64
698+ - name : Download Windows x86_64 installer
699+ uses : actions/download-artifact@v2
700+ with :
701+ name : win-installer-x86_64
702+ path : win-installer-x86_64
703+ - name : Download Mac dmg
704+ uses : actions/download-artifact@v2
705+ with :
706+ name : osx-dmg
707+ path : osx-dmg
708+ - name : Download Mac pkg
709+ uses : actions/download-artifact@v2
710+ with :
711+ name : osx-signed-pkg
712+ path : osx-pkg
713+ - name : Download Ubuntu package (signed)
714+ if : needs.prereqs.outputs.deb_signable == 'true'
715+ uses : actions/download-artifact@v2
716+ with :
717+ name : deb-package-signed
718+ path : deb-package
719+ - name : Download Ubuntu package (unsigned)
720+ if : needs.prereqs.outputs.deb_signable != 'true'
721+ uses : actions/download-artifact@v2
722+ with :
723+ name : deb-package-unsigned
724+ path : deb-package
725+ - uses : actions/github-script@v4
726+ with :
727+ script : |
728+ const fs = require('fs');
729+ const path = require('path');
730+
731+ var releaseMetadata = {
732+ owner: context.repo.owner,
733+ repo: context.repo.repo
734+ };
735+
736+ // Create the release
737+ var tagName = "${{ needs.prereqs.outputs.tag_name }}";
738+ var createdRelease = await github.repos.createRelease({
739+ ...releaseMetadata,
740+ draft: true,
741+ tag_name: tagName,
742+ name: tagName
743+ });
744+ releaseMetadata.release_id = createdRelease.data.id;
745+
746+ // Uploads contents of directory to the release created above
747+ async function uploadDirectoryToRelease(directory, includeExtensions=[]) {
748+ return fs.promises.readdir(directory)
749+ .then(async(files) => Promise.all(
750+ files.filter(file => {
751+ return includeExtensions.length==0 || includeExtensions.includes(path.extname(file).toLowerCase());
752+ })
753+ .map(async (file) => {
754+ var filePath = path.join(directory, file);
755+ github.repos.uploadReleaseAsset({
756+ ...releaseMetadata,
757+ name: file,
758+ headers: {
759+ "content-length": (await fs.promises.stat(filePath)).size
760+ },
761+ data: fs.createReadStream(filePath)
762+ });
763+ }))
764+ );
765+ }
766+
767+ await Promise.all([
768+ // Upload Windows artifacts
769+ uploadDirectoryToRelease('win-installer-x86_64', ['.exe']),
770+ uploadDirectoryToRelease('win-portable-x86_64', ['.exe']),
771+
772+ // Upload Mac artifacts
773+ uploadDirectoryToRelease('osx-dmg'),
774+ uploadDirectoryToRelease('osx-pkg'),
775+
776+ // Upload Ubuntu artifacts
777+ uploadDirectoryToRelease('deb-package')
778+ ]);
0 commit comments