Skip to content

Commit

Permalink
Add SDL to autoupdate
Browse files Browse the repository at this point in the history
  • Loading branch information
Froxcey committed Jan 15, 2024
1 parent 065a911 commit 5b170c7
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 6 deletions.
9 changes: 7 additions & 2 deletions .github/actions/nightly-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ const { Octokit } = require("@octokit/action");
execSync(`git checkout -b "${branchName}"`);

// Do the check here
const zigRes = await require("./zig-update");
const results = [];
results.push(
await require("./zig-update"),
await require("./sdl3-update"),
await require("./sdl3_image-update"),
);

if (zigRes == "") return;

Expand All @@ -29,6 +34,6 @@ const { Octokit } = require("@octokit/action");
base: "main",
head: branchName,
title: `Nightly update: ${dateString}`,
body: zigRes,
body: results.join(""),
});
})();
44 changes: 44 additions & 0 deletions .github/actions/sdl3-update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const https = require("https");
const fs = require("fs");

const verMatch = /"([a-f]|[0-9])+"/;

module.exports = new Promise((resolve, reject) => {
https.get(
{
href: "https://api.github.com/repos/libsdl-org/SDL/branches/main",
headers: { "user-agent": "chiissu-macchiato/1.0." },
},
(res) => {
let data = "";

// A chunk of data has been received.
res.on("data", (chunk) => {
data += chunk;
});

// The whole response has been received.
res.on("end", async () => {
let res = JSON.parse(data);
resolve(await check(res));
});
},
);
});

async function check(data) {
const path = "Formula/sdl3-nightly.rb";
var file = fs.readFileSync(path).toString();
const localVer = file.match(verMatch)[0].replaceAll('"', "");
const remoteVer = data.commit.sha;

if (localVer == remoteVer) {
console.log("SDL3 is up to date");
return "";
}

file = file.replace(verMatch, `"${remoteVer}"`);
fs.writeFileSync(path, file);

return `- Update SDL3 to ${remoteVer}\n`;
}
44 changes: 44 additions & 0 deletions .github/actions/sdl3_image-update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const https = require("https");
const fs = require("fs");

const verMatch = /"([a-f]|[0-9])+"/;

module.exports = new Promise((resolve, reject) => {
https.get(
{
href: "https://api.github.com/repos/libsdl-org/SDL/branches/main",
headers: { "user-agent": "chiissu-macchiato/1.0." },
},
(res) => {
let data = "";

// A chunk of data has been received.
res.on("data", (chunk) => {
data += chunk;
});

// The whole response has been received.
res.on("end", async () => {
let res = JSON.parse(data);
resolve(await check(res));
});
},
);
});

async function check(data) {
const path = "Formula/sdl3_image-nightly.rb";
var file = fs.readFileSync(path).toString();
const localVer = file.match(verMatch)[0].replaceAll('"', "");
const remoteVer = data.commit.sha;

if (localVer == remoteVer) {
console.log("SDL3_Image is up to date");
return "";
}

file = file.replace(verMatch, `"${remoteVer}"`);
fs.writeFileSync(path, file);

return `- Update SDL3_Image to ${remoteVer}\n`;
}
4 changes: 2 additions & 2 deletions .github/actions/zig-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function check(data) {
const localVer = file.match(verMatch)[0].replaceAll('"', "");
const remoteVer = data.master.version;
if (localVer == remoteVer) {
console.log("Nightly is up to date");
console.log("Zig is up to date");
return ""
}

Expand All @@ -45,5 +45,5 @@ async function check(data) {

fs.writeFileSync(path, file);

return `- Update zig-nightly to ${remoteVer}\n`;
return `- Update zig to ${remoteVer}\n`;
}
1 change: 0 additions & 1 deletion Formula/sdl3-nightly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ class Sdl3Nightly < Formula
homepage "https://www.libsdl.org/"
version "649556befa156201116a4f25089597463d0efd44"
url "https://codeload.github.com/libsdl-org/SDL/tar.gz/#{version}"
sha256 "5490459af59f58f0e552ebe5185c552c232fe4da9cc438df5686c053a8ac139d"
license "Zlib"

depends_on "cmake"
Expand Down
1 change: 0 additions & 1 deletion Formula/sdl3_image-nightly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ class Sdl3ImageNightly < Formula
homepage "https://www.libsdl.org/"
version "be035537a9ee0e4990c57809446b4776754980cd"
url "https://codeload.github.com/libsdl-org/SDL_image/tar.gz/#{version}"
sha256 "66ce41b4af9dd41b6847cc4edcb172ff4de8010553011d6cd831f5c21786f361"
license "Zlib"

depends_on "cmake"
Expand Down

0 comments on commit 5b170c7

Please sign in to comment.