Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[setup-pandoc]: pass GH token to nightly download #889

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
unchanged, on all R versions. To avoid using a P3M snapshot on R 3.6.x,
set the `RSPM_PIN_3_6` environment variable to `false`.

* `[setup-pandoc]`: installing nightly Pandoc works again now (#889).

* `[setup-r-dependencies]` now automatically installs Quarto if the repo
has a qmd file, and it isn't installed. See the `install-quarto` and
`quarto-version` input parameters (#866).
Expand Down
67 changes: 41 additions & 26 deletions setup-pandoc/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58541,13 +58541,24 @@ const http_client_1 = __nccwpck_require__(4812);
const action_1 = __nccwpck_require__(161);
const IS_WINDOWS = process.platform === "win32";
const IS_MAC = process.platform === "darwin";
const OS = !!process.env.SETUP_R_OS ? process.env.SETUP_R_OS :
IS_WINDOWS ? "win" : IS_MAC ? "mac" : "linux";
const ARCH = !!process.env.SETUP_R_ARCH ? process.env.SETUP_R_ARCH :
OS == "win" ? undefined :
(OS == "mac" && process.arch == "arm64") ? "arm64" :
(OS == "mac" && process.arch == "x64") ? "x86_64" :
process.arch == "x64" ? "amd64" : process.arch;
const OS = !!process.env.SETUP_R_OS
? process.env.SETUP_R_OS
: IS_WINDOWS
? "win"
: IS_MAC
? "mac"
: "linux";
const ARCH = !!process.env.SETUP_R_ARCH
? process.env.SETUP_R_ARCH
: OS == "win"
? undefined
: OS == "mac" && process.arch == "arm64"
? "arm64"
: OS == "mac" && process.arch == "x64"
? "x86_64"
: process.arch == "x64"
? "amd64"
: process.arch;
const api_url = process.env.GITHUB_API_URL || "https://api.github.com";
if (!tempDirectory) {
let baseLocation;
Expand Down Expand Up @@ -58631,29 +58642,33 @@ function getNightlyPandoc() {
const octokit = new action_1.Octokit();
const owner = "jgm";
const repo = "pandoc";
const res = yield octokit.paginate('GET /repos/{owner}/{repo}/actions/runs', {
const res = yield octokit.paginate("GET /repos/{owner}/{repo}/actions/runs", {
owner,
repo,
status: "success"
status: "success",
}, (response, done) => {
var bld = response.data.find(x => x.name == "Nightly");
var bld = response.data.find((x) => x.name == "Nightly");
if (!!bld) {
done();
return [bld.id];
}
return [];
});
const run_id = res[0];
const res2 = yield octokit.request('GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts', {
const res2 = yield octokit.request("GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts", {
owner,
repo,
run_id
run_id,
});
var arts = {};
for (var i in res2.data.artifacts) {
arts[res2.data.artifacts[i].name] = res2.data.artifacts[i].id;
}
const which = IS_WINDOWS ? 'nightly-windows' : (IS_MAC ? 'nightly-macos' : 'nightly-linux');
const which = IS_WINDOWS
? "nightly-windows"
: IS_MAC
? "nightly-macos"
: "nightly-linux";
const artifact_id = arts[which];
let { url } = yield octokit.request("HEAD /repos/{owner}/{repo}/actions/artifacts/{artifact_id}/{archive_format}", {
owner,
Expand All @@ -58666,18 +58681,18 @@ function getNightlyPandoc() {
});
let downloadPath;
try {
downloadPath = yield tc.downloadTool(url);
downloadPath = yield tc.downloadTool(url, undefined, getAuthHeaderValue());
}
catch (error) {
throw new Error('Failed to download Pandoc nightly build: ' + error);
throw new Error("Failed to download Pandoc nightly build: " + error);
}
const fileName = which + '.zip';
const fileName = which + ".zip";
const extractionPath = yield tc.extractZip(downloadPath);
const subdir = yield fs.promises.readdir(extractionPath);
const pandocPath = extractionPath + '/' + subdir[0];
const pandocPath = extractionPath + "/" + subdir[0];
if (!IS_WINDOWS) {
const pandoc = pandocPath + '/pandoc';
yield fs.promises.chmod(pandoc, '755');
const pandoc = pandocPath + "/pandoc";
yield fs.promises.chmod(pandoc, "755");
}
core.debug(`Adding '${pandocPath}' to PATH.`);
core.addPath(pandocPath);
Expand All @@ -58688,9 +58703,9 @@ function installPandocMac(version) {
var _a;
// Since 3.1.2, Pandoc uses cabal instead of stack to build the macOS binary.
const is_new_macos_installer = (0, compare_versions_1.compare)(version, "3.1.2", ">=") ? true : false;
const fileName = is_new_macos_installer ?
util.format("pandoc-%s-%s-macOS.pkg", version, ARCH) :
util.format("pandoc-%s-macOS.pkg", version);
const fileName = is_new_macos_installer
? util.format("pandoc-%s-%s-macOS.pkg", version, ARCH)
: util.format("pandoc-%s-macOS.pkg", version);
const downloadUrl = util.format("https://github.com/jgm/pandoc/releases/download/%s/%s", version, fileName);
let downloadPath;
try {
Expand All @@ -58706,7 +58721,7 @@ function installPandocMac(version) {
"-pkg",
path.join(tempDirectory, fileName),
"-target",
"/"
"/",
]);
});
}
Expand Down Expand Up @@ -58749,9 +58764,9 @@ function installPandocLinux(version) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
const is_new_linux_installer = (0, compare_versions_1.compare)(version, "2.8", ">=") ? true : false;
const fileName = is_new_linux_installer ?
util.format("pandoc-%s-linux-%s.tar.gz", version, ARCH) :
util.format("pandoc-%s-linux.tar.gz", version);
const fileName = is_new_linux_installer
? util.format("pandoc-%s-linux-%s.tar.gz", version, ARCH)
: util.format("pandoc-%s-linux.tar.gz", version);
const downloadUrl = util.format("https://github.com/jgm/pandoc/releases/download/%s/%s", version, fileName);
let downloadPath;
try {
Expand Down
2 changes: 1 addition & 1 deletion setup-pandoc/dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion setup-pandoc/src/setup-pandoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async function getNightlyPandoc(): Promise<void> {

let downloadPath: string;
try {
downloadPath = await tc.downloadTool(url);
downloadPath = await tc.downloadTool(url, undefined, getAuthHeaderValue());
} catch (error) {
throw new Error("Failed to download Pandoc nightly build: " + error);
}
Expand Down
Loading