Skip to content

v0.2.0

v0.2.0 #1

Workflow file for this run

name: OperatorHub Submission
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g. v0.1.0)'
required: true
jobs:
submit:
name: Submit to OperatorHub
runs-on: ubuntu-latest
steps:
- name: Resolve tag
id: version
run: |
TAG="${{ github.event.inputs.tag || github.ref_name }}"
VERSION="${TAG#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ steps.version.outputs.tag }}
- name: Prepare bundle
run: |
VERSION="${{ steps.version.outputs.version }}"
TAG="${{ steps.version.outputs.tag }}"
BUNDLE_DIR="submission/operators/paperclip-operator/${VERSION}"
mkdir -p "${BUNDLE_DIR}/manifests" "${BUNDLE_DIR}/metadata"
# Copy and version the CSV
sed \
-e "s/paperclip-operator\.v[0-9]\+\.[0-9]\+\.[0-9]\+/paperclip-operator.v${VERSION}/g" \
-e "s|ghcr.io/paperclipinc/paperclip-operator:v[0-9]\+\.[0-9]\+\.[0-9]\+|ghcr.io/paperclipinc/paperclip-operator:${TAG}|g" \
-e "s/createdAt: .*/createdAt: \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"/" \
-e "s/^ version: [0-9]\+\.[0-9]\+\.[0-9]\+/ version: ${VERSION}/" \
bundle/manifests/paperclip-operator.v*.clusterserviceversion.yaml \
> "${BUNDLE_DIR}/manifests/paperclip-operator.v${VERSION}.clusterserviceversion.yaml"
# Copy CRD and metadata as-is
cp bundle/manifests/paperclip.inc_instances.yaml "${BUNDLE_DIR}/manifests/" 2>/dev/null || \
cp config/crd/bases/paperclip.inc_instances.yaml "${BUNDLE_DIR}/manifests/"
cp bundle/metadata/annotations.yaml "${BUNDLE_DIR}/metadata/"
echo "Bundle prepared at ${BUNDLE_DIR}:"
find "${BUNDLE_DIR}" -type f
- name: Fork and submit to community-operators
env:
GH_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
BRANCH="paperclip-operator-v${VERSION}"
# Configure gh as git credential helper so git push works with the PAT
gh auth setup-git
# Clone the community-operators repo (fork is auto-created by gh)
gh repo fork k8s-operatorhub/community-operators --clone=true --remote=true -- community-operators
cd community-operators
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Sync fork with upstream to avoid stale-branch CI failures
git fetch upstream main
git reset --hard upstream/main
git checkout -b "${BRANCH}"
# Copy prepared bundle
mkdir -p operators/paperclip-operator
cp -r ../submission/operators/paperclip-operator/${VERSION} operators/paperclip-operator/${VERSION}
git add "operators/paperclip-operator/${VERSION}"
git commit -m "operator paperclip-operator (${VERSION})"
git push --force origin "${BRANCH}"
# Create PR or update existing one
FORK_OWNER=$(gh api user --jq '.login')
if ! gh pr view "${FORK_OWNER}:${BRANCH}" --repo k8s-operatorhub/community-operators --json state --jq '.state' 2>/dev/null | grep -q OPEN; then
gh pr create \
--repo k8s-operatorhub/community-operators \
--head "${FORK_OWNER}:${BRANCH}" \
--title "operator paperclip-operator (${VERSION})" \
--body "$(cat <<EOF
### Update to paperclip-operator
**Version:** ${VERSION}
**Operator:** [Paperclip Kubernetes Operator](https://github.com/paperclipinc/paperclip-operator)
#### Changes
See [release notes](https://github.com/paperclipinc/paperclip-operator/releases/tag/v${VERSION}).
#### Testing
- CI tests pass on the source repository
- Container image is published and signed at \`ghcr.io/paperclipinc/paperclip-operator:v${VERSION}\`
EOF
)"
else
echo "PR already exists for ${FORK_OWNER}:${BRANCH} - branch was force-pushed with updated content"
fi