From 14338f06db9f49cbb4327892245a3cacd972d2e2 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Thu, 21 Mar 2024 15:09:01 +0100 Subject: [PATCH] fix: Only use cross if a custom target is configured --- dist/build-crates-debian-main.js | 32 ++++++++++++++++++++---------- dist/publish-crates-debian-main.js | 26 ++++++++++++++++-------- dist/publish-crates-github-main.js | 26 ++++++++++++++++-------- src/build-crates-debian.ts | 24 +++++++++++++++++----- 4 files changed, 76 insertions(+), 32 deletions(-) diff --git a/dist/build-crates-debian-main.js b/dist/build-crates-debian-main.js index 4ca23bb..233a581 100644 --- a/dist/build-crates-debian-main.js +++ b/dist/build-crates-debian-main.js @@ -127169,13 +127169,6 @@ var promises_ = __nccwpck_require__(73292); var lib_core = __nccwpck_require__(42186); // EXTERNAL MODULE: ./node_modules/@actions/artifact/lib/artifact.js var artifact = __nccwpck_require__(79450); -// EXTERNAL MODULE: external "os" -var external_os_ = __nccwpck_require__(22037); -// EXTERNAL MODULE: external "path" -var external_path_ = __nccwpck_require__(71017); -var external_path_default = /*#__PURE__*/__nccwpck_require__.n(external_path_); -// EXTERNAL MODULE: ./node_modules/@actions/cache/lib/cache.js -var cache = __nccwpck_require__(27799); ;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/error.js /*! * Copyright (c) Squirrel Chat et al., All rights reserved. @@ -128139,6 +128132,13 @@ function parse(toml) { +// EXTERNAL MODULE: external "os" +var external_os_ = __nccwpck_require__(22037); +// EXTERNAL MODULE: external "path" +var external_path_ = __nccwpck_require__(71017); +var external_path_default = /*#__PURE__*/__nccwpck_require__.n(external_path_); +// EXTERNAL MODULE: ./node_modules/@actions/cache/lib/cache.js +var cache = __nccwpck_require__(27799); // EXTERNAL MODULE: external "child_process" var external_child_process_ = __nccwpck_require__(32081); ;// CONCATENATED MODULE: ./src/command.ts @@ -128445,6 +128445,7 @@ function fromFiles(output, ...files) { + const build_crates_debian_artifact = new artifact.DefaultArtifactClient(); function setup() { const repo = lib_core.getInput("repo", { required: true }); @@ -128467,10 +128468,19 @@ async function main(input) { const repo = input.repo.split("/")[1]; const remote = `https://${input.githubToken}@github.com/${input.repo}.git`; sh(`git clone --recursive --branch ${input.branch} --single-branch ${remote}`); + const crossContents = await promises_.readFile(external_path_default().join(repo, "Cross.toml"), "utf-8"); + const crossManifest = parse(crossContents); sh(`rustup target add ${input.target}`, { cwd: repo }); - sh(`cross build --release --bins --lib --target ${input.target}`, { - cwd: repo, - }); + if (input.target in crossManifest.target) { + sh(`cross build --release --bins --lib --target ${input.target}`, { + cwd: repo, + }); + } + else { + sh(`cargo build --release --bins --lib --target ${input.target}`, { + cwd: repo, + }); + } const packages = await packagesDebian(repo); lib_core.info(`Building ${packages.map(p => p.name).join(", ")}`); for (const package_ of packages) { @@ -128500,7 +128510,7 @@ const artifactRegExp = /^.*-debian\.zip$/; async function cleanup(input) { const repoPath = input.repo.split("/")[1]; lib_core.info(`Deleting repository ${repoPath}`); - await (0,promises_.rm)(repoPath, { recursive: true, force: true }); + await promises_.rm(repoPath, { recursive: true, force: true }); } diff --git a/dist/publish-crates-debian-main.js b/dist/publish-crates-debian-main.js index a5d5c25..4e4b2f5 100644 --- a/dist/publish-crates-debian-main.js +++ b/dist/publish-crates-debian-main.js @@ -127237,10 +127237,6 @@ async function withIdentity(privateKey, passphrase, fn) { // EXTERNAL MODULE: external "path" var external_path_ = __nccwpck_require__(71017); var external_path_default = /*#__PURE__*/__nccwpck_require__.n(external_path_); -// EXTERNAL MODULE: external "os" -var external_os_ = __nccwpck_require__(22037); -// EXTERNAL MODULE: ./node_modules/@actions/cache/lib/cache.js -var lib_cache = __nccwpck_require__(27799); ;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/error.js /*! * Copyright (c) Squirrel Chat et al., All rights reserved. @@ -128204,6 +128200,10 @@ function parse(toml) { +// EXTERNAL MODULE: external "os" +var external_os_ = __nccwpck_require__(22037); +// EXTERNAL MODULE: ./node_modules/@actions/cache/lib/cache.js +var lib_cache = __nccwpck_require__(27799); ;// CONCATENATED MODULE: ./src/config.ts const config_config = __nccwpck_require__(16035); const gitEnv = { @@ -128467,6 +128467,7 @@ function fromFiles(output, ...files) { + const build_crates_debian_artifact = new artifact.DefaultArtifactClient(); function setup() { const repo = core.getInput("repo", { required: true }); @@ -128489,10 +128490,19 @@ async function main(input) { const repo = input.repo.split("/")[1]; const remote = `https://${input.githubToken}@github.com/${input.repo}.git`; sh(`git clone --recursive --branch ${input.branch} --single-branch ${remote}`); + const crossContents = await fs.readFile(path.join(repo, "Cross.toml"), "utf-8"); + const crossManifest = toml.parse(crossContents); sh(`rustup target add ${input.target}`, { cwd: repo }); - sh(`cross build --release --bins --lib --target ${input.target}`, { - cwd: repo, - }); + if (input.target in crossManifest.target) { + sh(`cross build --release --bins --lib --target ${input.target}`, { + cwd: repo, + }); + } + else { + sh(`cargo build --release --bins --lib --target ${input.target}`, { + cwd: repo, + }); + } const packages = await cargo.packagesDebian(repo); core.info(`Building ${packages.map(p => p.name).join(", ")}`); for (const package_ of packages) { @@ -128522,7 +128532,7 @@ const artifactRegExp = /^.*-debian\.zip$/; async function cleanup(input) { const repoPath = input.repo.split("/")[1]; core.info(`Deleting repository ${repoPath}`); - await rm(repoPath, { recursive: true, force: true }); + await fs.rm(repoPath, { recursive: true, force: true }); } ;// CONCATENATED MODULE: ./src/publish-crates-debian.ts diff --git a/dist/publish-crates-github-main.js b/dist/publish-crates-github-main.js index 017cacf..9435a7e 100644 --- a/dist/publish-crates-github-main.js +++ b/dist/publish-crates-github-main.js @@ -127215,10 +127215,6 @@ var external_path_ = __nccwpck_require__(71017); var external_path_default = /*#__PURE__*/__nccwpck_require__.n(external_path_); // EXTERNAL MODULE: external "fs/promises" var promises_ = __nccwpck_require__(73292); -// EXTERNAL MODULE: external "os" -var external_os_ = __nccwpck_require__(22037); -// EXTERNAL MODULE: ./node_modules/@actions/cache/lib/cache.js -var lib_cache = __nccwpck_require__(27799); ;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/error.js /*! * Copyright (c) Squirrel Chat et al., All rights reserved. @@ -128182,6 +128178,10 @@ function parse(toml) { +// EXTERNAL MODULE: external "os" +var external_os_ = __nccwpck_require__(22037); +// EXTERNAL MODULE: ./node_modules/@actions/cache/lib/cache.js +var lib_cache = __nccwpck_require__(27799); ;// CONCATENATED MODULE: ./src/config.ts const config_config = __nccwpck_require__(16035); const gitEnv = { @@ -128445,6 +128445,7 @@ function fromFiles(output, ...files) { + const build_crates_debian_artifact = new artifact.DefaultArtifactClient(); function setup() { const repo = core.getInput("repo", { required: true }); @@ -128467,10 +128468,19 @@ async function main(input) { const repo = input.repo.split("/")[1]; const remote = `https://${input.githubToken}@github.com/${input.repo}.git`; sh(`git clone --recursive --branch ${input.branch} --single-branch ${remote}`); + const crossContents = await fs.readFile(path.join(repo, "Cross.toml"), "utf-8"); + const crossManifest = toml.parse(crossContents); sh(`rustup target add ${input.target}`, { cwd: repo }); - sh(`cross build --release --bins --lib --target ${input.target}`, { - cwd: repo, - }); + if (input.target in crossManifest.target) { + sh(`cross build --release --bins --lib --target ${input.target}`, { + cwd: repo, + }); + } + else { + sh(`cargo build --release --bins --lib --target ${input.target}`, { + cwd: repo, + }); + } const packages = await cargo.packagesDebian(repo); core.info(`Building ${packages.map(p => p.name).join(", ")}`); for (const package_ of packages) { @@ -128500,7 +128510,7 @@ const artifactRegExp = /^.*-debian\.zip$/; async function cleanup(input) { const repoPath = input.repo.split("/")[1]; core.info(`Deleting repository ${repoPath}`); - await rm(repoPath, { recursive: true, force: true }); + await fs.rm(repoPath, { recursive: true, force: true }); } ;// CONCATENATED MODULE: ./src/build-crates-standalone.ts diff --git a/src/build-crates-debian.ts b/src/build-crates-debian.ts index fceb58f..a3b4eb5 100644 --- a/src/build-crates-debian.ts +++ b/src/build-crates-debian.ts @@ -1,7 +1,8 @@ -import { rm } from "fs/promises"; +import * as fs from "fs/promises"; import * as core from "@actions/core"; import { DefaultArtifactClient } from "@actions/artifact"; +import * as toml from "smol-toml"; import * as cargo from "./cargo"; import { sh } from "./command"; @@ -43,11 +44,20 @@ export async function main(input: Input) { const remote = `https://${input.githubToken}@github.com/${input.repo}.git`; sh(`git clone --recursive --branch ${input.branch} --single-branch ${remote}`); + const crossContents = await fs.readFile(path.join(repo, "Cross.toml"), "utf-8"); + const crossManifest = toml.parse(crossContents) as CrossManifest; + sh(`rustup target add ${input.target}`, { cwd: repo }); - sh(`cross build --release --bins --lib --target ${input.target}`, { - cwd: repo, - }); + if (input.target in crossManifest.target) { + sh(`cross build --release --bins --lib --target ${input.target}`, { + cwd: repo, + }); + } else { + sh(`cargo build --release --bins --lib --target ${input.target}`, { + cwd: repo, + }); + } const packages = await cargo.packagesDebian(repo); core.info(`Building ${packages.map(p => p.name).join(", ")}`); @@ -77,6 +87,10 @@ export async function main(input: Input) { } } +type CrossManifest = { + target: { [target: string]: { image: string } }; +}; + export function artifactName(repo: string, version: string, target: string): string { return `${repo}-${version}-${target}-debian.zip`; } @@ -86,5 +100,5 @@ export const artifactRegExp: RegExp = /^.*-debian\.zip$/; export async function cleanup(input: Input) { const repoPath = input.repo.split("/")[1]; core.info(`Deleting repository ${repoPath}`); - await rm(repoPath, { recursive: true, force: true }); + await fs.rm(repoPath, { recursive: true, force: true }); }