update
This commit is contained in:
parent
b367c08be4
commit
d9becc67b6
7
.github/workflows/test.yml
vendored
7
.github/workflows/test.yml
vendored
|
@ -13,4 +13,9 @@ jobs:
|
|||
- name: Test run
|
||||
uses: ./
|
||||
with:
|
||||
directory: lolcat
|
||||
source_directory: lolcat
|
||||
artifacts_directory: output
|
||||
- name: Check files
|
||||
run: |
|
||||
ls -lh output
|
||||
ls -lh output/lolcat_*.*
|
|
@ -8,6 +8,7 @@ An action that builds a Debian package from source.
|
|||
- name: Build Debian package
|
||||
uses: dawidd6/action-debian-package@master
|
||||
with:
|
||||
directory: lolcat # optional, relative to workspace directory
|
||||
source_directory: lolcat # optional, relative to workspace directory
|
||||
artifacts_directory: output # optional, relative to workspace directory
|
||||
os: debian # or ubuntu, defaults to debian
|
||||
```
|
||||
|
|
|
@ -4,10 +4,14 @@ branding:
|
|||
color: red
|
||||
icon: package
|
||||
inputs:
|
||||
directory:
|
||||
source_directory:
|
||||
description: Directory where Debian sources are, relative to workspace
|
||||
required: false
|
||||
default: ./
|
||||
artifacts_directory:
|
||||
description: Directory where build artifacts will be placed, relative to workspace
|
||||
required: false
|
||||
default: ./
|
||||
os:
|
||||
description: '"ubuntu" or "debian"'
|
||||
required: false
|
||||
|
|
29
main.js
29
main.js
|
@ -1,30 +1,32 @@
|
|||
const path = require("path")
|
||||
const core = require("@actions/core")
|
||||
const exec = require("@actions/exec")
|
||||
const firstline = require("firstline")
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const directory = core.getInput("directory", { required: true })
|
||||
const sourceDirectory = core.getInput("source_directory", { required: true })
|
||||
const artifactsDirectory = core.getInput("artifacts_directory", { required: true })
|
||||
const os = core.getInput("os", { required: true })
|
||||
|
||||
const directoryRunner = path.join(process.cwd(), directory)
|
||||
const directoryContainer = "/build/source"
|
||||
|
||||
const file = path.join(directoryRunner, "debian/changelog")
|
||||
const workspaceDirectory = process.cwd()
|
||||
const file = path.join(workspaceDirectory, sourceDirectory, "debian/changelog")
|
||||
const changelog = await firstline(file)
|
||||
const regex = /^(?<package>.+) \((?<version>.+)-(?<revision>.+)\) (?<distribution>.+); (?<options>.+)$/
|
||||
const regex = /^(?<package>.+) \((?<version>[^-]+)-?(?<revision>[^-]+)?\) (?<distribution>.+); (?<options>.+)$/
|
||||
const match = changelog.match(regex)
|
||||
const { package, version, revision, distribution } = match.groups
|
||||
const container = package + "_" + version + "-" + revision
|
||||
const container = package + "_" + version
|
||||
const image = os + ":" + distribution.replace("UNRELEASED", "unstable")
|
||||
|
||||
fs.mkdirSync(artifactsDirectory, { recursive: true })
|
||||
|
||||
core.startGroup("Create container")
|
||||
await exec.exec("docker", [
|
||||
"create",
|
||||
"--name", container,
|
||||
"--volume", directoryRunner + ":" + directoryContainer,
|
||||
"--workdir", directoryContainer,
|
||||
"--volume", workspaceDirectory + ":" + workspaceDirectory,
|
||||
"--workdir", path.join(workspaceDirectory, sourceDirectory),
|
||||
"--tty",
|
||||
image,
|
||||
"sleep", "inf"
|
||||
|
@ -38,6 +40,7 @@ async function main() {
|
|||
])
|
||||
core.endGroup()
|
||||
|
||||
if (revision) {
|
||||
core.startGroup("Create tarball")
|
||||
await exec.exec("docker", [
|
||||
"exec",
|
||||
|
@ -50,6 +53,7 @@ async function main() {
|
|||
"./"
|
||||
])
|
||||
core.endGroup()
|
||||
}
|
||||
|
||||
core.startGroup("Update packages list")
|
||||
await exec.exec("docker", [
|
||||
|
@ -71,7 +75,7 @@ async function main() {
|
|||
await exec.exec("docker", [
|
||||
"exec",
|
||||
container,
|
||||
"apt-get", "build-dep", "-y", directoryContainer
|
||||
"apt-get", "build-dep", "-y", "./"
|
||||
])
|
||||
core.endGroup()
|
||||
|
||||
|
@ -90,9 +94,10 @@ async function main() {
|
|||
"find",
|
||||
"..",
|
||||
"-maxdepth", "1",
|
||||
"-name", `${package}_${version}*.*`,
|
||||
"-type", "f",
|
||||
"-print",
|
||||
"-exec", "cp", "{}", ".", ";"
|
||||
"-exec", "cp", "{}", artifactsDirectory, ";"
|
||||
])
|
||||
core.endGroup()
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in a new issue