Skip to content

Commit c7cd57b

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 <ldennington@github.com>
1 parent c000de0 commit c7cd57b

1 file changed

Lines changed: 116 additions & 0 deletions

File tree

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

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,3 +729,119 @@ jobs:
729729
path: |
730730
*.deb
731731
# End build and sign Debian package
732+
733+
create-github-release:
734+
runs-on: ubuntu-latest
735+
permissions:
736+
contents: write
737+
needs:
738+
- create-linux-artifacts
739+
- create-macos-artifacts
740+
- windows_artifacts
741+
- prereqs
742+
if: |
743+
success() ||
744+
(needs.create-linux-artifacts.result == 'skipped' &&
745+
needs.create-macos-artifacts.result == 'success' &&
746+
needs.windows_artifacts.result == 'success')
747+
steps:
748+
- name: Download Windows portable (x86_64)
749+
uses: actions/download-artifact@v4
750+
with:
751+
name: win-portable-x86_64
752+
path: win-portable-x86_64
753+
754+
- name: Download Windows portable (aarch64)
755+
uses: actions/download-artifact@v4
756+
with:
757+
name: win-portable-aarch64
758+
path: win-portable-aarch64
759+
760+
- name: Download Windows installer (x86_64)
761+
uses: actions/download-artifact@v4
762+
with:
763+
name: win-installer-x86_64
764+
path: win-installer-x86_64
765+
766+
- name: Download Windows installer (aarch64)
767+
uses: actions/download-artifact@v4
768+
with:
769+
name: win-installer-aarch64
770+
path: win-installer-aarch64
771+
772+
- name: Download macOS artifacts
773+
uses: actions/download-artifact@v4
774+
with:
775+
name: macos-artifacts
776+
path: macos-artifacts
777+
778+
- name: Download Debian package (amd64)
779+
uses: actions/download-artifact@v4
780+
with:
781+
name: linux-amd64
782+
path: deb-package
783+
784+
- name: Download Debian package (arm64)
785+
uses: actions/download-artifact@v4
786+
with:
787+
name: linux-arm64
788+
path: deb-package
789+
790+
- uses: actions/github-script@v6
791+
with:
792+
script: |
793+
const fs = require('fs');
794+
const path = require('path');
795+
796+
var releaseMetadata = {
797+
owner: context.repo.owner,
798+
repo: context.repo.repo
799+
};
800+
801+
// Create the release
802+
var tagName = "${{ needs.prereqs.outputs.tag_name }}";
803+
var createdRelease = await github.rest.repos.createRelease({
804+
...releaseMetadata,
805+
draft: true,
806+
tag_name: tagName,
807+
name: tagName
808+
});
809+
releaseMetadata.release_id = createdRelease.data.id;
810+
core.notice(`Created release at ${createdRelease.data.html_url}`);
811+
812+
// Uploads contents of directory to the release created above
813+
async function uploadDirectoryToRelease(directory, includeExtensions=[]) {
814+
return fs.promises.readdir(directory)
815+
.then(async(files) => Promise.all(
816+
files.filter(file => {
817+
return includeExtensions.length==0 || includeExtensions.includes(path.extname(file).toLowerCase());
818+
})
819+
.map(async (file) => {
820+
var filePath = path.join(directory, file);
821+
github.rest.repos.uploadReleaseAsset({
822+
...releaseMetadata,
823+
name: file,
824+
headers: {
825+
"content-length": (await fs.promises.stat(filePath)).size
826+
},
827+
data: fs.createReadStream(filePath)
828+
});
829+
}))
830+
);
831+
}
832+
833+
await Promise.all([
834+
// Upload Windows x86_64 artifacts
835+
uploadDirectoryToRelease('win-installer-x86_64', ['.exe']),
836+
uploadDirectoryToRelease('win-portable-x86_64', ['.exe']),
837+
838+
// Upload Windows aarch64 artifacts
839+
uploadDirectoryToRelease('win-installer-aarch64', ['.exe']),
840+
uploadDirectoryToRelease('win-portable-aarch64', ['.exe']),
841+
842+
// Upload Mac artifacts
843+
uploadDirectoryToRelease('macos-artifacts'),
844+
845+
// Upload Ubuntu artifacts
846+
uploadDirectoryToRelease('deb-package')
847+
]);

0 commit comments

Comments
 (0)