-
Notifications
You must be signed in to change notification settings - Fork 17
80 lines (68 loc) · 2.39 KB
/
build-rpm-packages.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
name: Build RPM Packages
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: ["fedora:38", "fedora:37", "almalinux:9", "almalinux:8"]
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch full Git history and tags
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache dnf packages
uses: actions/cache@v2
with:
path: /var/cache/dnf
key: ${{ runner.os }}-dnf-${{ hashFiles('**/Dockerfile') }}
restore-keys: |
${{ runner.os }}-dnf-
- name: Determine version and dist
id: version
run: |
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")
TAGGED_COMMIT=$(git describe --tags --exact-match 2>/dev/null || echo "notag")
if [ "$TAGGED_COMMIT" = "notag" ]; then
VERSION="${LATEST_TAG}+"
DIST="-git"
else
VERSION=$LATEST_TAG
DIST=""
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "DIST=$DIST" >> $GITHUB_ENV
- name: Build RPM packages in Docker
run: |
docker run --rm -v $(pwd):/workspace -w /workspace ${{ matrix.os }} /bin/bash -c "
dnf install -y epel-release
dnf install -y rpm-build dnf-plugins-core yum-utils gettext gettext-devel autopoint
./autogen.sh
yum-builddep -y xnec2c.spec
mkdir -p ~/rpmbuild/SPECS ~/rpmbuild/SOURCES
cp xnec2c.spec ~/rpmbuild/SPECS/
tar -czvf ~/rpmbuild/SOURCES/xnec2c-v${VERSION}.tar.gz --transform 's,^,xnec2c-v${VERSION}/,' *
rpmbuild -ba -D \"_topdir $(pwd)/rpmbuild\" -D \"dist $DIST\" ~/rpmbuild/SPECS/xnec2c.spec
cp ~/rpmbuild/RPMS/x86_64/xnec2c-*.rpm ."
- name: Test RPM Package
run: |
docker run --rm -v $(pwd):/workspace -w /workspace ${{ matrix.os }} /bin/bash -c "
dnf install -y ./xnec2c-*.rpm
xnec2c -h"
- name: Upload the RPM package
uses: actions/upload-artifact@v2
with:
name: xnec2c-${{ matrix.os }}.rpm
path: xnec2c-*.rpm