CI: move Generate manifest keys into JS part

This commit is contained in:
Kilian von Pflugk 2024-08-15 20:36:35 +02:00
parent 6720f43298
commit 8afa083b39
2 changed files with 16 additions and 15 deletions

View File

@ -39,15 +39,6 @@ jobs:
- name: Create archive - name: Create archive
run: zip -j "intro-skipper-v${{ env.NEW_FILE_VERSION }}.zip" ConfusedPolarBear.Plugin.IntroSkipper/bin/Debug/net8.0/ConfusedPolarBear.Plugin.IntroSkipper.dll run: zip -j "intro-skipper-v${{ env.NEW_FILE_VERSION }}.zip" ConfusedPolarBear.Plugin.IntroSkipper/bin/Debug/net8.0/ConfusedPolarBear.Plugin.IntroSkipper.dll
- name: Generate manifest keys
run: |
sourceUrl="https://github.com/${{ github.repository }}/releases/download/10.9/v${{ env.NEW_FILE_VERSION }}/intro-skipper-v${{ env.NEW_FILE_VERSION }}.zip"
echo "SOURCE_URL=$sourceUrl" >> $GITHUB_ENV
md5sum intro-skipper-v${{ env.NEW_FILE_VERSION }}.zip > intro-skipper-v${{ env.NEW_FILE_VERSION }}.md5
checksum="$(awk '{print $1}' intro-skipper-v${{ env.NEW_FILE_VERSION }}.md5)"
echo "CHECKSUM=$checksum" >> $GITHUB_ENV
timestamp="$(date +%FT%TZ)"
echo "TIMESTAMP=$timestamp" >> $GITHUB_ENV
- name: Create new release with tag - name: Create new release with tag
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
@ -59,6 +50,7 @@ jobs:
run: node validate-and-update-manifest.js run: node validate-and-update-manifest.js
env: env:
VERSION: ${{ env.NEW_FILE_VERSION }} VERSION: ${{ env.NEW_FILE_VERSION }}
GITHUB_REPOSITORY: ${{ github.repository }}
- name: Commit changes - name: Commit changes
if: success() if: success()

View File

@ -3,6 +3,10 @@ const crypto = require('crypto');
const fs = require('fs'); const fs = require('fs');
const { URL } = require('url'); const { URL } = require('url');
const repository = process.env.GITHUB_REPOSITORY;
const version = process.env.VERSION;
const targetAbi = "10.9.9.0";
// Read manifest.json // Read manifest.json
const manifestPath = './manifest.json'; const manifestPath = './manifest.json';
if (!fs.existsSync(manifestPath)) { if (!fs.existsSync(manifestPath)) {
@ -12,12 +16,12 @@ if (!fs.existsSync(manifestPath)) {
const jsonData = JSON.parse(fs.readFileSync(manifestPath, 'utf8')); const jsonData = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
const newVersion = { const newVersion = {
version: process.env.VERSION, // replace with the actual new version version,
changelog: "- See the full changelog at [GitHub](https://github.com/jumoog/intro-skipper/blob/master/CHANGELOG.md)\n", changelog: `- See the full changelog at [GitHub](https://github.com/${repository}/blob/master/CHANGELOG.md)\n`,
targetAbi: "10.9.9.0", targetAbi,
sourceUrl: process.env.SOURCE_URL, sourceUrl: `https://github.com/${repository}/releases/download/10.9/v${version}/intro-skipper-v${version}.zip`,
checksum: process.env.CHECKSUM, checksum: getMD5FromFile(),
timestamp: process.env.TIMESTAMP timestamp: new Date().toISOString().replace(/\.\d{3}Z$/, 'Z')
}; };
async function updateManifest() { async function updateManifest() {
@ -101,6 +105,11 @@ async function downloadAndHashFile(url, redirects = 5) {
}); });
} }
function getMD5FromFile() {
const fileBuffer = fs.readFileSync(`intro-skipper-v${version}.zip`);
return crypto.createHash('md5').update(fileBuffer).digest('hex');
}
async function run() { async function run() {
await updateManifest(); await updateManifest();
} }