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>
This commit is contained in:
Victoria Dye 2021-07-16 10:51:02 -04:00 коммит произвёл Johannes Schindelin
Родитель cb824c4886
Коммит 4cab821900
1 изменённых файлов: 92 добавлений и 0 удалений

92
.github/workflows/build-git-installers.yml поставляемый
Просмотреть файл

@ -577,3 +577,95 @@ jobs:
path: |
*.deb
# End build and sign Debian package
create-github-release:
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- create-linux-artifacts
- create-macos-artifacts
- windows_artifacts
- prereqs
if: |
success() ||
(needs.create-linux-artifacts.result == 'skipped' &&
needs.create-macos-artifacts.result == 'success' &&
needs.windows_artifacts.result == 'success')
steps:
- name: Download Windows portable installer
uses: actions/download-artifact@v3
with:
name: win-portable-x86_64
path: win-portable-x86_64
- name: Download Windows x86_64 installer
uses: actions/download-artifact@v3
with:
name: win-installer-x86_64
path: win-installer-x86_64
- name: Download macOS artifacts
uses: actions/download-artifact@v3
with:
name: macos-artifacts
path: macos-artifacts
- name: Download Debian package
uses: actions/download-artifact@v3
with:
name: linux-artifacts
path: deb-package
- uses: actions/github-script@v6
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.rest.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.rest.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('macos-artifacts'),
// Upload Ubuntu artifacts
uploadDirectoryToRelease('deb-package')
]);