mirror of
https://github.com/kou029w/megabit-os.git
synced 2025-01-18 16:07:58 +00:00
add release job
This commit is contained in:
parent
598305cce2
commit
720eb2e3df
2 changed files with 43 additions and 0 deletions
28
.github/scripts/release.js
vendored
Normal file
28
.github/scripts/release.js
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
const path = require("path");
|
||||
const fs = require("fs").promises;
|
||||
const crypto = require("crypto");
|
||||
|
||||
/** actions/github-script でのリリース成果物のアップロード */
|
||||
module.exports = async function ({ github, context, glob }) {
|
||||
const version = context.payload.release.tag_name.replace(/^v/i, "");
|
||||
const target = {
|
||||
...context.repo,
|
||||
release_id: context.payload.release.id,
|
||||
};
|
||||
let body = "## Megabit OS\n";
|
||||
const globber = await glob.create("megabit-armhf.*.gz");
|
||||
for await (const file of globber.globGenerator()) {
|
||||
const name = path
|
||||
.basename(file)
|
||||
.replace(/^megabit-armhf[.]/, `megabit-${version}-armhf.`);
|
||||
const data = await fs.readFile(file);
|
||||
await github.repos.uploadReleaseAsset({ ...target, name, data });
|
||||
const hash = crypto.createHash("sha256").update(data).digest("hex");
|
||||
body = `${body}
|
||||
${name.split(".").includes("img") ? "OS イメージ" : "ファイルシステム"}
|
||||
|
||||
- ${name} (SHA256: \`${hash}\`)
|
||||
`;
|
||||
}
|
||||
await github.repos.updateRelease({ ...target, body, prerelease: false });
|
||||
};
|
15
.github/workflows/build.yml
vendored
15
.github/workflows/build.yml
vendored
|
@ -1,6 +1,8 @@
|
|||
name: build
|
||||
on:
|
||||
push: { branches: [main] }
|
||||
release:
|
||||
types: [published]
|
||||
jobs:
|
||||
main:
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -14,3 +16,16 @@ jobs:
|
|||
with:
|
||||
name: megabit-armhf
|
||||
path: megabit-armhf.*
|
||||
release:
|
||||
if: github.event.release.prerelease
|
||||
needs: main
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/download-artifact@v2
|
||||
with: { name: megabit-armhf }
|
||||
- uses: actions/github-script@v4
|
||||
with:
|
||||
script: |
|
||||
const script = require("./.github/scripts/release.js");
|
||||
await script({ github, context, glob });
|
||||
|
|
Loading…
Add table
Reference in a new issue