Skip to content

Commit e41b5fa

Browse files
author
Luca Bassi
committed
Minor cleanup in Maven and Build RPM workflows
1 parent b502a82 commit e41b5fa

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

.github/workflows/build-rpm.yaml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
name: Build RPM
66
on: push
7-
env:
8-
NIGHTLY_BRANCH: develop
7+
98
jobs:
109
build-rpm:
1110
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
@@ -23,7 +22,7 @@ jobs:
2322
- name: Install dependencies
2423
run: |
2524
dnf upgrade -y
26-
[[ "${{ matrix.version }}" = 8 ]] && dnf module enable -y maven:3.8/common
25+
dnf module enable -y maven:3.8
2726
dnf install -y git rpmdevtools rpmlint maven-openjdk17
2827
- name: Setup build tree
2928
run: |
@@ -41,19 +40,16 @@ jobs:
4140
# Maven uses -SNAPSHOT for pre-releases, change the - to ~ in the RPM
4241
VERSION_RPM=$(echo ${VERSION_POM} | sed 's/-/~/')
4342
if [[ ${{ github.ref_type }} = 'tag' ]]; then
44-
# In case is a tag, get the tag value
45-
GITHUB_REF=${{ github.ref }}
46-
TAG_NAME=${GITHUB_REF#refs/tags/}
47-
# Check if the tag matches v<x>.<y>.<z>
48-
if [[ ${TAG_NAME} =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
43+
# In case is a tag, check if the tag matches v<x>.<y>.<z>
44+
if [[ ${GITHUB_REF_NAME} =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
4945
REPO='stable'
5046
VERSION="${BASH_REMATCH[1]}"
5147
if [[ ${VERSION} != ${VERSION_POM} ]]; then
5248
echo "Version mismatch between tag (${VERSION}) and POM file (${VERSION_POM})"
5349
exit 1
5450
fi
5551
fi
56-
elif [[ ${GITHUB_REF} = "refs/heads/${NIGHTLY_BRANCH}" ]]; then
52+
elif [[ ${GITHUB_REF_NAME} = ${{ github.event.repository.default_branch }} ]]; then
5753
# Check if the version in POM file matches <x>.<y>.<z>-SNAPSHOT
5854
if [[ ${VERSION_POM} =~ ^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT$ ]]; then
5955
REPO='nightly'

.github/workflows/maven.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ name: Maven build
66

77
on:
88
push:
9-
env:
10-
SNAPSHOT_BRANCH: develop
119

1210
jobs:
1311
build:
@@ -66,19 +64,16 @@ jobs:
6664
run: |
6765
VERSION_POM=$(mvn org.apache.maven.plugins:maven-help-plugin:evaluate -Dexpression=project.version -q -DforceStdout)
6866
if [[ ${{ github.ref_type }} = 'tag' ]]; then
69-
# In case is a tag, get the tag value
70-
GITHUB_REF=${{ github.ref }}
71-
TAG_NAME=${GITHUB_REF#refs/tags/}
72-
# Check if the tag matches v<x>.<y>.<z>
73-
if [[ ${TAG_NAME} =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
67+
# In case is a tag, check if the tag matches v<x>.<y>.<z>
68+
if [[ ${GITHUB_REF_NAME} =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
7469
VERSION="${BASH_REMATCH[1]}"
7570
if [[ ${VERSION} != ${VERSION_POM} ]]; then
7671
echo "Version mismatch between tag (${VERSION}) and POM file (${VERSION_POM})"
7772
exit 1
7873
fi
7974
mvn deploy -P central-staging
8075
fi
81-
elif [[ ${GITHUB_REF} = "refs/heads/${SNAPSHOT_BRANCH}" ]]; then
76+
elif [[ ${GITHUB_REF_NAME} = ${{ github.event.repository.default_branch }} ]]; then
8277
# Check if the version in POM file matches <x>.<y>.<z>-SNAPSHOT
8378
if [[ ${VERSION_POM} =~ ^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT$ ]]; then
8479
mvn deploy -P central-staging

0 commit comments

Comments
 (0)