-
Notifications
You must be signed in to change notification settings - Fork 18
90 lines (73 loc) · 2.52 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
81
82
83
84
85
86
87
88
89
90
name: Build RPM Package
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Determine Version
id: version
run: |
# Get the most recent tag
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
# Check if the latest commit is tagged
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 "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "DIST=$DIST" >> $GITHUB_ENV
- name: Build RPM
run: |
docker run --rm -v $(pwd):/workspace -w /workspace almalinux:9 /bin/bash -c "
set -x
# Install dependencies
dnf install -y epel-release
dnf install -y gcc make automake autoconf gtk3-devel gettext-devel libtool \
rpm-build rpmdevtools git
# Prepare the RPM build environment
rpmdev-setuptree
./autogen.sh
./configure
make xnec2c.spec
make dist
# Copy the spec file to the SPECS directory if necessary
cp xnec2c.spec /root/rpmbuild/SPECS/
cp xnec2c*.tar.gz /root/rpmbuild/SOURCES/xnec2c-${LATEST_TAG}.tar.gz
# Build the RPM
rpmbuild -ba --define \"_version ${VERSION}\" --define \"_dist ${DIST}\" \
--define \"_topdir /root/rpmbuild\" /root/rpmbuild/SPECS/xnec2c.spec
# Check the RPM files
ls -l /root/rpmbuild/RPMS/x86_64
"
- name: Install and Test RPM
run: |
docker run --rm -v $(pwd):/workspace -w /workspace almalinux:9 /bin/bash -c "
# Install the RPM package
dnf install -y /root/rpmbuild/RPMS/x86_64/xnec2c-*.rpm
# Run the test to verify the package
xnec2c -h
"
- name: Upload RPM
uses: actions/upload-artifact@v2
with:
name: xnec2c-rpm
path: /root/rpmbuild/RPMS/x86_64/xnec2c-*.rpm