Skip to content
Merged
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
137 changes: 54 additions & 83 deletions .github/workflows/PRBuild.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Copyright © 2025 OpenCHAMI a Series of LF Projects, LLC
#
# Copyright © 2026 OpenCHAMI a Series of LF Projects, LLC
# SPDX-License-Identifier: MIT

name: Build each PR for testing and validation

on:
pull_request:
branches:
Expand All @@ -17,91 +15,64 @@ on:
type: string

permissions: write-all # Necessary for the generate-build-provenance action with containers

jobs:

build:


config:
runs-on: ubuntu-latest

outputs:
rpm-unsigned: ${{ steps.names.outputs.rpm-unsigned }}
rpm-signed: ${{ steps.names.outputs.rpm-signed }}
keys-public: ${{ steps.names.outputs.keys-public }}
steps:
- name: Set up latest stable Go
uses: actions/setup-go@v6.4.0
with:
go-version: stable
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:master
network=host
- name: Docker Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v6.0.2
with:
fetch-tags: 1
fetch-depth: 0
# Set environment variables required by GoReleaser
- name: Set build environment variables
- id: names
run: |
echo "GIT_STATE=$(if git diff-index --quiet HEAD --; then echo 'clean'; else echo 'dirty'; fi)" >> $GITHUB_ENV
echo "BUILD_HOST=$(hostname)" >> $GITHUB_ENV
echo "GO_VERSION=$(go version | awk '{print $3}')" >> $GITHUB_ENV
echo "BUILD_USER=$(whoami)" >> $GITHUB_ENV
echo "CGO_ENABLED=0" >> $GITHUB_ENV
echo "IS_PR_BUILD=true" >> $GITHUB_ENV
{
echo "rpm-unsigned=rpms-unsigned"
echo "rpm-signed=rpms-signed"
echo "keys-public=public-keys"
} >> "$GITHUB_OUTPUT"

- name: Docker Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
build:
uses: OpenCHAMI/github-actions/.github/workflows/build-publish-container-goreleaser.yml@v3.7
secrets: inherit
with:
cgo_enabled: 0
go_version_file: go.mod
registry_subject_name: ghcr.io/openchami/metadata-service
is_pr_build: true
pr_number: ${{ inputs.pr_number || github.event.pull_request.number || 0 }}

- name: Create Tag for PR
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.pr_number != '')
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
PR_NUM="${{ github.event.number }}"
if [[ "${{ inputs.pr_number }}" != "" ]]; then
PR_NUM="${{ inputs.pr_number }}"
fi
git tag -f -a pr-${PR_NUM} -m "PR Release"
rpmbuild:
needs: [config, build]
uses: OpenCHAMI/github-actions/.github/workflows/build-rpm-quadlet.yml@v3.7
secrets: inherit
with:
artifact-name-unsigned-rpms: ${{ needs.config.outputs.rpm-unsigned }}

- name: Build/Push container with goreleaser
uses: goreleaser/goreleaser-action@v6
env:
GITHUB_TOKEN: ${{ github.token }}
with:
version: '~> 2'
args: release --clean --skip=announce,validate,archive
id: goreleaser
- name: Process goreleaser output
id: process_goreleaser_output
run: |
echo "const fs = require('fs');" > process.js
echo 'const artifacts = ${{ steps.goreleaser.outputs.artifacts }}' >> process.js
echo "const firstNonNullDigest = artifacts.find(artifact => artifact.extra && artifact.extra.Digest != null)?.extra.Digest;" >> process.js
echo "console.log(firstNonNullDigest);" >> process.js
echo "fs.writeFileSync('digest.txt', firstNonNullDigest);" >> process.js
node process.js
echo "digest=$(cat digest.txt)" >> $GITHUB_OUTPUT
- name: Attest Binaries
uses: actions/attest-build-provenance@v4.1.0
with:
subject-path: dist/**
- name: generate build provenance
uses: actions/attest-build-provenance@v4.1.0
with:
subject-name: ghcr.io/openchami/metadata-service
subject-digest: ${{ steps.process_goreleaser_output.outputs.digest }}
push-to-registry: true
rpmsign:
needs: [config, rpmbuild]
uses: OpenCHAMI/github-actions/.github/workflows/gpg-sign-artifacts.yml@v3.7
secrets: inherit
with:
artifact-name-unsigned-rpms: ${{ needs.config.outputs.rpm-unsigned }}
artifact-name-signed-rpms: ${{ needs.config.outputs.rpm-signed }}
artifact-name-public-keys: ${{ needs.config.outputs.keys-public }}

rpmvalidate:
needs: [config, rpmsign]
uses: OpenCHAMI/github-actions/.github/workflows/validate-rpm-quadlet.yml@v3.7
secrets: inherit
with:
artifact-name-signed-rpms: ${{ needs.config.outputs.rpm-signed }}
rpms: |
- name: metadata-service-*.rpm
files:
- /etc/openchami
- /etc/openchami/configs
- /etc/openchami/configs/metadata-service.yaml
- /usr/share/containers/systemd/metadata-service-data.volume
- /usr/share/containers/systemd/metadata-service.container
- /usr/share/containers/systemd/metadata-service.container.d
- /usr/share/containers/systemd/metadata-service.container.d/10-defaults.conf
- /usr/share/licenses/metadata-service-quadlet
- /usr/share/licenses/metadata-service-quadlet/MIT.txt
112 changes: 45 additions & 67 deletions .github/workflows/Release.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Copyright © 2025 OpenCHAMI a Series of LF Projects, LLC
#
# Copyright © 2026 OpenCHAMI a Series of LF Projects, LLC
# SPDX-License-Identifier: MIT

name: Release with goreleaser

name: Release
on:
workflow_dispatch:
push:
Expand All @@ -14,70 +12,50 @@ permissions: write-all # Necessary for the generate-build-provenance action with

jobs:

build:


config:
runs-on: ubuntu-latest

outputs:
rpm-unsigned: ${{ steps.names.outputs.rpm-unsigned }}
rpm-signed: ${{ steps.names.outputs.rpm-signed }}
keys-public: ${{ steps.names.outputs.keys-public }}
steps:
- name: Set up latest stable Go
uses: actions/setup-go@v6.4.0
with:
go-version: stable
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:master
network=host
- name: Docker Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v6.0.2
with:
fetch-tags: 1
fetch-depth: 0
# Set environment variables required by GoReleaser
- name: Set build environment variables
- id: names
run: |
echo "GIT_STATE=$(if git diff-index --quiet HEAD --; then echo 'clean'; else echo 'dirty'; fi)" >> $GITHUB_ENV
echo "BUILD_HOST=$(hostname)" >> $GITHUB_ENV
echo "GO_VERSION=$(go version | awk '{print $3}')" >> $GITHUB_ENV
echo "BUILD_USER=$(whoami)" >> $GITHUB_ENV
echo "CGO_ENABLED=0" >> $GITHUB_ENV
echo "IS_PR_BUILD=false" >> $GITHUB_ENV
{
echo "rpm-unsigned=rpms-unsigned"
echo "rpm-signed=rpms-signed"
echo "keys-public=gpg-public-keys"
} >> "$GITHUB_OUTPUT"

- name: Release with goreleaser
uses: goreleaser/goreleaser-action@v6
env:
GITHUB_TOKEN: ${{ github.token }}
with:
version: latest
args: release --clean
id: goreleaser
- name: Process goreleaser output
id: process_goreleaser_output
run: |
echo "const fs = require('fs');" > process.js
echo 'const artifacts = ${{ steps.goreleaser.outputs.artifacts }}' >> process.js
echo "const firstNonNullDigest = artifacts.find(artifact => artifact.extra && artifact.extra.Digest != null)?.extra.Digest;" >> process.js
echo "console.log(firstNonNullDigest);" >> process.js
echo "fs.writeFileSync('digest.txt', firstNonNullDigest);" >> process.js
node process.js
echo "digest=$(cat digest.txt)" >> $GITHUB_OUTPUT
- name: Attest Binaries
uses: actions/attest-build-provenance@v1
with:
subject-path: dist/**
- name: generate build provenance
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/openchami/metadata-service
subject-digest: ${{ steps.process_goreleaser_output.outputs.digest }}
push-to-registry: true
build:
uses: OpenCHAMI/github-actions/.github/workflows/build-publish-container-goreleaser.yml@v3.7
secrets: inherit
with:
cgo_enabled: 0
go_version_file: go.mod
is_pr_build: false
registry_subject_name: ghcr.io/openchami/metadata-service

rpmbuild:
needs: [config, build]
uses: OpenCHAMI/github-actions/.github/workflows/build-rpm-quadlet.yml@v3.7
secrets: inherit
with:
artifact-name-unsigned-rpms: ${{ needs.config.outputs.rpm-unsigned }}

rpmsign:
needs: [config, rpmbuild]
uses: OpenCHAMI/github-actions/.github/workflows/gpg-sign-artifacts.yml@v3.7
secrets: inherit
with:
artifact-name-unsigned-rpms: ${{ needs.config.outputs.rpm-unsigned }}
artifact-name-signed-rpms: ${{ needs.config.outputs.rpm-signed }}
artifact-name-public-keys: ${{ needs.config.outputs.keys-public }}

release:
needs: [config, rpmsign]
uses: OpenCHAMI/github-actions/.github/workflows/release-signed-artifacts.yml@v3.7
secrets: inherit
with:
artifact-name-signed-rpms: ${{ needs.config.outputs.rpm-signed }}
artifact-name-public-keys: ${{ needs.config.outputs.keys-public }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ dist/
# Runtime config (contains environment-specific values)
config.yaml
config.yml
!packaging/**/configs/*
!config.example.yaml
Comment thread
synackd marked this conversation as resolved.

# IDE files
.vscode/
Expand All @@ -49,4 +51,4 @@ config.yml
*~

# Graphify Cache
graphify-out/cache/
graphify-out/cache/
27 changes: 26 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# SPDX-License-Identifier: MIT

.PHONY: help build test lint clean install run container-build container-run generate generate-check dev
.PHONY: help build test lint clean install run container-build container-run generate generate-check dev rpm-build rpm-clean

# Variables
BINARY_NAME=metadata-service
Expand All @@ -15,6 +15,13 @@ DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
CONTAINER_PROG ?= $(shell command -v docker 2>/dev/null)
CONTAINER_TAG ?= latest
CONTAINER_GO_VERSION ?= $(shell awk '/^go / {print $$2; exit}' go.mod)
# RPM version/release: strip the leading 'v' and drop git-describe's
# '-N-gHASH[-dirty]' suffix (hyphens aren't allowed in an RPM Version
# field anyway). An exact tag like v0.1.2 becomes 0.1.2.
RPM_VERSION ?= $(shell echo "$(VERSION)" | sed -e 's/^v//' -e 's/-.*//')
RPM_RELEASE ?= 1
RPM_TOPDIR ?= $(CURDIR)/dist/rpmbuild
RPM_NAME ?= metadata-service-quadlet
LDFLAGS=-ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"
FABRICA_CMD ?= go run github.com/openchami/fabrica/cmd/fabrica@latest
FABRICA_SOURCE_ARG ?=
Expand Down Expand Up @@ -102,6 +109,24 @@ container-run: container-build ## Build and run Docker container
release-snapshot: ## Create a snapshot release with GoReleaser
goreleaser release --snapshot --clean

rpm-build: ## Build the metadata-service RPM (VERSION/RPM_RELEASE override the derived defaults)
@command -v rpmbuild >/dev/null 2>&1 || { echo "rpmbuild is required but not installed."; exit 1; }
rm -rf $(RPM_TOPDIR)
mkdir -p $(RPM_TOPDIR)/SOURCES/$(RPM_NAME)-$(RPM_VERSION)/LICENSES
cp -rL packaging/rpm-quadlet/systemd/* $(RPM_TOPDIR)/SOURCES/$(RPM_NAME)-$(RPM_VERSION)/
cp -rL packaging/rpm-quadlet/configs/* $(RPM_TOPDIR)/SOURCES/$(RPM_NAME)-$(RPM_VERSION)/
cp LICENSES/MIT.txt $(RPM_TOPDIR)/SOURCES/$(RPM_NAME)-$(RPM_VERSION)/LICENSES/
tar -C $(RPM_TOPDIR)/SOURCES -czf $(RPM_TOPDIR)/SOURCES/$(RPM_NAME)-$(RPM_VERSION).tar.gz \
$(RPM_NAME)-$(RPM_VERSION)
rpmbuild --define "_topdir $(RPM_TOPDIR)" \
--define "version $(RPM_VERSION)" \
--define "rel $(RPM_RELEASE)" \
-bb packaging/rpm-quadlet/$(RPM_NAME).spec
@echo "Built: $(RPM_TOPDIR)/RPMS/noarch/$$(ls $(RPM_TOPDIR)/RPMS/noarch)"

rpm-clean: ## Remove local RPM build artifacts
rm -rf $(RPM_TOPDIR)

fmt: ## Format code
$(GO) fmt ./...
goimports -w .
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Key capabilities

The server defaults to port `8080`. The examples below use `8888` explicitly.

Flags used below can also be set in a config file (`--config`, default `/etc/metadata-service/config.yaml`) or via `METADATA_SERVICE_*` environment variables; see [`config.example.yaml`](config.example.yaml) for every option and its default.

1. Start the server with the built-in mock SMD data:

```bash
Expand Down
Loading
Loading