Skip to content

Commit

Permalink
chore: RPM build workflow to fetch correct tags
Browse files Browse the repository at this point in the history
This prevents building images for RPMs and instead makes sure we get
from the registry. This also improves the versioning change based on the
tag so it is more straight-forward
  • Loading branch information
Venefilyn committed Oct 11, 2024
1 parent ac083ad commit 5716e19
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
34 changes: 21 additions & 13 deletions .github/workflows/build-rpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ name: Build release RPMs
on:
push:
tags:
- "v*"
- v*
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Custom tag for release, e.g. v1.2.3-1234"
required: false
default: ""

jobs:
setup_version:
Expand All @@ -22,28 +28,28 @@ jobs:
uses: devops-actions/[email protected]
with:
strip_v: true # Optional: Remove 'v' character from version
default: v0.0.0 # Optional: Default version when tag not found
default: ${{ github.event.inputs.tag }} # Optional: Default version when tag not found

- name: Update specfile to match tag
if: ${{ github.event_name != 'release' }}
uses: richardrigutins/replace-in-files@v2
if: ${{ github.event_name != 'release' || steps.tag.outputs.tag != '' }}
uses: jacobtomlinson/gha-find-replace@v3
with:
files: "packaging/convert2rhel.spec"
search-text: "/(Version: +).*/gi"
replacement-text: "$1${{steps.tag.outputs.tag}}"
include: "packaging/convert2rhel.spec"
find: "(Version: +).*"
replace: "${1}${{steps.tag.outputs.tag}}"

- name: Update convert2rhel version to match tag
if: ${{ github.event_name != 'release' }}
uses: richardrigutins/replace-in-files@v2
if: ${{ github.event_name != 'release' || steps.tag.outputs.tag != '' }}
uses: jacobtomlinson/gha-find-replace@v3
with:
files: "convert2rhel/__init__.py"
search-text: "/(__version__ += +).*/gi"
replacement-text: '$1"${{steps.tag.outputs.tag}}"'
include: "convert2rhel/__init__.py"
find: "(__version__ += +).*"
replace: '${1}\"${{steps.tag.outputs.tag}}\"'

- uses: actions/upload-artifact@v4
with:
name: github-repo
path: ""
path: "."
retention-days: 1

build_rpms:
Expand All @@ -64,6 +70,8 @@ jobs:
name: github-repo

- name: Build RPM package for EL${{ matrix.el.ver }}
env:
BUILD_IMAGES: false # Building an image is unnecessary
run: |
make rpm${{ matrix.el.ver }}
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ endif
.build-image-message:
@echo "Building images"
.build-image%:
@$(PODMAN) build -f Containerfiles/centos$*.Containerfile -t $(IMAGE)-centos$* .
@$(PODMAN) tag $(IMAGE)-centos$* $(IMAGE_REPOSITORY)/$(IMAGE_ORG)/$(IMAGE_PREFIX)-centos:$*
@$(PODMAN) build -f Containerfiles/centos$*.Containerfile -t $(IMAGE)-centos:$* .
@$(PODMAN) tag $(IMAGE)-centos:$* $(IMAGE_REPOSITORY)/$(IMAGE_ORG)/$(IMAGE_PREFIX)-centos:$*
touch $@

# These files need to be made writable for pytest to run
Expand Down

0 comments on commit 5716e19

Please sign in to comment.