Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RPM build #24

Merged
merged 1 commit into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .automation/build-rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash -xe

source $(dirname "$(readlink -f "$0")")/build-srpm.sh

# Install build dependencies
dnf builddep -y rpmbuild/SRPMS/*src.rpm

# Build binary package
rpmbuild \
--define "_topmdir rpmbuild" \
--define "_rpmdir rpmbuild" \
--rebuild rpmbuild/SRPMS/*src.rpm

# Move RPMs to exported artifacts
[[ -d $ARTIFACTS_DIR ]] || mkdir -p $ARTIFACTS_DIR
find rpmbuild -iname \*rpm | xargs mv -t $ARTIFACTS_DIR
41 changes: 41 additions & 0 deletions .automation/build-srpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash -xe

# When building on GitHub we should use GITHUB_SHA environment variable, otherwise parse has from git
if [ "${GITHUB_SHA}" == "" ]; then
GIT_HASH=$(git rev-list HEAD | wc -l)
else
GIT_HASH=$(git rev-parse --short $GITHUB_SHA)
fi

# Directory, where build artifacts will be stored, should be passed as the 1st parameter
ARTIFACTS_DIR=${1:-exported-artifacts}

# Disabling tests can be passed as the 2nd parameter
SKIP_TESTS=${2:-0}

# Prepare the version string (with support for SNAPSHOT versioning)
VERSION=$(mvn help:evaluate -q -DforceStdout -Dexpression=project.version)
VERSION=${VERSION/-SNAPSHOT/-0.${GIT_HASH}.$(date +%04Y%02m%02d%02H%02M)}
IFS='-' read -ra VERSION <<< "$VERSION"
RELEASE=${VERSION[1]-1}

# Prepare source archive
[[ -d rpmbuild/SOURCES ]] || mkdir -p rpmbuild/SOURCES
git archive --format=tar HEAD | gzip -9 > rpmbuild/SOURCES/ovirt-engine-api-model-$VERSION.tar.gz

# Generate AsciiDoc and HTML documentation
mvn package -Pgenerate-adoc-html -Dadoc.linkcss=true
cp target/doc.jar rpmbuild/SOURCES/ovirt-engine-api-model-doc-$VERSION.jar

# Set version and release
sed \
-e "s|@VERSION@|${VERSION}|g" \
-e "s|@RELEASE@|${RELEASE}|g" \
-e "s|@SKIP_TESTS@|${SKIP_TESTS}|g" \
< ovirt-engine-api-model.spec.in \
> ovirt-engine-api-model.spec

# Build source package
rpmbuild \
-D "_topdir rpmbuild" \
-bs ovirt-engine-api-model.spec
36 changes: 0 additions & 36 deletions .automation/build.sh

This file was deleted.

8 changes: 8 additions & 0 deletions .copr/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.PHONY: installdeps srpm

installdeps:
dnf -y install git gzip java-11-openjdk-devel make maven ovirt-engine-api-metamodel rpm-build sed unzip

srpm: installdeps
./.automation/build-srpm.sh exported-artifacts 1
cp rpmbuild/SRPMS/*.src.rpm $(outdir)
63 changes: 15 additions & 48 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
pull_request:
branches: [master]
workflow_dispatch:
branches: [master]

jobs:
build:
Expand All @@ -16,56 +15,21 @@ jobs:
include:
- name: centos-stream-8
shortcut: cs8
container-name: stream8
- name: centos-stream-9
shortcut: cs9
container-name: stream9
container-name: el8stream
# Uncomment CS9 builds once all deps on CS9 are provided
#- name: centos-stream-9
# shortcut: cs9
# container-name: el9stream

name: ${{ matrix.name }}

env:
ARTIFACTS_DIR: exported-artifacts

container:
image: quay.io/centos/centos:${{ matrix.container-name }}
image: quay.io/ovirt/buildcontainer:${{ matrix.container-name }}

steps:
- name: Prepare CentOS Stream 8 environment
if: ${{ matrix.shortcut == 'cs8' }}
run: |
# Install oVirt repositories
dnf copr enable -y ovirt/ovirt-master-snapshot centos-stream-8
dnf install -y ovirt-release-master

# Configure CS8 repositories
dnf config-manager --enable powertools
dnf module enable -y pki-deps javapackages-tools

- name: Prepare CentOS Stream 9 environment
if: ${{ matrix.shortcut == 'cs9' }}
run: |
# DNF core plugins are installed in the official CS9 container image
dnf install -y dnf-plugins-core

# Install oVirt repositories
dnf copr enable -y ovirt/ovirt-master-snapshot
dnf install -y ovirt-release-master

# Configure CS9 repositories
dnf config-manager --enable crb

- name: Install required packages
run: |
dnf install -y \
dnf-utils \
git \
gzip \
java-11-openjdk-devel \
maven \
rpm-build \
sed \
tar

- name: Checkout sources
uses: actions/checkout@v2

Expand All @@ -77,21 +41,24 @@ jobs:
restore-keys: |
${{ runner.os }}-maven-

- name: Install additional build dependencies
run: |
dnf install -y ovirt-engine-api-metamodel unzip

- name: Perform build
run: |
.automation/build.sh $ARTIFACTS_DIR
.automation/build-rpm.sh $ARTIFACTS_DIR

- name: Upload RPM artifacts
uses: actions/upload-artifact@v2
- name: Upload artifacts
uses: ovirt/upload-rpms-action@v2
with:
name: rpm-${{ matrix.shortcut }}
path: ${{ env.ARTIFACTS_DIR}}
directory: ${{ env.ARTIFACTS_DIR }}

- name: Upload generated documentation artifacts
uses: actions/upload-artifact@v2
with:
name: generated-documentation-${{ matrix.shortcut }}
path: target/generated-html*
path: target/html/*


publish-doc:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.iml
.idea/
.bash_history
.vscode/
exported-artifacts/
logs*
mocker*
Expand Down
Loading