-
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
26 additions
and
10 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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
const https = require("https"); | ||
const fs = require("fs"); | ||
const { execSync, exec } = require("child_process"); | ||
const { execSync } = require("child_process"); | ||
const { Octokit } = require("@octokit/action"); | ||
|
||
const req = https.get("https://ziglang.org/download/index.json", (res) => { | ||
https.get("https://ziglang.org/download/index.json", (res) => { | ||
let data = ""; | ||
|
||
// A chunk of data has been received. | ||
|
@@ -18,7 +18,7 @@ const req = https.get("https://ziglang.org/download/index.json", (res) => { | |
}); | ||
}); | ||
|
||
function check(data) { | ||
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); | ||
|
@@ -33,7 +33,10 @@ function check(data) { | |
})(); | ||
if (localVer == remoteVer) return console.log("Nightly is up to date"); | ||
|
||
const branchName = `zig_0.12.${remoteVer}`; | ||
const dateString = new Date() | ||
.toLocaleDateString("en-GB", { day: "numeric", month: "short" }) | ||
.replace(" ", "-") | ||
const branchName = "nightly_update_" + dateString; | ||
execSync(`git checkout -b "${branchName}"`); | ||
|
||
file = file.replace(verMatch, `"${remoteVer}"`); | ||
|
@@ -45,19 +48,29 @@ function check(data) { | |
data.master["aarch64-linux"].shasum, | ||
data.master["x86_64-linux"].shasum, | ||
]; | ||
file = file.replace(/sha256 "([a-f]|\d)*"/, () => { | ||
file = file.replace(/sha256 "([a-f]|\d)*"/g, () => { | ||
replacementIndex++; | ||
return `sha256 "${newSHA[replacementIndex]}"`; | ||
}); | ||
|
||
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.git.createCommit({ | ||
octokit.pulls.create({ | ||
owner, | ||
repo, | ||
message: `"[Autoupdate]: Sync [email protected] to ${remoteVer}"`, | ||
base: "main", | ||
head: branchName, | ||
title: `Nightly update: ${dateString}`, | ||
body: `- Update [email protected] to ${remoteVer}`, | ||
}); | ||
octokit.pulls.create({ owner, repo, base: "main", head: branchName }); | ||
} |
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
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,2 +1,4 @@ | ||
.DS_Store | ||
node_modules | ||
package.json | ||
package-lock.json |