Skip to content
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
46 changes: 36 additions & 10 deletions .github/workflows/self-build-rpm.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
name: Run oneself to build self rpm
on: workflow_dispatch
---

name: Build Self as RPM
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-upload:
runs-on: self-hosted
build-rpm:
name: EL${{ matrix.el_version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
el_version: [8, 9, 10]
container:
image: almalinux:${{ matrix.el_version }}
steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: |
dnf -y install rpmdevtools git

- name: Checkout code
uses: actions/checkout@v6
with:
set-safe-directory: true
persist-credentials: false
- run: ./scripts/git-rpm-tools
- uses: actions/upload-artifact@v3
with:
name: rpms
path: ./*.rpm
fetch-depth: 0

- name: Switch to branch to leave detached head state
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
git checkout -b gha-build

- name: Build RPMs
run: ./scripts/git-rpm-tools
14 changes: 14 additions & 0 deletions scripts/git-rpm-tools
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ function build_prep() {
GRT_ART_STORAGE_LOC=${GRT_ART_STORAGE_LOC:-$WORK_DIR}
echo "Set artifact storage location to $GRT_ART_STORAGE_LOC"

# Check to make sure we aren't in a detached head state, which can cause issues with git archive
if [ -z "$GIT_BRANCH" ] && [ -z "$ABSORB_LOCAL" ] && [ -z "$DIRTY" ]; then
git_branch_check=$(git symbolic-ref --quiet HEAD 2> /dev/null)
if [ $? -ne 0 ]; then
die "Error: HEAD is detached, please specify a branch with -b or use -a to include local changes"
fi
fi

# If -a (ABSORB_LOCAL) is set, generate and use a temporary stash branch
# which includes any uncommitted local changes
# Else if -b is set, use the branch name provided to -b (GIT_BRANCH)
Expand Down Expand Up @@ -101,6 +109,9 @@ function build_prep() {
echo "Archiving sources to: $BUILD_TREE/SOURCES"
mkdir -p $BUILD_TREE/SOURCES
git archive --prefix="${TARBALL_NAME%.tar.gz}/" --format=tar.gz $GIT_BRANCH > $BUILD_TREE/SOURCES/$TARBALL_NAME
if [ $? -ne 0 ]; then
die "Error: git archive failed, cannot continue!"
fi

# Figure out dist identifier, e.g. epochtime-[branchname-]osver
# using release number from spec for now
Expand All @@ -122,6 +133,9 @@ function build_pkg() {
--define "_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
--define "debug_package %{nil}" \
-$1 $BUILD_TREE/SPECS/*.spec
if [ $? -ne 0 ]; then
die "Error: rpmbuild failed, cannot continue!"
fi

# Move artifacts to root dir
artifacts=()
Expand Down