From fb3670aed9703260410835ba25f4b250c833c5f0 Mon Sep 17 00:00:00 2001 From: Nicolai Antiferov <75987872+nantiferov@users.noreply.github.com> Date: Sat, 10 Jul 2021 00:54:49 +0300 Subject: [PATCH] Add optional os_distribution parameter (#29) * Add optional os_distribution parameter Fixes #28 Co-authored-by: Dawid Dziurla --- README.md | 2 ++ action.yml | 3 +++ main.js | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3a2143e..4f80a2f 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,6 @@ An action that builds a Debian package from source in a Docker container. source_directory: lolcat # Optional, relative to workspace directory artifacts_directory: output + # Optional, value from `debian/changelog` is used if not defined + os_distribution: bionic ``` diff --git a/action.yml b/action.yml index 7e90219..173700e 100644 --- a/action.yml +++ b/action.yml @@ -12,6 +12,9 @@ inputs: description: Directory where build artifacts will be placed, relative to workspace required: false default: ./ + os_distribution: + description: OS distribution name, value from `debian/changelog` is used if not defined + required: false runs: using: node12 main: main.js diff --git a/main.js b/main.js index d4f9cb7..3589243 100644 --- a/main.js +++ b/main.js @@ -30,6 +30,7 @@ async function main() { try { const sourceRelativeDirectory = core.getInput("source_directory") || "./" const artifactsRelativeDirectory = core.getInput("artifacts_directory") || "./" + const osDistribution = core.getInput("os_distribution") || "" const workspaceDirectory = process.cwd() const sourceDirectory = path.join(workspaceDirectory, sourceRelativeDirectory) @@ -38,9 +39,10 @@ async function main() { const file = path.join(sourceDirectory, "debian/changelog") const changelog = await firstline(file) - const regex = /^(?.+) \(((?[0-9]+):)?(?[^:-]+)(-(?[^:-]+))?\) (?.+);/ + const regex = /^(?.+) \(((?[0-9]+):)?(?[^:-]+)(-(?[^:-]+))?\) (?.+);/ const match = changelog.match(regex) - const { pkg, epoch, version, revision, distribution } = match.groups + const { pkg, epoch, version, revision, packageDistribution } = match.groups + const distribution = osDistribution ? osDistribution : packageDistribution const imageName = await getImageName(distribution) const imageTag = await getImageTag(imageName, distribution) const container = pkg