Skip to content

Commit

Permalink
release: create draft GitHub release with packages & installers
Browse files Browse the repository at this point in the history
- create release & uploads artifact using Octokit
- use job "if" condition to handle uploading signed *or* unsigned .deb
  • Loading branch information
vdye authored and derrickstolee committed Aug 3, 2021
1 parent e00b8d2 commit 1d061cf
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/build-git-installers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,93 @@ jobs:
name: deb-package-signed
path: ${{ env.ARTIFACTS_DIR }}/signed
# End build & sign Ubuntu package

create-github-release:
runs-on: ubuntu-latest
needs: [prereqs, windows_artifacts, mac_artifacts, ubuntu_sign-artifacts]
if: |
success() ||
(needs.ubuntu_sign-artifacts.result == 'skipped' &&
needs.mac_artifacts.result == 'success' &&
needs.windows_artifacts.result == 'success')
steps:
- name: Download Windows portable installer
uses: actions/download-artifact@v2
with:
name: win-portable-x86_64
path: win-portable-x86_64
- name: Download Windows x86_64 installer
uses: actions/download-artifact@v2
with:
name: win-installer-x86_64
path: win-installer-x86_64
- name: Download Mac installer
uses: actions/download-artifact@v2
with:
name: osx-installer
path: osx-installer
- name: Download Ubuntu package (signed)
if: needs.prereqs.outputs.deb_signable == 'true'
uses: actions/download-artifact@v2
with:
name: deb-package-signed
path: deb-package
- name: Download Ubuntu package (unsigned)
if: needs.prereqs.outputs.deb_signable != 'true'
uses: actions/download-artifact@v2
with:
name: deb-package-unsigned
path: deb-package
- uses: actions/github-script@v4
with:
script: |
const fs = require('fs');
const path = require('path');
var releaseMetadata = {
owner: context.repo.owner,
repo: context.repo.repo
};
// Create the release
var tagName = "${{ needs.prereqs.outputs.tag_name }}";
var createdRelease = await github.repos.createRelease({
...releaseMetadata,
draft: true,
tag_name: tagName,
name: tagName
});
releaseMetadata.release_id = createdRelease.data.id;
// Uploads contents of directory to the release created above
async function uploadDirectoryToRelease(directory, includeExtensions=[]) {
return fs.promises.readdir(directory)
.then(async(files) => Promise.all(
files.filter(file => {
return includeExtensions.length==0 || includeExtensions.includes(path.extname(file).toLowerCase());
})
.map(async (file) => {
var filePath = path.join(directory, file);
github.repos.uploadReleaseAsset({
...releaseMetadata,
name: file,
headers: {
"content-length": (await fs.promises.stat(filePath)).size
},
data: fs.createReadStream(filePath)
});
}))
);
}
await Promise.all([
// Upload Windows artifacts
uploadDirectoryToRelease('win-installer-x86_64', ['.exe']),
uploadDirectoryToRelease('win-portable-x86_64', ['.exe']),
// Upload Mac artifacts
uploadDirectoryToRelease('osx-installer'),
// Upload Ubuntu artifacts
uploadDirectoryToRelease('deb-package')
]);

0 comments on commit 1d061cf

Please sign in to comment.