From e426ea429cb577b21d7fd6e58756759bb0178511 Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Wed, 11 Mar 2026 13:55:20 -0400 Subject: [PATCH 01/12] Modify CI job to matrix build across RH 8-10, on github actions --- .github/workflows/self-build-rpm.yml | 36 ++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/.github/workflows/self-build-rpm.yml b/.github/workflows/self-build-rpm.yml index c84ade9..67ac612 100644 --- a/.github/workflows/self-build-rpm.yml +++ b/.github/workflows/self-build-rpm.yml @@ -1,14 +1,30 @@ -name: Run oneself to build self rpm -on: workflow_dispatch +--- + +name: Build rpms with self +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: - build-upload: - runs-on: self-hosted + build-rpm: + 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 + - uses: actions/checkout@v4 with: persist-credentials: false - - run: ./scripts/git-rpm-tools - - uses: actions/upload-artifact@v3 - with: - name: rpms - path: ./*.rpm + + - name: Install dependencies + run: | + dnf -y install rpmdevtools git + + - name: Build RPMs + run: ./scripts/git-rpm-tools From ed411dc63918d525c15247ef6ceff4863bd2ae3e Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Wed, 11 Mar 2026 13:57:24 -0400 Subject: [PATCH 02/12] Set fetch depth parameter, more descriptive name --- .github/workflows/self-build-rpm.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/self-build-rpm.yml b/.github/workflows/self-build-rpm.yml index 67ac612..b3219d9 100644 --- a/.github/workflows/self-build-rpm.yml +++ b/.github/workflows/self-build-rpm.yml @@ -10,6 +10,7 @@ on: - main jobs: build-rpm: + name: EL${{ matrix.el_version }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -21,6 +22,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false + fetch-depth: 0 - name: Install dependencies run: | From 03bcd3b617de1454c75942402b970f220d95dd90 Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Wed, 11 Mar 2026 13:58:44 -0400 Subject: [PATCH 03/12] Install dependencies first --- .github/workflows/self-build-rpm.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/self-build-rpm.yml b/.github/workflows/self-build-rpm.yml index b3219d9..3a6c573 100644 --- a/.github/workflows/self-build-rpm.yml +++ b/.github/workflows/self-build-rpm.yml @@ -1,6 +1,6 @@ --- -name: Build rpms with self +name: Build Self as RPM on: push: branches: @@ -19,14 +19,15 @@ jobs: container: image: almalinux:${{ matrix.el_version }} steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - fetch-depth: 0 - name: Install dependencies run: | dnf -y install rpmdevtools git + - uses: actions/checkout@v4 + with: + persist-credentials: false + fetch-depth: 0 + - name: Build RPMs run: ./scripts/git-rpm-tools From a6b737e6604911a815ad36899d6658bd7b5ab5f2 Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Wed, 11 Mar 2026 14:05:01 -0400 Subject: [PATCH 04/12] Add checkout to safe directory list --- .github/workflows/self-build-rpm.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/self-build-rpm.yml b/.github/workflows/self-build-rpm.yml index 3a6c573..3b2f691 100644 --- a/.github/workflows/self-build-rpm.yml +++ b/.github/workflows/self-build-rpm.yml @@ -29,5 +29,9 @@ jobs: persist-credentials: false fetch-depth: 0 + + - name: Add current dir to git safe directory + run: git config --global --add safe.directory $PWD + - name: Build RPMs run: ./scripts/git-rpm-tools From 5cf2bf44c817ac380848a3c7e79e670c021d5d41 Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Wed, 11 Mar 2026 14:13:48 -0400 Subject: [PATCH 05/12] Die if rpmbuild or git archive fail --- scripts/git-rpm-tools | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/git-rpm-tools b/scripts/git-rpm-tools index b87a4ff..a3a34a6 100755 --- a/scripts/git-rpm-tools +++ b/scripts/git-rpm-tools @@ -101,6 +101,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 @@ -122,6 +125,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=() From 5361356457a15e9513cfbfa6690e8f53f1308f57 Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Wed, 11 Mar 2026 14:21:08 -0400 Subject: [PATCH 06/12] Add more descriptive error if we are in a detached HEAD state --- .github/workflows/self-build-rpm.yml | 3 ++- scripts/git-rpm-tools | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/self-build-rpm.yml b/.github/workflows/self-build-rpm.yml index 3b2f691..79bcc76 100644 --- a/.github/workflows/self-build-rpm.yml +++ b/.github/workflows/self-build-rpm.yml @@ -24,7 +24,8 @@ jobs: run: | dnf -y install rpmdevtools git - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 with: persist-credentials: false fetch-depth: 0 diff --git a/scripts/git-rpm-tools b/scripts/git-rpm-tools index a3a34a6..c3a9ac8 100755 --- a/scripts/git-rpm-tools +++ b/scripts/git-rpm-tools @@ -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) From 72d4bc0e8a669aa501cc6bcb2f579faad3a1cd72 Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Wed, 11 Mar 2026 14:22:53 -0400 Subject: [PATCH 07/12] Switch away from detatched HEAD before attempting build --- .github/workflows/self-build-rpm.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/self-build-rpm.yml b/.github/workflows/self-build-rpm.yml index 79bcc76..350b8e7 100644 --- a/.github/workflows/self-build-rpm.yml +++ b/.github/workflows/self-build-rpm.yml @@ -30,9 +30,11 @@ jobs: persist-credentials: false fetch-depth: 0 - - name: Add current dir to git safe directory run: git config --global --add safe.directory $PWD + - name: Switch to branch to leave detached head state + run: git switch - + - name: Build RPMs run: ./scripts/git-rpm-tools From a316d94dd11a59ac789ad7cd4869ed6fe1485ca8 Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Wed, 11 Mar 2026 14:24:56 -0400 Subject: [PATCH 08/12] Checkout a new branch, since the detatched HEAD may not be attached to one. --- .github/workflows/self-build-rpm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/self-build-rpm.yml b/.github/workflows/self-build-rpm.yml index 350b8e7..58b5cc3 100644 --- a/.github/workflows/self-build-rpm.yml +++ b/.github/workflows/self-build-rpm.yml @@ -34,7 +34,7 @@ jobs: run: git config --global --add safe.directory $PWD - name: Switch to branch to leave detached head state - run: git switch - + run: git switch checkout -b gha-build - name: Build RPMs run: ./scripts/git-rpm-tools From 4d92585cb71511c42dd1dc5f12f807547aa3b78c Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Wed, 11 Mar 2026 14:25:18 -0400 Subject: [PATCH 09/12] Fix typo --- .github/workflows/self-build-rpm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/self-build-rpm.yml b/.github/workflows/self-build-rpm.yml index 58b5cc3..e9192a2 100644 --- a/.github/workflows/self-build-rpm.yml +++ b/.github/workflows/self-build-rpm.yml @@ -34,7 +34,7 @@ jobs: run: git config --global --add safe.directory $PWD - name: Switch to branch to leave detached head state - run: git switch checkout -b gha-build + run: git checkout -b gha-build - name: Build RPMs run: ./scripts/git-rpm-tools From d0f4097785ebddc67be62e5b91ce6c3e97e9beed Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Thu, 12 Mar 2026 09:58:22 -0400 Subject: [PATCH 10/12] Update to newest checkout action that can set safe directory automatically --- .github/workflows/self-build-rpm.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/self-build-rpm.yml b/.github/workflows/self-build-rpm.yml index e9192a2..7c4afdd 100644 --- a/.github/workflows/self-build-rpm.yml +++ b/.github/workflows/self-build-rpm.yml @@ -25,14 +25,12 @@ jobs: dnf -y install rpmdevtools git - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: + set-safe-directory: true persist-credentials: false fetch-depth: 0 - - name: Add current dir to git safe directory - run: git config --global --add safe.directory $PWD - - name: Switch to branch to leave detached head state run: git checkout -b gha-build From b184a8cfd13b03b94f42698ea28b3fcd30b17f6c Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Thu, 12 Mar 2026 10:03:32 -0400 Subject: [PATCH 11/12] Use ref option from checkout v6 --- .github/workflows/self-build-rpm.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/self-build-rpm.yml b/.github/workflows/self-build-rpm.yml index 7c4afdd..4061d73 100644 --- a/.github/workflows/self-build-rpm.yml +++ b/.github/workflows/self-build-rpm.yml @@ -30,9 +30,10 @@ jobs: set-safe-directory: true persist-credentials: false fetch-depth: 0 + ref: ${{ github.head_ref }} - - name: Switch to branch to leave detached head state - run: git checkout -b gha-build + # - name: Switch to branch to leave detached head state + # run: git checkout -b gha-build - name: Build RPMs run: ./scripts/git-rpm-tools From 3285c330fd68845500a45424c5aa371a7925b632 Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Thu, 12 Mar 2026 10:21:24 -0400 Subject: [PATCH 12/12] Revert previous changes --- .github/workflows/self-build-rpm.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/self-build-rpm.yml b/.github/workflows/self-build-rpm.yml index 4061d73..119dc51 100644 --- a/.github/workflows/self-build-rpm.yml +++ b/.github/workflows/self-build-rpm.yml @@ -30,10 +30,11 @@ jobs: set-safe-directory: true persist-credentials: false fetch-depth: 0 - ref: ${{ github.head_ref }} - # - name: Switch to branch to leave detached head state - # run: git checkout -b gha-build + - 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