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
11 changes: 11 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# GitHub Release Notes Configuration
# This file configures how GitHub auto-generates release notes
# It separates dependency updates into a "Version Bumps" section
# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes

changelog:
categories:
- title: Version Bumps
labels:
- dependencies
79 changes: 79 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write
pull-requests: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Configure git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"

- name: Get tag information
id: tag_data
run: |
# Get tag name and message
TAG_NAME=${GITHUB_REF#refs/tags/}
TAG_MESSAGE=$(git tag -n1 "$TAG_NAME" | sed "s/^$TAG_NAME[[:space:]]*//")

# If tag message is empty, use a default
if [ -z "$TAG_MESSAGE" ]; then
TAG_MESSAGE="Release $TAG_NAME"
fi

echo "TAG_NAME=$TAG_NAME" >> $GITHUB_OUTPUT
echo "TAG_MESSAGE<<EOF" >> $GITHUB_OUTPUT
echo "$TAG_MESSAGE" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "VERSION=${TAG_NAME#v}" >> $GITHUB_OUTPUT

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Determine if this is a prerelease
PRERELEASE=""
if [[ "${{ steps.tag_data.outputs.TAG_NAME }}" =~ (alpha|beta|rc) ]]; then
PRERELEASE="--prerelease"
fi

# Create release with auto-generated notes
gh release create "${{ steps.tag_data.outputs.TAG_NAME }}" \
--title "${{ steps.tag_data.outputs.TAG_NAME }}" \
--notes "${{ steps.tag_data.outputs.TAG_MESSAGE }}" \
--generate-notes \
$PRERELEASE

- name: Update kustomization.yaml
run: |
./scripts/bump-version.sh "${{ steps.tag_data.outputs.TAG_NAME }}"

- name: Commit and push changes
run: |
# Check if there are changes to commit
if git diff --quiet; then
echo "No changes to commit"
exit 0
fi

git add config/manager/kustomization.yaml
git commit -m "chore: bump version to ${{ steps.tag_data.outputs.TAG_NAME }} [skip ci]"

# Push to main branch
git push origin HEAD:main
5 changes: 5 additions & 0 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
resources:
- manager.yaml

images:
- name: controller
newName: ghcr.io/netbox-community/netbox-operator
newTag: v0.2.8
27 changes: 27 additions & 0 deletions scripts/bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -e

# Script to bump version in kustomization.yaml
# Usage: ./bump-version.sh <new_version>

NEW_VERSION=$1

if [ -z "$NEW_VERSION" ]; then
echo "Usage: $0 <new_version>"
exit 1
fi

KUSTOMIZATION_FILE="config/manager/kustomization.yaml"

if [ ! -f "$KUSTOMIZATION_FILE" ]; then
echo "Error: $KUSTOMIZATION_FILE not found!"
exit 1
fi

echo "Updating version to $NEW_VERSION in $KUSTOMIZATION_FILE..."

# Update the newTag
sed -i.bak "s/newTag: .*/newTag: $NEW_VERSION/" "$KUSTOMIZATION_FILE"
rm -f "$KUSTOMIZATION_FILE.bak"

echo "Version bumped to $NEW_VERSION successfully!"
Loading