Skip to content
Closed

COPR #107

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions .github/actions/build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ inputs:
- all
- rpms
- bootc-image
rpm-builder:
type: string
description: RPM builder image to use
required: false
default: rpm-local-builder

runs:
using: "composite"
Expand All @@ -56,9 +61,12 @@ runs:
uses: ./.github/actions/debug-info

- name: Prepare the build and run environment
# Skip if the rpm-builder is overridden - release.yaml builds RPMs using COPR.
if: inputs.rpm-builder == 'rpm-local-builder'
uses: ./.github/actions/prebuild

- name: Build MicroShift RPMs
if: inputs.rpm-builder == 'rpm-local-builder'
shell: bash
run: |
# See https://github.com/microshift-io/microshift/blob/main/docs/build.md
Expand Down Expand Up @@ -89,6 +97,7 @@ runs:
make image \
BOOTC_IMAGE_URL=${{ inputs.bootc-image-url }} \
BOOTC_IMAGE_TAG=${{ inputs.bootc-image-tag }} \
BUILDER_IMAGE=${{ inputs.rpm-builder }} \
${make_opts[@]}

- name: Run a test to verify that MicroShift is functioning properly
Expand Down Expand Up @@ -143,17 +152,21 @@ runs:
set -euo pipefail
set -x

# Check if the MicroShift container is running
if ! sudo podman ps --format "{{.Names}}" | grep -q '^microshift-okd$' ; then
echo "WARNING: MicroShift container is not running - cannot collect sos report"
exit 0
fi
sudo podman ps --all

# Collect sos report from the MicroShift container
sudo podman exec -i microshift-okd microshift-sos-report
for f in $(sudo podman exec -i microshift-okd bash -c 'ls -1 /tmp/sosreport-*'); do
sudo podman cp microshift-okd:${f} /mnt/tmp/
sudo chmod 644 "/mnt/tmp/$(basename "${f}")"
for i in $(seq 1 ${{ inputs.node-count }}); do
# Check if the MicroShift container is running
if ! sudo podman ps --format "{{.Names}}" | grep -q "^microshift-okd-${i}$" ; then
echo "WARNING: MicroShift container number ${i} is not running - cannot collect sos report"
exit 0
fi

# Collect sos report from the MicroShift container
sudo podman exec -i "microshift-okd-${i}" microshift-sos-report
for f in $(sudo podman exec -i "microshift-okd-${i}" bash -c 'ls -1 /tmp/sosreport-*'); do
sudo podman cp "microshift-okd-${i}":${f} /mnt/tmp/
sudo chmod 644 "/mnt/tmp/$(basename "${f}")"
done
done

- name: Upload sos report to the GitHub Actions artifact
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/builders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
ushift-branch: main
okd-version-tag: ${{ steps.detect-okd-version.outputs.okd-version-tag }}
bootc-image-url: registry.fedoraproject.org/fedora-bootc
bootc-image-tag: latest
bootc-image-tag: 42
build: bootc-image
node-count: 2

Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,32 @@

#### RPM

Review the instructions in [MicroShift RPMs](https://github.com/microshift-io/microshift/blob/main/docs/run.md#microshift-rpms) to install the packages and run MicroShift.
Enable COPR repository (optionally specify chroot such as `centos-stream-9-{x86_64,aarch64}`, `fedora-42-{x86_64,aarch64}`):
```sh
sudo dnf copr enable $COPR_REPO_NAME [chroot]
```

Next, install MicroShift:
```sh
sudo dnf install -y \
microshift-$VERSION \
microshift-kindnet-$VERSION \
microshift-topolvm-$VERSION
```
Comment on lines +5 to +16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clarify where $VERSION and $COPR_REPO_NAME variables are defined.

The documentation uses $VERSION and $COPR_REPO_NAME variables without explaining where they come from or how users should set them. Consider adding a note at the beginning explaining these are placeholders that should be replaced with actual values (e.g., export VERSION=4.18.0 and export COPR_REPO_NAME=microshift-io/microshift).

🤖 Prompt for AI Agents
In .github/workflows/release.md around lines 5 to 16, the instructions use the
placeholders $VERSION and $COPR_REPO_NAME without defining them; update the doc
to state these are user-defined environment variables and show how to set them
before running the commands (for example, indicate users should export VERSION
and COPR_REPO_NAME with the desired values or replace the placeholders inline),
and add a brief example line or sentence near the top of this section that
demonstrates setting these variables (e.g., export VERSION=4.18.0; export
COPR_REPO_NAME=microshift-io/microshift) so readers know where the values come
from.


Review the instructions in [MicroShift RPMs](https://github.com/microshift-io/microshift/blob/main/docs/run.md#microshift-rpms) to run MicroShift.

#### Bootc Image

Load the Bootc container image using the following command:

```bash
sudo podman pull ghcr.io/microshift-io/microshift:$TAG
sudo podman pull ghcr.io/microshift-io/microshift:$VERSION
```

Or use the image with the `quickstart.sh`:
```bash
curl -s https://microshift-io.github.io/microshift/quickstart.sh | sudo TAG=$TAG bash
curl -s https://microshift-io.github.io/microshift/quickstart.sh | sudo TAG=$VERSION bash
```

Review the instructions in [MicroShift Bootc Image](https://github.com/microshift-io/microshift/blob/main/docs/run.md#microshift-bootc-image) to run the image.
100 changes: 54 additions & 46 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@ on:
description: MicroShift branch from https://github.com/openshift/microshift/branches
type: string
okd-version-tag:
default: "4.19.0-okd-scos.19"
default: "4.21.0-okd-scos.ec.5"
description: OKD version tag from https://quay.io/repository/okd/scos-release?tab=tags
type: string
build:
type: choice
description: Types of artifacts to build
default: all
options:
- all
- rpms
- bootc-image
copr-repo:
default: pmtk0/test123
description: COPR repository name
type: string
Comment on lines +15 to +18
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Don't default to a personal COPR repo.

Leaving copr-repo defaulted to pmtk0/test123 means anyone running the release workflow without overriding the input will publish the RPMs into that test project. Please drop the default (or point it at the official MicroShift COPR namespace) so releases can't accidentally land in the wrong repo.

🤖 Prompt for AI Agents
In .github/workflows/release.yaml around lines 15 to 18, the workflow input
`copr-repo` is defaulting to a personal COPR repo (`pmtk0/test123`); remove that
default value (or replace it with the official MicroShift COPR namespace such as
`openshift/microshift`) so running the workflow without an explicit input cannot
publish to a personal test project; keep the input name, description and type,
and update any documentation/comments to note that callers must supply the
intended COPR repo when invoking the workflow.


jobs:
build:
Expand All @@ -34,47 +30,56 @@ jobs:
- name: Check out MicroShift upstream repository
uses: actions/checkout@v4

- name: Run the build action
- name: Prepare the build and run environment
uses: ./.github/actions/prebuild

- name: Build MicroShift RPMs
shell: bash
env:
COPR_TOKEN: |
${{ secrets.COPR_TOKEN }}
run: |
cd ${GITHUB_WORKSPACE}/
echo "${COPR_TOKEN}" > /tmp/copr-token
make copr-rpm \
USHIFT_BRANCH=${{ inputs.ushift-branch }} \
OKD_VERSION_TAG=${{ inputs.okd-version-tag }} \
RPM_OUTDIR=/mnt/rpms \
COPR_CONFIG=/tmp/copr-token \
COPR_REPO_NAME="${{ inputs.copr-repo }}"

- name: Build and test bootc image
uses: ./.github/actions/build
with:
ushift-branch: ${{ inputs.ushift-branch }}
okd-version-tag: ${{ inputs.okd-version-tag }}
build: ${{ inputs.build }}

# Test the local container image with the quick start and clean procedures
# before releasing the artifacts.
- name: Run the quick start script and clean scripts
if: contains(fromJSON('["all", "bootc-image"]'), inputs.build)
uses: ./.github/actions/quick-start-clean
with:
image-ref: localhost/microshift-okd:latest
build: bootc-image
rpm-builder: rpm-copr-builder

# The release process consumes the RPMs and the container image
# prepared by the build action.
- name: Prepare the RPM archives
if: contains(fromJSON('["all", "rpms"]'), inputs.build)
- name: COPR - Delete builds
if: failure()
shell: bash
env:
COPR_TOKEN: |
${{ secrets.COPR_TOKEN }}
run : |
# Archive sources separately from the RPMs
sudo mv /mnt/rpms/srpms /mnt/srpms
cd /mnt/srpms
sudo tar zcvf /mnt/release/microshift-src.tgz .

cd /mnt/rpms
sudo tar zcvf /mnt/release/microshift-rpms-$(uname -m).tgz .
echo "${COPR_TOKEN}" > /tmp/copr-token
make copr-delete-builds \
COPR_CONFIG=/tmp/copr-token \
COPR_BUILDS="$(cat /mnt/rpms/builds.txt)"

- name: Release RPMs
if: contains(fromJSON('["all", "rpms"]'), inputs.build)
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.ushift-branch }}-${{ inputs.okd-version-tag }}
files: |
/mnt/release/microshift-rpms-*.tgz
/mnt/release/microshift-src.tgz
overwrite_files: true
- name: COPR - Regenerate RPM repo
shell: bash
env:
COPR_TOKEN: |
${{ secrets.COPR_TOKEN }}
run : |
echo "${COPR_TOKEN}" > /tmp/copr-token
make copr-regenerate-repos \
COPR_CONFIG=/tmp/copr-token \
COPR_REPO_NAME="${{ inputs.copr-repo }}"

- name: Login to GitHub Container Registry
if: contains(fromJSON('["all", "bootc-image"]'), inputs.build)
uses: redhat-actions/podman-login@v1
with:
registry: ghcr.io/${{ github.repository_owner }}
Expand All @@ -83,21 +88,24 @@ jobs:
auth_file_path: /tmp/ghcr-auth.json

- name: Publish Bootc image
if: contains(fromJSON('["all", "bootc-image"]'), inputs.build)
id: publish-bootc-image
shell: bash
run: |
VERSION="$(cat /mnt/rpms/version.txt)"
sudo podman tag microshift-okd \
ghcr.io/${{ github.repository }}:${{ inputs.ushift-branch }}-${{ inputs.okd-version-tag }} \
ghcr.io/${{ github.repository }}:${VERSION} \
ghcr.io/${{ github.repository }}:latest
sudo podman push --authfile /tmp/ghcr-auth.json ghcr.io/${{ github.repository }}:${{ inputs.ushift-branch }}-${{ inputs.okd-version-tag }}
sudo podman push --authfile /tmp/ghcr-auth.json ghcr.io/${{ github.repository }}:${VERSION}
sudo podman push --authfile /tmp/ghcr-auth.json ghcr.io/${{ github.repository }}:latest

# Prepare the release note for the bootc image usage
TAG=${{ inputs.ushift-branch }}-${{ inputs.okd-version-tag }} envsubst < .github/workflows/release.md > /tmp/release.md
VERSION="${VERSION}" \
COPR_REPO_NAME="${{ inputs.copr-repo }}" \
envsubst < .github/workflows/release.md > /tmp/release.md
echo "version=${VERSION}" >> $GITHUB_OUTPUT

- name: Add release note for bootc image usage
if: contains(fromJSON('["all", "bootc-image"]'), inputs.build)
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.ushift-branch }}-${{ inputs.okd-version-tag }}
tag_name: ${{ steps.publish-bootc-image.outputs.version }}
body_path: /tmp/release.md
24 changes: 18 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ ISOLATED_NETWORK ?= 0

# Internal variables
SHELL := /bin/bash
BUILDER_IMAGE := microshift-okd-builder
BUILDER_IMAGE ?= rpm-local-builder
USHIFT_IMAGE := microshift-okd
LVM_DISK := /var/lib/microshift-okd/lvmdisk.image
VG_NAME := myvg1

PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
include $(PROJECT_DIR)/src/copr/copr.mk

#
# Define the main targets
#
Expand All @@ -47,16 +50,23 @@ all:
@echo " run-status: show the status of the MicroShift cluster"
@echo " clean-all: perform a full cleanup, including the container images"
@echo ""
@echo "COPR related targets:"
@echo " copr-rpm: build the MicroShift RPMs using COPR build service"
@echo " copr-delete-builds: delete the COPR builds using the COPR_BUILDS environment variable"
@echo " copr-regenerate-repos: regenerate the COPR repository"
@echo " copr-cfg-ensure-podman-secret: create podman secret from COPR_CONFIG"
@echo " copr-cli: build the COPR CLI container image used by copr-delete-builds and copr-regenerate-repos"
@echo ""

.PHONY: rpm
rpm:
@echo "Building the MicroShift builder image"
@echo "Building the MicroShift RPMs"
sudo podman build \
-t "${BUILDER_IMAGE}" \
--ulimit nofile=524288:524288 \
--build-arg USHIFT_BRANCH="${USHIFT_BRANCH}" \
--build-arg OKD_VERSION_TAG="${OKD_VERSION_TAG}" \
-f packaging/microshift-builder.Containerfile .
-f packaging/rpm-local-builder.Containerfile .

@echo "Extracting the MicroShift RPMs"
outdir="$${RPM_OUTDIR:-$$(mktemp -d /tmp/microshift-rpms-XXXXXX)}" && \
Expand All @@ -80,8 +90,8 @@ rpm-to-deb:

.PHONY: image
image:
@if ! sudo podman image exists microshift-okd-builder ; then \
echo "ERROR: Run 'make rpm' to build the MicroShift RPMs" ; \
@if ! sudo podman image exists "${BUILDER_IMAGE}" ; then \
echo "ERROR: Run 'make rpm' or 'make copr-rpm' to build the MicroShift RPMs" ; \
exit 1 ; \
fi

Expand All @@ -93,11 +103,12 @@ image:
--label okd.version="${OKD_VERSION_TAG}" \
--build-arg BOOTC_IMAGE_URL="${BOOTC_IMAGE_URL}" \
--build-arg BOOTC_IMAGE_TAG="${BOOTC_IMAGE_TAG}" \
--build-arg RPM_BUILDER_IMAGE="${BUILDER_IMAGE}" \
--env WITH_KINDNET="${WITH_KINDNET}" \
--env WITH_TOPOLVM="${WITH_TOPOLVM}" \
--env WITH_OLM="${WITH_OLM}" \
--env EMBED_CONTAINER_IMAGES="${EMBED_CONTAINER_IMAGES}" \
-f packaging/microshift-runner.Containerfile .
-f packaging/bootc.Containerfile .

# Notes:
# - An isolated network is created if the ISOLATED_NETWORK environment variable is set
Expand Down Expand Up @@ -157,6 +168,7 @@ clean-all:
$(MAKE) clean
sudo podman rmi -f "${USHIFT_IMAGE}" || true
sudo podman rmi -f "${BUILDER_IMAGE}" || true
sudo podman rmi -f "${COPR_BUILDER_IMAGE}" || true

.PHONY: check
check: _hadolint _shellcheck
Expand Down
Loading