Skip to content

Commit ef62195

Browse files
authored
Merge pull request #1 from Cali0707/main
feat: initial setup of the kubernetes extension
2 parents 30ae7d7 + 9b926cd commit ef62195

23 files changed

Lines changed: 1865 additions & 0 deletions

.github/dependabot.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: gomod
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
8+
- package-ecosystem: github-actions
9+
directory: /
10+
schedule:
11+
interval: weekly

.github/workflows/nightly.yaml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
name: Nightly Release
2+
3+
on:
4+
schedule:
5+
# Run at 02:00 UTC every day
6+
- cron: '0 2 * * *'
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: nightly-release
11+
cancel-in-progress: true
12+
13+
jobs:
14+
check-and-create-nightly:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
outputs:
19+
nightly_version: ${{ env.NIGHTLY_VERSION }}
20+
skip_nightly: ${{ env.SKIP_NIGHTLY }}
21+
changelog_body: ${{ env.CHANGELOG_BODY }}
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v6
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Check for unreleased commits
29+
id: check_commits
30+
run: |
31+
# Find the latest release tag (any x.y.z release)
32+
LATEST_RELEASE=$(git tag -l 'v*.*.*' --sort=-version:refname | grep -v 'prerelease' | grep -v '^nightly' | head -n1)
33+
34+
if [ -z "$LATEST_RELEASE" ]; then
35+
echo "No existing releases found, creating first nightly"
36+
COMMITS_SINCE_RELEASE=$(git rev-list HEAD --count)
37+
LATEST_RELEASE_COMMIT=""
38+
else
39+
echo "Latest release: $LATEST_RELEASE"
40+
COMMITS_SINCE_RELEASE=$(git rev-list ${LATEST_RELEASE}..HEAD --count)
41+
LATEST_RELEASE_COMMIT="$LATEST_RELEASE"
42+
fi
43+
44+
echo "Commits since latest release: $COMMITS_SINCE_RELEASE"
45+
46+
if [ "$COMMITS_SINCE_RELEASE" -eq "0" ]; then
47+
echo "No new commits since latest release, skipping nightly"
48+
echo "SKIP_NIGHTLY=true" >> "$GITHUB_ENV"
49+
exit 0
50+
fi
51+
52+
CURRENT_COMMIT=$(git rev-parse HEAD)
53+
54+
# Check for existing nightly with same commit
55+
EXISTING_NIGHTLY_COMMIT=""
56+
if git rev-parse --verify nightly >/dev/null 2>&1; then
57+
EXISTING_NIGHTLY_COMMIT=$(git rev-list -n 1 nightly 2>/dev/null || echo "")
58+
fi
59+
60+
if [ "$EXISTING_NIGHTLY_COMMIT" = "$CURRENT_COMMIT" ]; then
61+
echo "Nightly release already exists for current commit"
62+
echo "SKIP_NIGHTLY=true" >> "$GITHUB_ENV"
63+
exit 0
64+
fi
65+
66+
# Use fixed nightly tag name
67+
NIGHTLY_VERSION="nightly"
68+
echo "NIGHTLY_VERSION=$NIGHTLY_VERSION" >> "$GITHUB_ENV"
69+
echo "Creating nightly release: $NIGHTLY_VERSION"
70+
71+
- name: Extract changelog for nightly
72+
id: changelog
73+
if: env.SKIP_NIGHTLY != 'true'
74+
run: |
75+
# Extract the Unreleased section from CHANGELOG.md using make target
76+
CHANGELOG_CONTENT=$(make extract-changelog-unreleased)
77+
78+
# Save to environment variable, handling multiline content
79+
{
80+
echo 'CHANGELOG_BODY<<EOF'
81+
echo "$CHANGELOG_CONTENT"
82+
echo 'EOF'
83+
} >> "$GITHUB_ENV"
84+
85+
- name: Delete existing nightly release and tag
86+
if: env.SKIP_NIGHTLY != 'true'
87+
run: |
88+
# Delete existing nightly release if it exists
89+
if gh release view nightly >/dev/null 2>&1; then
90+
echo "Deleting existing nightly release"
91+
gh release delete nightly --yes
92+
fi
93+
94+
# Delete existing nightly tag if it exists
95+
if git rev-parse --verify nightly >/dev/null 2>&1; then
96+
echo "Deleting existing nightly tag"
97+
git tag -d nightly
98+
if ! git push origin :refs/tags/nightly; then
99+
echo "Warning: Failed to delete remote nightly tag" >&2
100+
exit 1
101+
fi
102+
fi
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
106+
- name: Create nightly release
107+
if: env.SKIP_NIGHTLY != 'true'
108+
run: |
109+
VERSION="${{ env.NIGHTLY_VERSION }}"
110+
CURRENT_DATE=$(date -u +%Y-%m-%d)
111+
SHORT_COMMIT=$(git rev-parse --short HEAD)
112+
113+
echo "Creating nightly release: $VERSION"
114+
gh release create "$VERSION" \
115+
--title "Nightly Release ($CURRENT_DATE - $SHORT_COMMIT)" \
116+
--notes "${{ env.CHANGELOG_BODY }}" \
117+
--prerelease
118+
env:
119+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120+
121+
build-and-upload:
122+
needs: check-and-create-nightly
123+
if: needs.check-and-create-nightly.outputs.skip_nightly != 'true'
124+
runs-on: ubuntu-latest
125+
permissions:
126+
contents: write
127+
id-token: write # Permission for keyless signing
128+
strategy:
129+
matrix:
130+
goos: [linux, windows, darwin]
131+
goarch: [amd64, arm64]
132+
steps:
133+
- name: Checkout code
134+
uses: actions/checkout@v6
135+
136+
- name: Set up Go
137+
uses: actions/setup-go@v6
138+
with:
139+
go-version-file: 'go.mod'
140+
141+
- name: Install cosign
142+
uses: sigstore/cosign-installer@v4.0.0
143+
144+
- name: Build release artifacts
145+
env:
146+
GOOS: ${{ matrix.goos }}
147+
GOARCH: ${{ matrix.goarch }}
148+
run: make build-release package-release
149+
150+
- name: Sign release artifacts
151+
env:
152+
GOOS: ${{ matrix.goos }}
153+
GOARCH: ${{ matrix.goarch }}
154+
run: make sign-release
155+
156+
- name: Upload assets to nightly release
157+
run: make upload-release-assets VERSION="${{ needs.check-and-create-nightly.outputs.nightly_version }}"
158+
env:
159+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/prerelease.yaml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Create Pre-Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*-rc.*'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'Pre-release tag (e.g., v1.0.0-rc.1)'
11+
required: true
12+
type: string
13+
14+
jobs:
15+
determine-version:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
outputs:
20+
prerelease_version: ${{ env.PRERELEASE_VERSION }}
21+
changelog_body: ${{ env.CHANGELOG_BODY }}
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v6
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Extract version from tag
29+
id: get_version
30+
run: |
31+
# Get version from tag (either from push event or manual input)
32+
if [ "${{ github.event_name }}" = "push" ]; then
33+
VERSION="${{ github.ref_name }}"
34+
else
35+
VERSION="${{ inputs.tag }}"
36+
fi
37+
38+
# Validate version format using make target
39+
make validate-prerelease-tag VERSION="$VERSION"
40+
41+
echo "PRERELEASE_VERSION=$VERSION" >> "$GITHUB_ENV"
42+
echo "Pre-release version: $VERSION"
43+
44+
- name: Extract changelog
45+
id: changelog
46+
run: |
47+
VERSION="${{ env.PRERELEASE_VERSION }}"
48+
# Extract the base release version (without -rc.N suffix)
49+
RELEASE_VERSION=$(echo "$VERSION" | sed 's/-rc\.[0-9]*$//')
50+
51+
# Extract changelog using make target (tries version-specific, then unreleased)
52+
CHANGELOG_CONTENT=$(make extract-changelog-version VERSION="$RELEASE_VERSION" 2>/dev/null || echo "Pre-release build for ${RELEASE_VERSION}. See CHANGELOG.md for details.")
53+
54+
# Save to environment variable, handling multiline content
55+
{
56+
echo 'CHANGELOG_BODY<<EOF'
57+
echo "$CHANGELOG_CONTENT"
58+
echo 'EOF'
59+
} >> "$GITHUB_ENV"
60+
61+
- name: Create or update pre-release
62+
run: |
63+
VERSION="${{ env.PRERELEASE_VERSION }}"
64+
65+
# Check if release already exists
66+
if gh release view "$VERSION" >/dev/null 2>&1; then
67+
echo "Pre-release $VERSION already exists, checking if changelog needs to be updated..."
68+
69+
# Get current release notes
70+
CURRENT_NOTES=$(gh release view "$VERSION" --json body -q .body)
71+
72+
# Check if changelog content is already in the notes
73+
if echo "$CURRENT_NOTES" | grep -qF "${{ env.CHANGELOG_BODY }}"; then
74+
echo "Changelog already present in release notes, skipping update..."
75+
else
76+
echo "Appending changelog to existing release notes..."
77+
NEW_NOTES="${CURRENT_NOTES}\n\n---\n\n${{ env.CHANGELOG_BODY }}"
78+
gh release edit "$VERSION" --notes "$NEW_NOTES"
79+
fi
80+
else
81+
echo "Creating pre-release $VERSION..."
82+
gh release create "$VERSION" \
83+
--title "$VERSION" \
84+
--notes "${{ env.CHANGELOG_BODY }}" \
85+
--prerelease
86+
fi
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
90+
build-and-upload:
91+
needs: determine-version
92+
runs-on: ubuntu-latest
93+
permissions:
94+
contents: write
95+
id-token: write # Permission for keyless signing
96+
strategy:
97+
matrix:
98+
goos: [linux, windows, darwin]
99+
goarch: [amd64, arm64]
100+
steps:
101+
- name: Checkout code
102+
uses: actions/checkout@v6
103+
with:
104+
fetch-depth: 0
105+
106+
- name: Set up Go
107+
uses: actions/setup-go@v6
108+
with:
109+
go-version-file: 'go.mod'
110+
111+
- name: Install cosign
112+
uses: sigstore/cosign-installer@v4.0.0
113+
114+
- name: Build release artifacts
115+
env:
116+
GOOS: ${{ matrix.goos }}
117+
GOARCH: ${{ matrix.goarch }}
118+
VERSION: ${{ needs.determine-version.outputs.prerelease_version }}
119+
run: make build-release package-release
120+
121+
- name: Sign release artifacts
122+
env:
123+
GOOS: ${{ matrix.goos }}
124+
GOARCH: ${{ matrix.goarch }}
125+
run: make sign-release
126+
127+
- name: Upload assets to release
128+
run: make upload-release-assets VERSION="${{ needs.determine-version.outputs.prerelease_version }}"
129+
env:
130+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)