-
Notifications
You must be signed in to change notification settings - Fork 3
80 lines (80 loc) · 3.48 KB
/
build-rpm.yaml
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
on: push
env:
NIGHTLY_BRANCH: develop
jobs:
build-rpm:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
strategy:
fail-fast: false
matrix:
os: [almalinux]
version: [8, 9]
runs-on: ubuntu-latest
container: '${{ matrix.os }}:${{ matrix.version }}'
steps:
- name: Install dependencies
run: |
dnf upgrade -y
[[ "${{ matrix.version }}" = 8 ]] && dnf module enable -y maven:3.8/common
dnf install -y git rpmdevtools rpmlint maven-openjdk11
- name: Setup build tree
run: |
mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
- uses: actions/checkout@v4
with:
path: 'rpmbuild/BUILD'
fetch-depth: 0
- name: Calculate version and repo
run: |
cd rpmbuild/BUILD
if [[ ${{ github.ref_type }} = 'tag' ]]; then
# In case is a tag, get the tag value
GITHUB_REF=${{ github.ref }}
TAG_NAME=${GITHUB_REF#refs/tags/}
# Check if the tag matches v<x>.<y>.<z>(-[0-9A-Za-z-]+)?
if [[ ${TAG_NAME} =~ ^v([0-9]+\.[0-9]+\.[0-9]+)(-[[:alnum:]-]+)?$ ]]; then
if [[ -z ${BASH_REMATCH[2]} ]]; then
REPO='stable'
VERSION="${BASH_REMATCH[1]}"
VERSION_POM=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)
if [[ ${VERSION} != ${VERSION_POM} ]]; then
echo "Version mismatch between tag (${VERSION}) and POM file (${VERSION_POM})"
exit 1
fi
else
# If the tag includes a "-" is a beta, substitute the first "-" with "~" and any other ones with "_"
REPO='beta'
PRERELEASE=$(echo ${BASH_REMATCH[2]:1} | sed 's/-/_/g')
VERSION="${BASH_REMATCH[1]}~$PRERELEASE"
fi
fi
else
# Use the output of "git describe" to create version dropping the leading "v" and substituting:
# - the last "-" with "."
# - the now last "-" with "^"
# - the first remaining "-" (if any) with "~"
# - all possible remaining "-" with "_"
VERSION=$(git describe --tags --long | sed 's/^v//' | sed -r 's/(.*)-/\1./' | sed -r 's/(.*)-/\1^/' | sed 's/-/~/' | sed 's/-/_/g')
if [[ ${GITHUB_REF} = 'refs/heads/'+$NIGHTLY_BRANCH ]]; then
REPO='nightly'
fi
fi
echo "REPO=$REPO" >> "$GITHUB_ENV"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "Version: $VERSION"
echo "Repo: ${REPO:-none}"
- name: Build RPM
run: |
cp rpmbuild/BUILD/storm-webdav.spec rpmbuild/SPECS/storm-webdav.spec
rpmlint rpmbuild/SPECS/storm-webdav.spec
rpmbuild --define "_topdir `pwd`/rpmbuild" --define "base_version ${VERSION}" -ba rpmbuild/SPECS/storm-webdav.spec
- uses: actions/upload-artifact@v4
with:
name: build-rpm-${{ matrix.os }}-${{ matrix.version }}
path: |
rpmbuild/RPMS/noarch/*.rpm
- name: Upload release to repo
if: env.REPO != ''
run: |
curl --fail --user "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file rpmbuild/RPMS/noarch/*.rpm https://repo.cloud.cnaf.infn.it/repository/storm-rpm-$REPO/redhat${{ matrix.version }}/