mirror-coreos-chunkah/.packit.yaml
Jonathan Lebon b64a38bc82 packit: add get-current-version to fix PR builds
Packit defaults to `git describe` for the project version. So when
cutting a release, on PRs where we're bumping the chunkah version in
`Cargo.toml`, we get a mismatch: `create-archives.sh` reads the version
from `Cargo.toml` (e.g. 0.3.0), but `PACKIT_PROJECT_VERSION` resolved to
0.2.0 from the last tag, so `fix-spec-file` referenced a vendor tarball
that didn't exist.

Add a `get-current-version` action that reads the version from
`Cargo.toml` via `cargo metadata`, keeping `PACKIT_PROJECT_VERSION`
consistent with the archives that `create-archives.sh` produces.

Assisted-by: OpenCode (Claude Opus 4.6)
2026-03-11 10:35:07 -04:00

48 lines
1.6 KiB
YAML

upstream_tag_template: v{version}
specfile_path: packaging/chunkah.spec
srpm_build_deps:
- cargo
- cargo-vendor-filterer
- git
- openssl-devel
- zlib-devel
actions:
# Packit defaults to `git describe` for the version, but for PRs that bump the
# Cargo.toml release, the versioned tarball that create-archive produces will
# not match what Packit expects. Always get the version from Cargo.toml.
get-current-version:
- bash -c 'cargo metadata --no-deps --format-version=1 | python3 -c "import json,sys; print(json.load(sys.stdin)[\"packages\"][0][\"version\"])"'
create-archive:
- tools/create-archives.sh --outdir packaging
# Packit only handles Source0 by default; we need to also rewrite Source1
# (the vendor tarball). Overriding this replaces all default behaviour, so
# we must handle Version, Release, and Source0 ourselves too.
fix-spec-file:
- >-
bash -c 'sed -i
-e "s/^Version:.*/Version: ${PACKIT_PROJECT_VERSION}/"
-e "s/^Release:.*/Release: ${PACKIT_RPMSPEC_RELEASE}%{?dist}/"
-e "s|^Source0:.*|Source0: ${PACKIT_PROJECT_ARCHIVE}|"
-e "s|^Source1:.*|Source1: chunkah-${PACKIT_PROJECT_VERSION}-vendor.tar.gz|"
packaging/chunkah.spec'
files_to_sync:
- src: packaging/chunkah.spec
dest: chunkah.spec
jobs:
# Build RPMs in COPR on every PR
- job: copr_build
trigger: pull_request
targets:
- fedora-latest-stable
- fedora-rawhide
# Propose updates to Fedora on release
- job: propose_downstream
trigger: release
dist_git_branches:
rawhide:
fast_forward_merge_into: [fedora-branched]