Add optional os_distribution parameter (#29)

* Add optional os_distribution parameter

Fixes #28

Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>
This commit is contained in:
Nicolai Antiferov 2021-07-10 00:54:49 +03:00 committed by GitHub
parent 5513f52a10
commit fb3670aed9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View file

@ -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
```

View file

@ -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

View file

@ -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 = /^(?<pkg>.+) \(((?<epoch>[0-9]+):)?(?<version>[^:-]+)(-(?<revision>[^:-]+))?\) (?<distribution>.+);/
const regex = /^(?<pkg>.+) \(((?<epoch>[0-9]+):)?(?<version>[^:-]+)(-(?<revision>[^:-]+))?\) (?<packageDistribution>.+);/
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