-
Notifications
You must be signed in to change notification settings - Fork 58
86 lines (77 loc) · 3.64 KB
/
build_linux.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Builds for Linux
on:
workflow_call:
inputs:
artifact_archive:
required: true
type: string
workflow_dispatch:
inputs:
artifact_archive:
required: true
type: string
default: artifacts-build_linux
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Hack around https://github.com/actions/checkout/issues/290
run: |
git fetch --tags --force
- name: Build on Ubuntu Linux
run: |
sudo apt-get update -y --allow-releaseinfo-change
sudo apt-get install -y build-essential git cmake libxml2-dev python3-docutils zip checkinstall
mkdir build
cmake -S . -B ./build -DCMAKE_C_FLAGS="-Wall" -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build ./build
- name: Set env vars
run: |
ARCH="$(dpkg --print-architecture)"
echo "ARCH=${ARCH}">> ${GITHUB_ENV}
BUILD_DIR="./build"
echo "BUILD_DIR=${BUILD_DIR}" >> ${GITHUB_ENV}
VERSION=$(sed -n -e '/^#define VERSION /{s/#define VERSION "\(.*\)"/\1/;s/unknown/'"$(date +0.0.%Y%m%d)"'/g;p}' ${BUILD_DIR}/version.h)
echo "VERSION=${VERSION}" >> ${GITHUB_ENV}
GH_REPO=$(echo -n "${GITHUB_REPOSITORY}" | cut -d "/" -f 2)
echo "GH_REPO=${GH_REPO}" >> ${GITHUB_ENV}
GH_USER=$(echo -n "${GITHUB_REPOSITORY}" | cut -d "/" -f 1)
echo "GH_USER=${GH_USER}" >> ./build/env
DEPLOYFILEPREFIX="${GH_REPO}_${VERSION}"
echo DEPLOYFILEPREFIX="${DEPLOYFILEPREFIX}" >> ${GITHUB_ENV}
DEPLOYFILEPREFIX_BIN="${DEPLOYFILEPREFIX}-${GITHUB_RUN_NUMBER}_${ARCH}"
echo DEPLOYFILEPREFIX_BIN="${DEPLOYFILEPREFIX_BIN}" >> ${GITHUB_ENV}
cat ${GITHUB_ENV}
- name: Checkinstall deb package creation
run: |
sudo checkinstall --strip=no --install=no --pkgname="${GH_REPO}" --pkgversion="${VERSION}" --pkgrelease=${GITHUB_RUN_NUMBER} --arch="${ARCH}" --maintainer="${GH_USER}@GitHub" --pkgsource="https://github.com/${GH_USER}/${GH_REPO}/releases/download/v${VERSION}/${DEPLOYFILEPREFIX}.orig.tar.gz" --pkgaltsource="https://github.com/${GH_USER}/${GH_REPO}/" --pkglicense="GPLv3" --pakdir=./build/ -D -y cmake --build ./build/ --target install
- name: Collect files
run: |
sudo chown -R $USER:$USER ./build/
for FILE in ./build/doc/man/*.1 ; do gzip ${FILE} ; done
zip -j ./build/${DEPLOYFILEPREFIX_BIN}.zip ./build/vcontrold ./build/vclient ./build/doc/man/vcontrold.1.gz ./build/doc/man/vclient.1.gz COPYING README.md
- name: Archive Source
# this is just to provide a *.orig.tar.gz source archive as it is tradition for Debian packages
# TODO: Use .gitattributes to set export-ignore instead of tar --delete
run: |
git archive --prefix "${GH_REPO}-${VERSION}/" -o "./build/${DEPLOYFILEPREFIX}.orig.tar" ${GITHUB_SHA}
tar -rf "./build/${DEPLOYFILEPREFIX}.orig.tar" --owner=root --group=root --transform="s#^.*build/#${GH_REPO}-${VERSION}/src/#" ./build/version.h
tar --delete -f "./build/${DEPLOYFILEPREFIX}.orig.tar" --wildcards "${GH_REPO}-${VERSION}/.*"
gzip --best "./build/${DEPLOYFILEPREFIX}.orig.tar"
tar tzvf "./build/${DEPLOYFILEPREFIX}.orig.tar.gz" --force-local
- name: Collect files 2
run: |
mkdir artifact-upload
mv ./build/*.zip ./build/*.deb ./build/*.tar.gz ./artifact-upload/
ls -laF ./artifact-upload/
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact_archive }}
path: |
artifact-upload/*
if-no-files-found: error