Files
OpenShell/.packit.yaml
Adam Miller 5bf22fd69a feat(rpm): use :dev image tag for non-release Packit builds (#1218)
* feat(rpm): use :dev image tag for non-release builds

Add a %global image_tag macro to the spec file (default: dev) that
controls the container image tag baked into RPM-built binaries and
the installed systemd unit.

Packit's fix-spec-file action detects tagged stable releases via
git describe --exact-match and overrides the macro to 'latest'.
PR and commit-to-main builds keep the 'dev' default, matching the
:dev images pushed by release-dev.yml.

The init-gateway-env.sh installed copy is also patched at RPM build
time so its commented image defaults stay consistent with the tag
the RPM actually expects from the registry.

Signed-off-by: Adam Miller <admiller@redhat.com>

* fix(rpm): scope image_tag to supervisor only; sandbox base stays latest

The community sandbox base image (ghcr.io/nvidia/openshell-community/
sandboxes/base) does not publish :dev tags -- only :latest and version-
pinned tags are available. Applying %{image_tag} to it caused a
manifest unknown error when pulling the image on non-release builds.

Scope the dynamic tag to the supervisor image only, which is part of
the core OpenShell release pipeline and does receive :dev tags from
release-dev.yml. The sandbox base image unconditionally uses :latest.

Also tighten the sed in %install to target only the supervisor image
line in init-gateway-env.sh rather than blanket-replacing all :latest
occurrences.

Signed-off-by: Adam Miller <admiller@redhat.com>

* fix(rpm): restore %%{openshell_python_version} in Python dist-info METADATA

The Version field inside the METADATA heredoc was hardcoded to 0.0.37
instead of using the %%{openshell_python_version} macro. This caused
the installed Python dist-info to always report the wrong version on
non-release builds.

Signed-off-by: Adam Miller <admiller@redhat.com>

---------

Signed-off-by: Adam Miller <admiller@redhat.com>
2026-05-07 11:45:03 -05:00

90 lines
4.3 KiB
YAML

# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# Packit configuration for OpenShell RPM builds via Fedora COPR.
# See https://packit.dev/docs/configuration for full reference.
upstream_tag_template: "v{version}"
upstream_package_name: openshell
downstream_package_name: openshell
specfile_path: openshell.spec
# Packages needed in the SRPM build environment to create vendor tarball
srpm_build_deps:
- rust
- cargo
- git-core
actions:
get-current-version:
# Release workflows pass OPENSHELL_RPM_VERSION so every artifact shares one
# precomputed identity. Local Packit runs fall back to the latest SemVer
# upstream tag, avoiding operational tags such as vm-dev; Packit normalizes
# those to invalid Cargo package versions such as m.dev.
- 'bash -c "if [ -n \"${OPENSHELL_RPM_VERSION:-}\" ]; then echo \"${OPENSHELL_RPM_VERSION}\"; else git describe --tags --match ''v[0-9]*.[0-9]*.[0-9]*'' --abbrev=0 HEAD | sed ''s/^v//''; fi"'
create-archive:
# Step 1: Create source tarball from git working tree.
# Uses git ls-files + tar instead of git archive so the tarball
# reflects any patching that Packit may have done (e.g. version bumps).
- '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}"'
# Step 2: Create vendored Cargo dependencies tarball for offline RPM build.
- '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/"'
# Step 3: Return the primary archive name. Packit expects create-archive
# to print one path for Source0; Source1 is patched explicitly below.
- 'bash -c "echo openshell-${PACKIT_PROJECT_VERSION}.tar.gz"'
fix-spec-file:
# Update Source0 to the generated tarball name
- 'bash -c "sed -i \"s|^Source0:.*|Source0: openshell-${PACKIT_PROJECT_VERSION}.tar.gz|\" openshell.spec"'
# Update Source1 to the generated vendor tarball name
- 'bash -c "sed -i \"s|^Source1:.*|Source1: openshell-${PACKIT_PROJECT_VERSION}-vendor.tar.xz|\" openshell.spec"'
# Update Version
- 'bash -c "sed -i -r \"s/^Version:(\\s*)\\S+/Version:\\1${PACKIT_RPMSPEC_VERSION}/\" openshell.spec"'
# Update Release
- 'bash -c "RELEASE=${OPENSHELL_RPM_RELEASE:-${PACKIT_RPMSPEC_RELEASE}} && sed -i -r \"s/^Release:(\\s*)\\S+/Release:\\1${RELEASE}%{?dist}/\" openshell.spec"'
# Keep embedded binary metadata aligned with the release workflow. Python
# dist-info stays at the RPM Version; dev build identity is carried by
# Release so Fedora's Python RPM post-processing can normalize metadata.
- 'bash -c "if [ -n \"${OPENSHELL_CARGO_VERSION:-}\" ]; then sed -i -r \"s/^%global openshell_cargo_version .*/%global openshell_cargo_version ${OPENSHELL_CARGO_VERSION}/\" openshell.spec; fi"'
# Override image_tag to 'latest' for tagged stable releases.
# For PR and commit-to-main builds the spec default ('dev') is kept,
# matching the :dev images pushed by release-dev.yml.
- 'bash -c "if git describe --exact-match --tags HEAD 2>/dev/null | grep -qE ''^v[0-9]+\.[0-9]+\.[0-9]+$''; then sed -i ''s/^%global image_tag.*/%global image_tag latest/'' openshell.spec; fi"'
jobs:
# Build on every pull request targeting main for CI validation
- job: copr_build
trigger: pull_request
branch: main
identifier: main-pr
targets:
- fedora-all
- epel-10
# Build into maxamillion/openshell on every commit to main
# for continuous development and testing builds.
- job: copr_build
trigger: commit
branch: main
owner: "maxamillion"
project: "openshell"
identifier: main-commit
targets:
- fedora-all
- epel-10
preserve_project: true
list_on_homepage: true
# Build on GitHub releases for publishable RPMs.
# See: https://packit.dev/docs/configuration/upstream/copr_build#using-a-custom-copr-project
- job: copr_build
trigger: release
owner: "maxamillion"
project: "openshell"
targets:
- fedora-all
- epel-10
preserve_project: true
list_on_homepage: true