Skip to content

Commit 0eb27d4

Browse files
authored
start release pipeline on workflow_dispatch (#436)
* start release pipeline on workflow_dispatch * improve based on pr review * use latest netbox helm chart * remove kind load docker-image * undo helm chart upgrade * upgrade netbox helm chart * load images to kind * fix kind deployment
1 parent 0724435 commit 0eb27d4

File tree

4 files changed

+74
-80
lines changed

4 files changed

+74
-80
lines changed

.github/workflows/release.yaml

Lines changed: 60 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22
name: Release
33

44
on:
5-
push:
6-
tags:
7-
- 'v*'
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'Version that should be released, format: v0.0.0'
9+
required: true
10+
type: string
11+
tagMessage:
12+
description: 'Message that will be added to the version tag'
13+
required: true
14+
type: string
815

916
permissions:
1017
contents: write
@@ -25,50 +32,52 @@ jobs:
2532
git config --global user.email "github-actions[bot]@users.noreply.github.com"
2633
git config --global user.name "github-actions[bot]"
2734
28-
- name: Get tag information
29-
id: tag_data
35+
- name: Update kustomization.yaml
3036
run: |
31-
# Get tag name and message
32-
TAG_NAME=${GITHUB_REF#refs/tags/}
33-
TAG_MESSAGE=$(git tag -n1 "$TAG_NAME" | sed "s|^$TAG_NAME[[:space:]]*||")
34-
35-
# If tag message is empty, use a default
36-
if [ -z "$TAG_MESSAGE" ]; then
37-
TAG_MESSAGE="Release $TAG_NAME"
37+
# Fail if tag already exists
38+
if [ -n "$(git tag --list "${{ inputs.version }}")" ]; then
39+
echo "Tag "${{ inputs.version }}" already exists. Exit."
40+
exit 1
41+
else
42+
echo "Tag "${{ inputs.version }}" does not exist. Continue."
3843
fi
3944
40-
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_OUTPUT
41-
echo "TAG_MESSAGE<<EOF" >> $GITHUB_OUTPUT
42-
echo "$TAG_MESSAGE" >> $GITHUB_OUTPUT
43-
echo "EOF" >> $GITHUB_OUTPUT
44-
echo "VERSION=${TAG_NAME#v}" >> $GITHUB_OUTPUT
45+
# Update image tag
46+
cd config/manager
47+
kustomize edit set image controller="netbox-operator:${{inputs.version}}"
48+
cd ../..
4549
46-
- name: Create GitHub Release
50+
- name: Generate release notes for changelog
4751
env:
48-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4953
run: |
50-
# Determine if this is a prerelease
51-
PRERELEASE=""
52-
if [[ "${{ steps.tag_data.outputs.TAG_NAME }}" =~ (alpha|beta|rc) ]]; then
53-
PRERELEASE="--prerelease"
54+
# Get the previous tag to determine commit range
55+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
56+
57+
# Generate release notes using GitHub API without creating a release
58+
if [ -n "$PREVIOUS_TAG" ]; then
59+
RELEASE_NOTES=$(gh api repos/:owner/:repo/releases/generate-notes \
60+
-f tag_name="${{ inputs.version }}" \
61+
-f target_commitish="$(git rev-parse HEAD)" \
62+
-f previous_tag_name="$PREVIOUS_TAG" \
63+
--jq '.body')
64+
else
65+
# If no previous tag, generate notes from all commits
66+
RELEASE_NOTES=$(gh api repos/:owner/:repo/releases/generate-notes \
67+
-f tag_name="${{ inputs.version }}" \
68+
-f target_commitish="$(git rev-parse HEAD)" \
69+
--jq '.body')
5470
fi
5571
56-
# Create release with auto-generated notes
57-
gh release create "${{ steps.tag_data.outputs.TAG_NAME }}" \
58-
--title "${{ steps.tag_data.outputs.TAG_NAME }}" \
59-
--notes "${{ steps.tag_data.outputs.TAG_MESSAGE }}" \
60-
--generate-notes \
61-
$PRERELEASE
62-
63-
- name: Update kustomization.yaml
64-
run: |
65-
./scripts/bump-version.sh "${{ steps.tag_data.outputs.TAG_NAME }}"
72+
# Save release notes to a file for use in changelog
73+
echo "$RELEASE_NOTES" > /tmp/release_notes.md
6674
6775
- name: Update CHANGELOG.md
6876
env:
6977
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7078
run: |
71-
./scripts/update-changelog-from-release.sh "${{ steps.tag_data.outputs.TAG_NAME }}"
79+
# Update changelog with the generated notes
80+
./scripts/update-changelog-from-release.sh "${{ inputs.version }}"
7281
7382
- name: Commit and push changes
7483
env:
@@ -81,23 +90,33 @@ jobs:
8190
fi
8291
8392
# Create a new branch for the changes
84-
BRANCH_NAME="release-updates-${{ steps.tag_data.outputs.TAG_NAME }}"
93+
BRANCH_NAME="release-updates-${{ inputs.version }}"
8594
git checkout -b "$BRANCH_NAME"
8695
8796
git add config/manager/kustomization.yaml CHANGELOG.md
88-
git commit -m "[skip ci] chore: bump version to ${{ steps.tag_data.outputs.TAG_NAME }} and update changelog"
89-
97+
git commit -m "[skip ci] chore: bump version to ${{ inputs.version }} and update changelog"
9098
# Push the branch and create PR
99+
91100
git push origin "$BRANCH_NAME"
92101
PR_URL=$(gh pr create \
93-
--title "chore: bump version to ${{ steps.tag_data.outputs.TAG_NAME }} and update changelog" \
94-
--body "Automated version bump and changelog update for release ${{ steps.tag_data.outputs.TAG_NAME }}" \
102+
--title "chore: bump version to ${{ inputs.version }} and update changelog" \
103+
--body "Automated version bump and changelog update for release ${{ inputs.version }}" \
95104
--head "$BRANCH_NAME" \
96105
--base main)
97106
98107
# Extract PR number from URL
99108
PR_NUMBER=$(echo "$PR_URL" | sed 's/.*\/pull\///')
100109
echo "Created PR #$PR_NUMBER: $PR_URL"
101110
102-
# Enable auto-merge and merge the PR
103-
gh pr merge "$PR_NUMBER" --auto --squash --delete-branch
111+
# Merge the PR
112+
gh pr merge "$PR_NUMBER" --squash --delete-branch
113+
114+
- name: Create GitHub Release
115+
env:
116+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
run: |
118+
# Create release with auto-generated notes
119+
gh release create "${{ inputs.version }}" \
120+
--title "${{ inputs.version }}" \
121+
--notes "${{ inputs.tagMessage }}" \
122+
--generate-notes

kind/deploy-netbox.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if [[ "${VERSION}" == "3.7.8" ]] ;then
4444
# need to align with netbox-chart otherwise the creation of the cluster will hang
4545
declare -a Remote_Images=( \
4646
"busybox:1.36.1" \
47-
"docker.io/bitnami/redis:7.2.4-debian-12-r9" \
47+
"docker.io/bitnamilegacy/redis:7.2.4-debian-12-r9" \
4848
"docker.io/netboxcommunity/netbox:v3.7.8" \
4949
"ghcr.io/zalando/postgres-operator:v1.12.2" \
5050
"ghcr.io/zalando/spilo-16:3.2-p3" \
@@ -61,7 +61,7 @@ elif [[ "${VERSION}" == "4.0.11" ]] ;then
6161
# need to align with netbox-chart otherwise the creation of the cluster will hang
6262
declare -a Remote_Images=( \
6363
"busybox:1.36.1" \
64-
"docker.io/bitnami/redis:7.4.0-debian-12-r2" \
64+
"docker.io/bitnamilegacy/redis:7.4.0-debian-12-r2" \
6565
"ghcr.io/netbox-community/netbox:v4.0.11" \
6666
"ghcr.io/zalando/postgres-operator:v1.12.2" \
6767
"ghcr.io/zalando/spilo-16:3.2-p3" \
@@ -77,7 +77,7 @@ elif [[ "${VERSION}" == "4.1.11" ]] ;then
7777
# need to align with netbox-chart otherwise the creation of the cluster will hang
7878
declare -a Remote_Images=( \
7979
"busybox:1.37.0" \
80-
"docker.io/bitnami/redis:7.4.1-debian-12-r2" \
80+
"docker.io/bitnamilegacy/redis:7.4.1-debian-12-r2" \
8181
"ghcr.io/netbox-community/netbox:v4.1.11" \
8282
"ghcr.io/zalando/postgres-operator:v1.12.2" \
8383
"ghcr.io/zalando/spilo-16:3.2-p3" \
@@ -202,7 +202,9 @@ ${HELM} upgrade --install netbox ${NETBOX_HELM_CHART} \
202202
--set resources.requests.memory="512Mi" \
203203
--set resources.limits.cpu="2000m" \
204204
--set resources.limits.memory="2Gi" \
205-
$REGISTRY_ARG
205+
--set redis.image.repository="bitnamilegacy/redis" \
206+
--set global.security.allowInsecureImages=true
207+
$REGISTRY_ARG
206208

207209
if [[ "$FORCE_NETBOX_NGINX_IPV4" == "true" ]]; then
208210
echo "Creating nginx-unit ConfigMap and patching deployment"

scripts/bump-version.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

scripts/update-changelog-from-release.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ fi
1313

1414
echo "Updating CHANGELOG.md for release $TAG_NAME..."
1515

16-
# Get release data from GitHub
17-
RELEASE_DATA=$(gh release view "$TAG_NAME" --json tagName,publishedAt,body,url)
16+
# Get release data from file
17+
RELEASE_NOTES=$(cat /tmp/release_notes.md)
1818

19-
# Extract fields
20-
TAG=$(echo "$RELEASE_DATA" | jq -r '.tagName')
21-
DATE=$(echo "$RELEASE_DATA" | jq -r '.publishedAt' | cut -d'T' -f1)
22-
BODY=$(echo "$RELEASE_DATA" | jq -r '.body')
23-
URL=$(echo "$RELEASE_DATA" | jq -r '.url')
19+
# Use current date and tag name from parameter
20+
TAG="$TAG_NAME"
21+
DATE=$(date +%Y-%m-%d)
22+
BODY="$RELEASE_NOTES"
23+
URL="https://github.com/netbox-community/netbox-operator/releases/tag/$TAG_NAME"
2424

2525
# Validate extracted fields
2626
if [ -z "$TAG" ] || [ -z "$DATE" ] || [ -z "$URL" ]; then
@@ -67,4 +67,4 @@ awk '/^## \[/ {found=1} found {print}' CHANGELOG.md >> "$TEMP_FILE"
6767
# Replace the original file
6868
mv "$TEMP_FILE" CHANGELOG.md
6969

70-
echo "CHANGELOG.md updated successfully!"
70+
echo "CHANGELOG.md updated successfully!"

0 commit comments

Comments
 (0)