Skip to content

Commit 6af5d30

Browse files
committed
build: update build flow
- Update the way version tags are added during build. Now we can tag a commit in github, and the correct version string will be used for the builds. - Run the workflow on any tag, so it builds tags in branches also. - Drop copr Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
1 parent d7b0805 commit 6af5d30

6 files changed

Lines changed: 112 additions & 119 deletions

File tree

‎.automation/build-rpm.sh‎

Lines changed: 0 additions & 16 deletions
This file was deleted.

‎.automation/build-srpm.sh‎

Lines changed: 0 additions & 26 deletions
This file was deleted.

‎.copr/Makefile‎

Lines changed: 0 additions & 36 deletions
This file was deleted.

‎.github/workflows/build.yml‎

Lines changed: 86 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,117 @@
1+
---
12
name: build
3+
24
on:
35
push:
46
branches: [master]
7+
tags: ['*']
58
pull_request:
69
branches: [master]
710
workflow_dispatch:
811

912
jobs:
1013
build:
1114
runs-on: ubuntu-latest
12-
name: Test and build
13-
container:
14-
image: quay.io/ovirt/buildcontainer:el10stream
15-
16-
steps:
17-
- name: Checkout sources
18-
uses: actions/checkout@v4
19-
- name: Run maven build
20-
run: |
21-
./autogen.sh
22-
./configure
23-
mvn test -P\!slow-tests-disabled
24-
25-
build-rpms:
26-
runs-on: ubuntu-latest
27-
needs: build
15+
permissions:
16+
contents: read
2817
strategy:
2918
fail-fast: false
3019
matrix:
3120
include:
21+
- name: almalinux-9
22+
shortcut: el9
23+
container-name: almalinux9
24+
- name: almalinux-10
25+
shortcut: el10
26+
container-name: almalinux10
3227
- name: centos-stream-9
33-
shortcut: cs9
28+
shortcut: el9s
3429
container-name: el9stream
3530
- name: centos-stream-10
36-
shortcut: cs10
31+
shortcut: el10s
3732
container-name: el10stream
3833

39-
name: ${{ matrix.name }}
40-
41-
env:
42-
ARTIFACTS_DIR: exported-artifacts
43-
34+
name: Build on ${{ matrix.name }}
4435
container:
4536
image: quay.io/ovirt/buildcontainer:${{ matrix.container-name }}
4637

4738
steps:
39+
- name: Checkout sources
40+
uses: actions/checkout@v7
4841

49-
- name: Checkout sources
50-
uses: ovirt/checkout-action@main
42+
- name: Mark repository as safe
43+
run: git config --global --add safe.directory "$(pwd)"
5144

52-
- name: Mark git repo as safe
53-
run: git config --global --add safe.directory $(pwd)
45+
- name: Install dependencies
46+
run: |
47+
dnf install -y \
48+
apache-commons-lang3 \
49+
autoconf \
50+
automake \
51+
gcc \
52+
git \
53+
jackson-annotations \
54+
jackson-core \
55+
jackson-databind \
56+
java-21-openjdk-devel \
57+
javapackages-tools \
58+
junit \
59+
make \
60+
maven \
61+
maven-local-openjdk21 \
62+
maven-source-plugin \
63+
mockito \
64+
rpm-build \
65+
slf4j \
66+
slf4j-jdk14
67+
68+
- name: Set build environment
69+
run: |
70+
TAG=$(git tag --points-at HEAD | head -1)
71+
if [[ -n "$TAG" ]]; then
72+
if [[ "$TAG" =~ -([0-9]+)$ ]]; then
73+
echo "PACKAGE_RPM_RELEASE=${BASH_REMATCH[1]}" >> $GITHUB_ENV
74+
else
75+
echo "PACKAGE_RPM_RELEASE=1" >> $GITHUB_ENV
76+
fi
77+
else
78+
echo "RELEASE_SUFFIX=.$(date --utc +%Y%m%d%H%M%S).git$(git rev-parse --short HEAD)" >> $GITHUB_ENV
79+
fi
80+
81+
- name: Autogen
82+
run: ./autogen.sh
83+
84+
- name: Configure
85+
run: ./configure
86+
87+
- name: Run tests
88+
run: mvn test -P\!slow-tests-disabled
89+
90+
- name: Build RPM
91+
run: make -j rpm
92+
93+
- name: Collect artifacts
94+
run: |
95+
mkdir -p exported-artifacts
96+
find tmp.repos -iname \*rpm -exec mv "{}" exported-artifacts/ \;
97+
mv ./*tar.gz exported-artifacts/
5498
55-
- name: Perform build
56-
run: |
57-
.automation/build-rpm.sh $ARTIFACTS_DIR
99+
- name: Upload artifacts
100+
uses: actions/upload-artifact@v7
101+
with:
102+
name: rpm-${{ matrix.shortcut }}
103+
path: exported-artifacts
58104

59-
- name: Upload artifacts
60-
uses: ovirt/upload-rpms-action@main
61-
with:
62-
directory: ${{ env.ARTIFACTS_DIR }}
105+
publish-rpms:
106+
permissions:
107+
artifact-metadata: read
108+
needs: build
109+
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
110+
uses: ovirt/ovirt-workflows/.github/workflows/publish-rpms.yml@main
111+
secrets: inherit
63112

64113
publish-snapshot:
65-
needs: build-rpms
114+
needs: build
66115
if: ${{ github.ref == 'refs/heads/master' }}
67116
runs-on: ubuntu-latest
68117
name: Publish snapshot to maven central
@@ -72,13 +121,13 @@ jobs:
72121

73122
steps:
74123
- name: Checkout sources
75-
uses: actions/checkout@v4
124+
uses: actions/checkout@v7
76125

77126
- name: Mark git repo as safe
78127
run: git config --global --add safe.directory $(pwd)
79128

80129
- name: Use cache for maven
81-
uses: actions/cache@v4
130+
uses: actions/cache@v6
82131
with:
83132
path: ~/.m2/repository
84133
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}

‎Makefile.am‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,27 @@
1919

2020
AUTOMAKE_OPTIONS = foreign 1.9
2121
ACLOCAL_AMFLAGS = -I m4
22+
SHELL := /bin/bash
2223

24+
TMPREPOS = tmp.repos
25+
RPMBUILD_ARGS := --define="_topdir `pwd`/$(TMPREPOS)"
26+
RPMBUILD_ARGS += $(if $(RELEASE_SUFFIX), --define="release_suffix $(RELEASE_SUFFIX)")
27+
28+
srpm: dist
29+
rm -fr "$(TMPREPOS)"
30+
mkdir -p $(TMPREPOS)/{SPECS,RPMS,SRPMS,SOURCES}
31+
rpmbuild $(RPMBUILD_ARGS) -ts "$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.gz"
32+
@echo
33+
@echo "srpm available at '$(TMPREPOS)'"
34+
@echo
35+
36+
rpm: srpm
37+
rpmbuild $(RPMBUILD_ARGS) --rebuild "$(TMPREPOS)"/SRPMS/*.src.rpm
38+
@echo
39+
@echo "rpm(s) available at '$(TMPREPOS)'"
40+
@echo
41+
42+
.PHONY: srpm rpm
2343
MAINTAINERCLEANFILES = \
2444
config.log config.status \
2545
$(srcdir)/Makefile.in \
@@ -46,7 +66,7 @@ dist_noinst_DATA = \
4666
$(NULL)
4767

4868
clean-local:
49-
rm -fr target
69+
rm -fr target tmp.repos
5070
if !WITH_DIST_ONLY
5171
$(MVN) clean
5272
endif

‎configure.ac‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ define([VERSION_MAJOR], [1])
2323
define([VERSION_MINOR], [7])
2424
define([VERSION_FIX], [5])
2525
define([VERSION_NUMBER], VERSION_MAJOR[.]VERSION_MINOR[.]VERSION_FIX)
26-
define([VERSION_SUFFIX], [])
2726

28-
AC_INIT([vdsm-jsonrpc-java], VERSION_NUMBER[]VERSION_SUFFIX)
27+
AC_INIT([vdsm-jsonrpc-java], VERSION_NUMBER)
2928
PACKAGE_RPM_VERSION="VERSION_NUMBER"
30-
PACKAGE_RPM_RELEASE="0"
29+
AC_ARG_VAR([PACKAGE_RPM_RELEASE],
30+
[RPM release field (default: 0.master for development, release number for release builds)])
31+
AS_IF([test -z "$PACKAGE_RPM_RELEASE"],
32+
[PACKAGE_RPM_RELEASE="0.master"])
3133
PACKAGE_MAVEN_VERSION="VERSION_MAJOR.VERSION_MINOR.VERSION_FIX"
3234
AC_SUBST([PACKAGE_RPM_VERSION])
3335
AC_SUBST([PACKAGE_RPM_RELEASE])

0 commit comments

Comments
 (0)