Skip to content

Modify updater.json with latest release data #3

Modify updater.json with latest release data

Modify updater.json with latest release data #3

name: Modify updater.json with latest release data
on:
workflow_dispatch:
workflow_call:
jobs:
modify-updater-gist:
name: Modify updater.json gist
runs-on: ubuntu-latest
steps:
- name: update download urls and signatures for updater gist
uses: actions/github-script@v7
env:
updater_gist_id: ${{ secrets.UPDATER_GIST_ID }}
with:
github-token: ${{ secrets.DEV_OPS_BOT_TOKEN }}
script: |
const { data } = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo
});
console.log('data', data);
const { name, body, published_at, assets } = data;
const platforms = {};
const promises = [];
const createPlatform = async (name, asset) => {
url = asset.browser_download_url;
const obj = await github.request(asset.browser_download_url);
const signature = new TextDecoder().decode(obj.data);
platforms['darwin-aarch64'] = { url, signature };
};
assets.forEach((asset) => {
if (asset.name.indexOf('_aarch64.app.tar.gz') > 0) {
promises.push(createPlaform('darwin-aarch64', asset));
} else if (asset.name.indexOf('_x64.app.tar.gz') > 0) {
promises.push(createPlaform('darwin-x86_64', asset));
} else if (asset.name.indexOf('_x64_en-US.msi.zip') > 0) {
promises.push(createPlaform('windows-x86_64', asset));
} else if (asset.name.indexOf('_amd64.AppImage.tar.gz') > 0) {
promises.push(createPlaform('linux-x86_64', asset));
}
});
/* const latest_url = assets.find((asset) => )
const linuxAssetUrl = assets[1].browser_download_url;
const linuxSigObj = await github.request(assets[2].browser_download_url);
const linuxSignature = new TextDecoder().decode(linuxSigObj.data);
const macAssetUrl = assets[4].browser_download_url;
const macSigObj = await github.request(assets[5].browser_download_url);
const macSignature = new TextDecoder().decode(macSigObj.data);
const winAssetUrl = assets[8].browser_download_url;
const winSigObj = await github.request(assets[9].browser_download_url);
const winSignature = new TextDecoder().decode(winSigObj.data); */
const notes = body.replace(/ *\([^)]*\)|#|\) */g, '');
const newGistContent = JSON.stringify({
version: name,
notes,
pub_date: published_at,
platforms: {
}
}, null, 2);
try {
await github.rest.gists.update({
gist_id: process.env.updater_gist_id,
files: {
"updater.json": {
content: newGistContent
}
}
});
} catch (e) {
console.log(e);
}