Skip to content

Commit 6ce988d

Browse files
authored
fix(ci): harden packit rpm source prep (#1182)
* fix(ci): harden packit rpm source prep Signed-off-by: Drew Newberry <anewberry@nvidia.com> * fix(ci): restrict packit version tag matching Signed-off-by: Drew Newberry <anewberry@nvidia.com> * fix(ci): collect local packit rpm artifacts Signed-off-by: Drew Newberry <anewberry@nvidia.com> --------- Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent f17806c commit 6ce988d

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

.github/workflows/rpm-package.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,16 @@ jobs:
5959
run: |
6060
set -euo pipefail
6161
mkdir -p artifacts
62-
find ~/rpmbuild/RPMS/ -name '*.rpm' -exec cp {} artifacts/ \;
62+
for rpm_dir in "$HOME/rpmbuild/RPMS" "$PWD/${{ matrix.arch }}"; do
63+
if [ -d "$rpm_dir" ]; then
64+
find "$rpm_dir" -type f -name '*.rpm' -exec cp {} artifacts/ \;
65+
fi
66+
done
67+
if ! compgen -G 'artifacts/*.rpm' > /dev/null; then
68+
echo "::error::No RPM artifacts found"
69+
find "$PWD" -maxdepth 3 -type f -name '*.rpm' -print
70+
exit 1
71+
fi
6372
echo "=== Built RPMs ==="
6473
ls -lah artifacts/
6574

.packit.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,21 @@ srpm_build_deps:
1717

1818
actions:
1919
get-current-version:
20-
# Derive version from the latest upstream tag on the current branch.
21-
- 'bash -c "git describe --tags --match ''v*'' --abbrev=0 HEAD | sed ''s/^v//''"'
20+
# Derive version from the latest SemVer upstream tag on the current branch.
21+
# Avoid operational tags such as vm-dev; Packit normalizes that to m.dev,
22+
# which is not a valid Cargo package version.
23+
- 'bash -c "git describe --tags --match ''v[0-9]*.[0-9]*.[0-9]*'' --abbrev=0 HEAD | sed ''s/^v//''"'
2224

2325
create-archive:
2426
# Step 1: Create source tarball from git working tree.
2527
# Uses git ls-files + tar instead of git archive so the tarball
2628
# reflects any patching that Packit may have done (e.g. version bumps).
2729
- 'bash -c "VERSION=${PACKIT_PROJECT_VERSION} && TMPDIR=$(mktemp -d) && DIR=openshell-${VERSION} && mkdir -p ${TMPDIR}/${DIR} && git ls-files -z | xargs -0 tar cf - | tar xf - -C ${TMPDIR}/${DIR}/ && tar -czf openshell-${VERSION}.tar.gz -C ${TMPDIR} ${DIR} && rm -rf ${TMPDIR}"'
2830
# Step 2: Create vendored Cargo dependencies tarball for offline RPM build.
29-
- 'bash -c "VERSION=${PACKIT_PROJECT_VERSION} && cargo vendor --quiet && tar -cJf openshell-${VERSION}-vendor.tar.xz vendor/ && rm -rf vendor/"'
30-
# Step 3: Return BOTH archive names. Packit maps each line to Source0, Source1, etc.
31-
- 'bash -c "echo openshell-${PACKIT_PROJECT_VERSION}.tar.gz && echo openshell-${PACKIT_PROJECT_VERSION}-vendor.tar.xz"'
31+
- 'bash -c "VERSION=${PACKIT_PROJECT_VERSION} && CARGO_HTTP_TIMEOUT=600 CARGO_NET_RETRY=5 cargo vendor --locked --quiet && tar -cJf openshell-${VERSION}-vendor.tar.xz vendor/ && rm -rf vendor/"'
32+
# Step 3: Return the primary archive name. Packit expects create-archive
33+
# to print one path for Source0; Source1 is patched explicitly below.
34+
- 'bash -c "echo openshell-${PACKIT_PROJECT_VERSION}.tar.gz"'
3235

3336
fix-spec-file:
3437
# Update Source0 to the generated tarball name

0 commit comments

Comments
 (0)