Skip to content

Commit 476fc26

Browse files
chore: change the current release workflow
Fix schemars 1.x update
1 parent 6cf1a65 commit 476fc26

13 files changed

+4376
-4278
lines changed
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
---
2+
name: Release with GGScout Version
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
ggscout_version:
8+
description: 'GGScout version to use for schemas (e.g., v0.17.5, latest)'
9+
required: true
10+
default: 'latest'
11+
type: string
12+
chart_increment:
13+
description: 'Chart version increment type'
14+
required: true
15+
default: 'patch'
16+
type: choice
17+
options:
18+
- patch
19+
- minor
20+
- major
21+
update_app_version:
22+
description: 'Update Chart.yaml appVersion to match GGScout version'
23+
required: false
24+
default: true
25+
type: boolean
26+
27+
concurrency:
28+
group: release-${{ github.ref }}
29+
cancel-in-progress: false
30+
31+
jobs:
32+
release:
33+
runs-on: ubuntu-latest
34+
permissions:
35+
contents: write
36+
pull-requests: write
37+
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 0
43+
token: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Configure Git
46+
run: |
47+
git config user.name "github-actions[bot]"
48+
git config user.email "github-actions[bot]@users.noreply.github.com"
49+
50+
- name: Setup mise
51+
uses: jdx/mise-action@v2
52+
53+
- name: Display release information
54+
run: |
55+
echo "🚀 Starting GGScout Helm Chart Release"
56+
echo "======================================"
57+
echo "GGScout Version: ${{ github.event.inputs.ggscout_version }}"
58+
echo "Chart Increment: ${{ github.event.inputs.chart_increment }}"
59+
echo "Update App Version: ${{ github.event.inputs.update_app_version }}"
60+
echo "======================================"
61+
62+
- name: Install required tools
63+
run: |
64+
echo "Installing Helm plugins..."
65+
mise run install-helm-plugins
66+
67+
- name: Fetch and bundle schemas
68+
run: |
69+
echo "Fetching schemas for GGScout version: ${{ github.event.inputs.ggscout_version }}"
70+
mise run bundle-schemas "${{ github.event.inputs.ggscout_version }}"
71+
72+
- name: Update Chart.yaml appVersion
73+
if: github.event.inputs.update_app_version == 'true'
74+
run: |
75+
GGSCOUT_VERSION="${{ github.event.inputs.ggscout_version }}"
76+
CHART_FILE="charts/ggscout/Chart.yaml"
77+
78+
echo "Updating Chart.yaml appVersion to: ${GGSCOUT_VERSION}"
79+
80+
# Remove 'v' prefix if present for appVersion
81+
APP_VERSION="${GGSCOUT_VERSION#v}"
82+
83+
# Update appVersion in Chart.yaml
84+
if command -v yq >/dev/null 2>&1; then
85+
yq eval ".appVersion = \"${APP_VERSION}\"" -i "${CHART_FILE}"
86+
else
87+
# Fallback to sed if yq is not available
88+
sed -i "s/^appVersion:.*/appVersion: \"${APP_VERSION}\"/" "${CHART_FILE}"
89+
fi
90+
91+
echo "Updated appVersion in ${CHART_FILE}:"
92+
grep "appVersion:" "${CHART_FILE}"
93+
94+
- name: Run tests
95+
run: |
96+
echo "Running Helm chart tests..."
97+
mise run test
98+
99+
- name: Run linting
100+
run: |
101+
echo "Running Helm chart linting..."
102+
mise run lint
103+
104+
- name: Check for changes
105+
id: check_changes
106+
run: |
107+
if git diff --quiet; then
108+
echo "No changes detected"
109+
echo "has_changes=false" >> $GITHUB_OUTPUT
110+
else
111+
echo "Changes detected:"
112+
git diff --name-only
113+
echo "has_changes=true" >> $GITHUB_OUTPUT
114+
fi
115+
116+
- name: Commit schema and Chart.yaml updates
117+
if: steps.check_changes.outputs.has_changes == 'true'
118+
run: |
119+
echo "Committing updates..."
120+
git add .
121+
git commit -m "feat: update schemas and appVersion for GGScout ${{ github.event.inputs.ggscout_version }}
122+
123+
- Fetch schemas from GGScout version ${{ github.event.inputs.ggscout_version }}
124+
- Update bundled values.schema.json
125+
$(if [ '${{ github.event.inputs.update_app_version }}' = 'true' ]; then echo '- Update Chart.yaml appVersion'; fi)
126+
127+
🤖 Generated with [Claude Code](https://claude.ai/code)
128+
129+
Co-Authored-By: Claude <[email protected]>"
130+
131+
- name: Create release
132+
run: |
133+
echo "Creating Helm chart release..."
134+
cz bump --increment "${{ github.event.inputs.chart_increment }}"
135+
136+
- name: Push changes and tags
137+
run: |
138+
echo "Pushing changes and tags to repository..."
139+
git push origin main --follow-tags
140+
141+
- name: Generate release summary
142+
run: |
143+
echo "## 🎉 Release Summary" >> $GITHUB_STEP_SUMMARY
144+
echo "" >> $GITHUB_STEP_SUMMARY
145+
echo "| Parameter | Value |" >> $GITHUB_STEP_SUMMARY
146+
echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY
147+
echo "| GGScout Version | \`${{ github.event.inputs.ggscout_version }}\` |" >> $GITHUB_STEP_SUMMARY
148+
echo "| Chart Increment | \`${{ github.event.inputs.chart_increment }}\` |" >> $GITHUB_STEP_SUMMARY
149+
echo "| Updated App Version | ${{ github.event.inputs.update_app_version }} |" >> $GITHUB_STEP_SUMMARY
150+
echo "" >> $GITHUB_STEP_SUMMARY
151+
echo "### ✅ Completed Steps" >> $GITHUB_STEP_SUMMARY
152+
echo "- Downloaded schemas from ggscout-repository" >> $GITHUB_STEP_SUMMARY
153+
echo "- Updated bundled schema files" >> $GITHUB_STEP_SUMMARY
154+
$(if [ '${{ github.event.inputs.update_app_version }}' = 'true' ]; then echo "- Updated Chart.yaml appVersion" >> $GITHUB_STEP_SUMMARY; fi)
155+
echo "- Ran tests and linting" >> $GITHUB_STEP_SUMMARY
156+
echo "- Created and pushed release" >> $GITHUB_STEP_SUMMARY
157+
echo "" >> $GITHUB_STEP_SUMMARY
158+
echo "🚀 **Chart release is now available!**" >> $GITHUB_STEP_SUMMARY
159+
160+
notify-completion:
161+
needs: release
162+
runs-on: ubuntu-latest
163+
if: always()
164+
165+
steps:
166+
- name: Notify completion
167+
run: |
168+
if [ "${{ needs.release.result }}" = "success" ]; then
169+
echo "✅ Release workflow completed successfully!"
170+
echo "The new Helm chart version with GGScout ${{ github.event.inputs.ggscout_version }} schemas is now available."
171+
else
172+
echo "❌ Release workflow failed!"
173+
echo "Please check the logs above for error details."
174+
fi

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
.vscode/
33
*.DS_Store
44
*.egg-info/
5+
6+
# Schema cache directory (populated by scripts/fetch-schemas.js)
7+
.cache/

.mise-tasks/bundle-schemas

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,55 @@
22
set -euo pipefail
33
IFS=$'\n\t'
44

5+
#USAGE arg "ggscout_version" help="GGScout version to fetch schemas for" default="latest"
6+
7+
GGSCOUT_VERSION="${1:-latest}"
8+
9+
echo "==================================="
10+
echo "GGScout Schema Bundle Process"
11+
echo "==================================="
12+
echo "GGScout Version: ${GGSCOUT_VERSION}"
13+
echo ""
14+
15+
# Fetch schemas for the specified version
16+
echo "Step 1: Fetching schemas..."
17+
echo "-----------------------------------"
18+
if ! node scripts/fetch-schemas.js "${GGSCOUT_VERSION}"; then
19+
echo "Error: Failed to fetch schemas for version ${GGSCOUT_VERSION}"
20+
exit 1
21+
fi
22+
23+
# Determine schema source directory
24+
SCHEMA_SOURCE_DIR=".cache/schemas/${GGSCOUT_VERSION}"
25+
if [[ ! -d "${SCHEMA_SOURCE_DIR}" ]]; then
26+
echo "Error: Schema cache directory not found: ${SCHEMA_SOURCE_DIR}"
27+
exit 1
28+
fi
29+
30+
echo ""
31+
echo "Step 2: Bundling schemas..."
32+
echo "-----------------------------------"
33+
534
process_json_schema() {
635
local directory="$1"
736
local base_values_schema_path="${directory}"/values-base-schema.schema.json
837
local values_schema_path="${directory}"/values.schema.json
938
local temp_dir
1039
temp_dir="$(mktemp -d)"
1140
local bundled_path="${temp_dir}"/resolved.json
12-
echo "Bundling schema from ${base_values_schema_path} to ${bundled_path}"
13-
jsonschema bundle --resolve schemas/ "${base_values_schema_path}" --without-id > "${bundled_path}"
14-
echo "Normalizing schema from ${bundled_path} to ${values_schema_path}"
15-
jsonschema canonicalize "${bundled_path}" > "${values_schema_path}"
41+
42+
echo "Bundling schema from ${base_values_schema_path}"
43+
echo "Using schema source: ${SCHEMA_SOURCE_DIR}"
44+
echo "Output: ${values_schema_path}"
45+
46+
# Use cached schemas instead of local schemas/ folder
47+
jsonschema bundle --resolve "${SCHEMA_SOURCE_DIR}" "${base_values_schema_path}" --without-id > "${values_schema_path}"
48+
49+
# Post-process to fix all schema structure issues
50+
echo "Post-processing schema to fix all structural issues..."
51+
node scripts/fix-schema-structure.js "${values_schema_path}"
52+
53+
echo "✓ Schema bundling completed for ${directory}"
1654
}
1755

1856
for chart in charts/*/

.mise-tasks/release

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,27 @@ IFS=$'\n\t'
55
#USAGE arg "<type>" help="Release type" default="patch" {
66
#USAGE choices "patch" "minor" "major"
77
#USAGE }
8+
#USAGE arg "ggscout_version" help="GGScout version to use for schemas" default="latest"
89

9-
cz bump
10+
RELEASE_TYPE="${1:-patch}"
11+
GGSCOUT_VERSION="${2:-latest}"
12+
13+
echo "==================================="
14+
echo "GGScout Helm Chart Release"
15+
echo "==================================="
16+
echo "Release Type: ${RELEASE_TYPE}"
17+
echo "GGScout Version: ${GGSCOUT_VERSION}"
18+
echo ""
19+
20+
# Ensure schemas are up to date with the specified version
21+
echo "Step 1: Updating schemas for GGScout version ${GGSCOUT_VERSION}..."
22+
echo "-------------------------------------------------------------------"
23+
if ! mise run bundle-schemas "${GGSCOUT_VERSION}"; then
24+
echo "Error: Failed to bundle schemas for GGScout version ${GGSCOUT_VERSION}"
25+
exit 1
26+
fi
27+
28+
echo ""
29+
echo "Step 2: Creating release..."
30+
echo "-------------------------------------------------------------------"
31+
cz bump --increment "${RELEASE_TYPE}"

charts/ggscout/values-base-schema.schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
"type": "object",
88
"properties": {
99
"log_level": {
10-
"$ref": "inventory-log-level.schema.json"
10+
"$ref": "https://gitguardian.com/inventory-log-level"
1111
},
1212
"config": {
13-
"$ref": "inventory-config.schema.json"
13+
"$ref": "https://gitguardian.com/inventory-config"
1414
},
1515
"jobs": {
16-
"$ref": "jobs.schema.json"
16+
"$ref": "https://gitguardian.com/jobs"
1717
}
1818
},
1919
"required": ["config"]

0 commit comments

Comments
 (0)