Skip to content

Commit 9a2ab21

Browse files
vdyeldennington
authored andcommitted
release: create draft GitHub release with packages & installers
- create release & uploads artifact using Octokit - use job "if" condition to handle uploading signed *or* unsigned .deb Co-authored-by: Lessley Dennington <[email protected]>
1 parent b09d662 commit 9a2ab21

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

.github/workflows/build-git-installers.yml

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

0 commit comments

Comments
 (0)