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
|
- name: Test run
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
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
|
- name: Build Debian package
|
||||||
uses: dawidd6/action-debian-package@master
|
uses: dawidd6/action-debian-package@master
|
||||||
with:
|
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
|
os: debian # or ubuntu, defaults to debian
|
||||||
```
|
```
|
||||||
|
|
|
@ -4,10 +4,14 @@ branding:
|
||||||
color: red
|
color: red
|
||||||
icon: package
|
icon: package
|
||||||
inputs:
|
inputs:
|
||||||
directory:
|
source_directory:
|
||||||
description: Directory where Debian sources are, relative to workspace
|
description: Directory where Debian sources are, relative to workspace
|
||||||
required: false
|
required: false
|
||||||
default: ./
|
default: ./
|
||||||
|
artifacts_directory:
|
||||||
|
description: Directory where build artifacts will be placed, relative to workspace
|
||||||
|
required: false
|
||||||
|
default: ./
|
||||||
os:
|
os:
|
||||||
description: '"ubuntu" or "debian"'
|
description: '"ubuntu" or "debian"'
|
||||||
required: false
|
required: false
|
||||||
|
|
53
main.js
53
main.js
|
@ -1,30 +1,32 @@
|
||||||
const path = require("path")
|
|
||||||
const core = require("@actions/core")
|
const core = require("@actions/core")
|
||||||
const exec = require("@actions/exec")
|
const exec = require("@actions/exec")
|
||||||
const firstline = require("firstline")
|
const firstline = require("firstline")
|
||||||
|
const path = require("path")
|
||||||
|
const fs = require("fs")
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
try {
|
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 os = core.getInput("os", { required: true })
|
||||||
|
|
||||||
const directoryRunner = path.join(process.cwd(), directory)
|
const workspaceDirectory = process.cwd()
|
||||||
const directoryContainer = "/build/source"
|
const file = path.join(workspaceDirectory, sourceDirectory, "debian/changelog")
|
||||||
|
|
||||||
const file = path.join(directoryRunner, "debian/changelog")
|
|
||||||
const changelog = await firstline(file)
|
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 match = changelog.match(regex)
|
||||||
const { package, version, revision, distribution } = match.groups
|
const { package, version, revision, distribution } = match.groups
|
||||||
const container = package + "_" + version + "-" + revision
|
const container = package + "_" + version
|
||||||
const image = os + ":" + distribution.replace("UNRELEASED", "unstable")
|
const image = os + ":" + distribution.replace("UNRELEASED", "unstable")
|
||||||
|
|
||||||
|
fs.mkdirSync(artifactsDirectory, { recursive: true })
|
||||||
|
|
||||||
core.startGroup("Create container")
|
core.startGroup("Create container")
|
||||||
await exec.exec("docker", [
|
await exec.exec("docker", [
|
||||||
"create",
|
"create",
|
||||||
"--name", container,
|
"--name", container,
|
||||||
"--volume", directoryRunner + ":" + directoryContainer,
|
"--volume", workspaceDirectory + ":" + workspaceDirectory,
|
||||||
"--workdir", directoryContainer,
|
"--workdir", path.join(workspaceDirectory, sourceDirectory),
|
||||||
"--tty",
|
"--tty",
|
||||||
image,
|
image,
|
||||||
"sleep", "inf"
|
"sleep", "inf"
|
||||||
|
@ -38,18 +40,20 @@ async function main() {
|
||||||
])
|
])
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
|
|
||||||
core.startGroup("Create tarball")
|
if (revision) {
|
||||||
await exec.exec("docker", [
|
core.startGroup("Create tarball")
|
||||||
"exec",
|
await exec.exec("docker", [
|
||||||
container,
|
"exec",
|
||||||
"tar",
|
container,
|
||||||
"--exclude-vcs",
|
"tar",
|
||||||
"--exclude", "./debian",
|
"--exclude-vcs",
|
||||||
"--transform", `s/^\./${package}-${version}/`,
|
"--exclude", "./debian",
|
||||||
"-cvzf", `../${package}_${version}.orig.tar.gz`,
|
"--transform", `s/^\./${package}-${version}/`,
|
||||||
"./"
|
"-cvzf", `../${package}_${version}.orig.tar.gz`,
|
||||||
])
|
"./"
|
||||||
core.endGroup()
|
])
|
||||||
|
core.endGroup()
|
||||||
|
}
|
||||||
|
|
||||||
core.startGroup("Update packages list")
|
core.startGroup("Update packages list")
|
||||||
await exec.exec("docker", [
|
await exec.exec("docker", [
|
||||||
|
@ -71,7 +75,7 @@ async function main() {
|
||||||
await exec.exec("docker", [
|
await exec.exec("docker", [
|
||||||
"exec",
|
"exec",
|
||||||
container,
|
container,
|
||||||
"apt-get", "build-dep", "-y", directoryContainer
|
"apt-get", "build-dep", "-y", "./"
|
||||||
])
|
])
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
|
|
||||||
|
@ -90,9 +94,10 @@ async function main() {
|
||||||
"find",
|
"find",
|
||||||
"..",
|
"..",
|
||||||
"-maxdepth", "1",
|
"-maxdepth", "1",
|
||||||
|
"-name", `${package}_${version}*.*`,
|
||||||
"-type", "f",
|
"-type", "f",
|
||||||
"-print",
|
"-print",
|
||||||
"-exec", "cp", "{}", ".", ";"
|
"-exec", "cp", "{}", artifactsDirectory, ";"
|
||||||
])
|
])
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Reference in a new issue