Skip to content

Commit

Permalink
chore: generate mcbbs checksum for build
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Oct 31, 2020
1 parent 21e4ea5 commit f767b9d
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/actions/generate-mcbbs-content/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: Generate MCBBS Content
description: Generate MCBBS Content
runs:
using: 'node12'
main: index.js

79 changes: 79 additions & 0 deletions .github/actions/generate-mcbbs-content/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
const { readdirSync, readFileSync, writeFileSync } = require('fs')
const core = require('@actions/core');

function main(output) {
const { version } = JSON.parse(readFileSync(`package.json`).toString());
const files = readdirSync('build').filter((f) => f.endsWith('.sha1') || f.endsWith('.sha256'));

let fileInfo = {};

for (const file of files) {
if (file.endsWith('.sha1')) {
const realFile = file.substring(0, file.length - 5);
if (!fileInfo[realFile]) {
fileInfo[realFile] = { sha1: '', sha256: '' };
}
fileInfo[realFile].sha1 = readFileSync(`./build/${file}`).toString();
} else {
const realFile = file.substring(0, file.length - 7);
if (!fileInfo[realFile]) {
fileInfo[realFile] = { sha1: '', sha256: '' };
}
fileInfo[realFile].sha256 = readFileSync(`./build/${file}`).toString();
}
}

fileInfo = new Proxy(fileInfo, {
get(target, key) {
if (!target[key]) {
return { sha1: '', sha256: '' };
}
return target[key]
}
})

const result =
`[align=center]
[size=5][b]下载地址[/b][/size]
由于国内上github太虐了……我还是直接放下载地址
[b]Windows:[/b]
[url=https://xmcl-release.azureedge.net/releases/xmcl-Setup-${version}.exe]安装版[/url]
sha1:${fileInfo['xmcl-Setup-' + version + '.exe'].sha1}
sha256: ${fileInfo['xmcl-Setup-' + version + '.exe'].sha256}
[url=https://xmcl-release.azureedge.net/releases/xmcl-${version}-win.zip]x64 压缩包[/url]
sha1:${fileInfo['xmcl-' + version + '-win.zip'].sha1}
sha256: ${fileInfo['xmcl-' + version + '-win.zip'].sha256}
[b]MacOS:[/b]
[url=https://xmcl-release.azureedge.net/releases/xmcl-${version}-mac.zip]压缩包[/url]
sha1:${fileInfo['xmcl-' + version + '-mac.zip'].sha1}
sha256: ${fileInfo['xmcl-' + version + '-mac.zip'].sha256}
[url=https://xmcl-release.azureedge.net/releases/xmcl-${version}.dmg]DMG[/url]
sha1:${fileInfo['xmcl-' + version + '.dmg'].sha1}
sha256: ${fileInfo['xmcl-' + version + '.dmg'].sha256}
[b]Linux:[/b]
[url=https://xmcl-release.azureedge.net/releases/x-minecraft-launcher-${version}.x86_64.rpm]rpm[/url]
sha1:${fileInfo['x-minecraft-launcher-' + version + '.x86_64.rpm'].sha1}
sha256: ${fileInfo['x-minecraft-launcher-' + version + '.x86_64.rpm'].sha256}
[url=https://xmcl-release.azureedge.net/releases/x-minecraft-launcher_${version}_amd64.deb]deb[/url]
sha1:${fileInfo['x-minecraft-launcher_' + version + '_amd64.deb'].sha1}
sha256: ${fileInfo['x-minecraft-launcher_' + version + '_amd64.deb'].sha256}
[url=https://xmcl-release.azureedge.net/releases/x-minecraft-launcher_${version}_amd64.snap]snap[/url]
sha1:${fileInfo['x-minecraft-launcher_' + version + '_amd64.snap'].sha1}
sha256: ${fileInfo['x-minecraft-launcher_' + version + '_amd64.snap'].sha256}
[url=https://xmcl-release.azureedge.net/releases/xmcl-${version}.AppImage]AppImage[/url]
sha1:${fileInfo['xmcl-' + version + '.AppImage'].sha1}
sha256: ${fileInfo['xmcl-' + version + '.AppImage'].sha256}[/align]`

console.log(result);

if (core) {
writeFileSync('./mcbbs', result);
}
}



main(core ? core.setOutput : (k, v) => {
console.log(k)
console.log(v)
});
6 changes: 6 additions & 0 deletions .github/actions/generate-mcbbs-content/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"devDependencies": {
"@actions/core": "1.2.4"
}
}
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ jobs:
with:
name: build
path: build
- uses: ./.github/actions/generate-mcbbs-content
- name: Upload Mcbbs Content
uses: actions/upload-artifact@v2
with:
name: mcbbs
path: mcbbs
- name: Prepare Release
id: prepare_release
uses: ./.github/actions/prepare-release
Expand Down

0 comments on commit f767b9d

Please sign in to comment.