Skip to content

Commit

Permalink
Fix spec version patching (#878)
Browse files Browse the repository at this point in the history
Some previously undetected regressions were brought to light after
merging the implementation of #821 in #865.

The background here is that the version defined in the spec files can
be patched during CI builds for master or a PR branch. This is done to
allow these builds to be versioned with qualifiers that identify them
as development builds.

The spec version patching had a couple issues that were introduced back
when removing the pull-request-target support. This PR fixes those and
some other other issues causing the work from #865 not to succeed on
master.
  • Loading branch information
jw3 committed Jun 23, 2023
1 parent 10a7b18 commit 25f3fff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/rpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ jobs:
run: |
make -f .copr/Makefile vendor-app spec=fapolicy-analyzer.spec
- name: Rename source0 with prerelease version
if: endsWith(github.ref, '/master')
run: |
spec_version=$(grep "Version:" fapolicy-analyzer.spec | tr -s ' ' | cut -d' ' -f2)
commit_number=$(git rev-list HEAD --count)
patched_version="$spec_version~dev${commit_number}"
mv fapolicy-analyzer-${spec_version}.tar.gz fapolicy-analyzer-${patched_version}.tar.gz
- name: Rename source0 with pull request version
if: github.event_name == 'pull_request'
run: |
spec_version=$(grep "Version:" fapolicy-analyzer.spec | tr -s ' ' | cut -d' ' -f2)
pr_number=${{ github.event.pull_request.number }}
patched_version="0.0.${pr_number}"
mv fapolicy-analyzer-${spec_version}.tar.gz fapolicy-analyzer-${patched_version}.tar.gz
- name: Upload
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -122,7 +138,7 @@ jobs:
echo "The spec version $spec_version is correct based on git tag $tag"
- name: Patch spec with prerelease version
if: endsWith(github.ref, '/master') && github.event_name != 'pull_request_target'
if: endsWith(github.ref, '/master')
run: |
spec_version=$(grep "Version:" ${{ matrix.props.spec }} | tr -s ' ' | cut -d' ' -f2)
commit_number=$(git rev-list HEAD --count)
Expand All @@ -131,7 +147,7 @@ jobs:
grep Version ${{ matrix.props.spec }}
- name: Patch spec with pull request version
if: github.event_name == 'pull_request_target'
if: github.event_name == 'pull_request'
run: |
spec_version=$(grep "Version:" ${{ matrix.props.spec }} | tr -s ' ' | cut -d' ' -f2)
pr_number=${{ github.event.pull_request.number }}
Expand Down
1 change: 1 addition & 0 deletions scripts/srpm/fapolicy-analyzer.el9.spec
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Source19: %{pypi_source flit_core 3.7.1}
Source20: %{pypi_source typing_extensions 3.7.4.3}

BuildRequires: python3-devel
BuildRequires: python3dist(pip)
BuildRequires: python3dist(babel)
BuildRequires: python3dist(packaging)
BuildRequires: python3dist(pyparsing)
Expand Down

0 comments on commit 25f3fff

Please sign in to comment.