-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
56 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const { execSync } = require("child_process"); | ||
const { Octokit } = require("@octokit/action"); | ||
|
||
const dateString = new Date() | ||
.toLocaleDateString("en-GB", { day: "numeric", month: "short" }) | ||
.replace(" ", "-"); | ||
const branchName = "nightly_update_" + dateString; | ||
execSync(`git checkout -b "${branchName}"`); | ||
|
||
// Do the check here | ||
const zigRes = require("./zig-update")(); | ||
|
||
if (zigRes == "") process.exit(); | ||
|
||
execSync( | ||
` git config --global user.name "froxcey"; | ||
git config --global user.email "[email protected]"; | ||
git add -A; | ||
git commit -m "[Autoupdate]: ${branchName}"; | ||
git push -f origin ${branchName};`, | ||
); | ||
|
||
const octokit = new Octokit(); | ||
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/"); | ||
octokit.pulls.create({ | ||
owner, | ||
repo, | ||
base: "main", | ||
head: branchName, | ||
title: `Nightly update: ${dateString}`, | ||
body: zigRes, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,33 @@ | ||
const https = require("https"); | ||
const fs = require("fs"); | ||
const { execSync } = require("child_process"); | ||
const { Octokit } = require("@octokit/action"); | ||
|
||
https.get("https://ziglang.org/download/index.json", (res) => { | ||
let data = ""; | ||
export default new Promise((resolve, reject) => { | ||
https.get("https://ziglang.org/download/index.json", (res) => { | ||
let data = ""; | ||
|
||
// A chunk of data has been received. | ||
res.on("data", (chunk) => { | ||
data += chunk; | ||
}); | ||
// A chunk of data has been received. | ||
res.on("data", (chunk) => { | ||
data += chunk; | ||
}); | ||
|
||
// The whole response has been received. | ||
res.on("end", () => { | ||
let res = JSON.parse(data); | ||
check(res); | ||
// The whole response has been received. | ||
res.on("end", async () => { | ||
let res = JSON.parse(data); | ||
resolve(await check(res)); | ||
}); | ||
}); | ||
}); | ||
}) | ||
|
||
async function check(data) { | ||
if (!data.master.version.startsWith("0.12")) { | ||
console.error("Zig master is no longer on 0.12, please update"); | ||
process.exit(1); | ||
} | ||
const path = "Formula/z/zig-nightly.rb"; | ||
const path = "Formula/zig-nightly.rb"; | ||
var file = fs.readFileSync(path).toString(); | ||
const verMatch = /"[\d.]+-dev\.[+-\w]+"/; | ||
const localVer = file.match(verMatch)[0].replaceAll('"', ""); | ||
const remoteVer = data.master.version; | ||
if (localVer == remoteVer) return console.log("Nightly is up to date"); | ||
|
||
const dateString = new Date() | ||
.toLocaleDateString("en-GB", { day: "numeric", month: "short" }) | ||
.replace(" ", "-") | ||
const branchName = "nightly_update_" + dateString; | ||
execSync(`git checkout -b "${branchName}"`); | ||
if (localVer == remoteVer) { | ||
console.log("Nightly is up to date"); | ||
return "" | ||
} | ||
|
||
file = file.replace(verMatch, `"${remoteVer}"`); | ||
|
||
|
@@ -52,22 +45,5 @@ async function check(data) { | |
|
||
fs.writeFileSync(path, file); | ||
|
||
execSync( | ||
` git config --global user.name "froxcey"; | ||
git config --global user.email "[email protected]"; | ||
git add -A; | ||
git commit -m "[Autoupdate]: Sync [email protected] to ${remoteVer}"; | ||
git push -f origin ${branchName};`, | ||
); | ||
|
||
const octokit = new Octokit(); | ||
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/"); | ||
octokit.pulls.create({ | ||
owner, | ||
repo, | ||
base: "main", | ||
head: branchName, | ||
title: `Nightly update: ${dateString}`, | ||
body: `- Update [email protected] to ${remoteVer}`, | ||
}); | ||
return `- Update zig-nightly to ${remoteVer}\n`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters