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
4 changes: 2 additions & 2 deletions .cursor/rules/zz_generated.base-llm-rules.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You are an AI assistant acting as an expert software developer and platform engi
- Write comprehensive tests and documentation.
- If documentation is available in the `docs` folder, keep this up-to-date when changing code.
- Maintain the main README.md file for correctness.
- If a changelog is available as CHANGELOG.md, add your changes to it.
- If a changelog is available as CHANGELOG.md, add your changes to it, unless the repository has `.github/workflows/zz_generated.auto_release.yaml`: there GitHub Releases are the changelog, written from the pull request titles, and CHANGELOG.md only points at them, so a pull request does not edit it.

## Release Management

Expand Down Expand Up @@ -56,6 +56,6 @@ For detailed guidelines and examples, always refer to: @https://github.com/giant
<!--
DO NOT EDIT. Generated with devctl.
This file is maintained at:
https://github.com/giantswarm/devctl/blob/3bbd5cb47ff855f0b9c88881fbdcaa907d85647c/pkg/gen/input/llm/internal/file/base_llm_rules.mdc.template
https://github.com/giantswarm/devctl/blob/a412d1a88eafd4543e12c04bb34a07fd32472280/pkg/gen/input/llm/internal/file/base_llm_rules.mdc.template
Manual changes will be overwritten.
-->
4 changes: 0 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@
### What is needed from the reviewers?

### Do the docs need to be updated?

### Should this change be mentioned in the release notes?

- [ ] CHANGELOG.md has been updated (if it exists)
55 changes: 50 additions & 5 deletions .github/workflows/zz_generated.auto_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# devctl
#
# https://github.com/giantswarm/devctl/blob/e1815b6d5c229bcb04d97e68566da30380a1d92f/pkg/gen/input/workflows/internal/file/auto_release.yaml.template
# https://github.com/giantswarm/devctl/blob/32940f296e152fd291e36a4c579e8c491c14e820/pkg/gen/input/workflows/internal/file/auto_release.yaml.template
#
# yamllint disable rule:truthy
# Push-based release tagger + release-page publisher.
Expand All @@ -26,6 +26,13 @@
# the one `version` names: the stable tag lands on that candidate's commit,
# so what ships is what was tested.
#
# Tags and releases are created with the giantswarm-release GitHub App token,
# so GitHub Actions workflows listening on push.tags or release can start.
# Requires the App installed on this repository with Contents write and the
# RELEASE_BOT_CLIENT_ID / RELEASE_BOT_PRIVATE_KEY secrets available to this
# workflow. Missing or unusable App credentials fail before creating a release;
# there is no GITHUB_TOKEN fallback, whose events cannot start those workflows.
#
# The tag push then triggers downstream publishing (for chart/service/CLI
# repos, this is the CircleCI architect pipeline firing on the same /^v.*/
# tag filter -- go-build + push-to-registries + push-to-app-catalog +
Expand Down Expand Up @@ -78,7 +85,7 @@ jobs:
name: Tag
runs-on: ubuntu-26.04
permissions:
contents: write # push tags and create the GitHub Release
contents: read # checkout and fetch; the App creates tags/releases
# git-cliff's GitHub API lookups (commit.remote.pr_number / username
# in release notes) need PR read access via GITHUB_TOKEN.
pull-requests: read
Expand Down Expand Up @@ -230,7 +237,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
# Single expensive call: walks commits, queries the GitHub API for
# One context read: walks commits, queries the GitHub API for
# per-commit PR lookups, emits the JSON context for ONLY the bumped
# release.
#
Expand All @@ -247,7 +254,27 @@ jobs:
# Without either filter, --bump --context returns the full release
# history in JSON and the render step below would concatenate every
# past release into each new release's notes.
git-cliff --unreleased --bump --context > cliff-context.json
# GitHub metadata reads can fail on a transient timeout, truncated
# response or 5xx. Retry with bounded backoff. Keep stderr in the
# log, including the final cause, and replace any partial context
# on each attempt before downstream steps can use it.
cliff_context() {
local try tries=3 status
for ((try=1; try<=tries; try++)); do
if git-cliff "$@" > cliff-context.json; then
return 0
else
status=$?
fi
if [ "$try" -eq "$tries" ]; then
echo "::error title=git-cliff failed::git-cliff failed after ${tries} attempts (exit ${status}); see its error above." >&2
return "$status"
fi
echo "git-cliff failed (attempt ${try} of ${tries}, exit ${status}); retrying in $((2 ** try))s" >&2
sleep $((2 ** try))
done
}
cliff_context --unreleased --bump --context
NEXT=$(jq -r '.[0].version // empty' cliff-context.json)
echo "next computed: ${NEXT:-<empty>}"
echo "version=${NEXT}" >> "$GITHUB_OUTPUT"
Expand Down Expand Up @@ -354,13 +381,20 @@ jobs:
# cliff-context.json holds exactly the commits git-cliff counted
# for this release, so intersecting it with the range since the
# last candidate needs no second copy of cliff.toml's skip rules.
# A new conventional `test:` commit is also enough once this
# target has a candidate: a test fix must be able to replace a
# red candidate. It opens no cycle and changes no version or notes.
if [ -n "${n}" ]; then
counted=$(jq -r '.[0].commits[].id' "$CLIFF_CONTEXT")
since=$(git rev-list "${NEXT}-rc.${n}..HEAD")
fresh=0
if [ -n "$counted" ] && [ -n "$since" ]; then
fresh=$(printf '%s\n' "$since" | { grep -cxF "$counted" || true; })
fi
if [ "$fresh" -eq 0 ]; then
fresh=$(git log --format='%s' "${NEXT}-rc.${n}..HEAD" \
| { grep -cE '^test(\([^)]*\))?!?: ' || true; })
fi
if [ "$fresh" -eq 0 ]; then
echo "No releasable commits since ${NEXT}-rc.${n}; skipping tag."
echo "tag=" >> "$GITHUB_OUTPUT"
Expand Down Expand Up @@ -482,6 +516,17 @@ jobs:
# create --notes-file expects.
git-cliff --from-context cliff-context.tagged.json --strip all --output release-notes.md

# Mint just before publishing, after the release guards have passed.
# With owner/repositories unset, the token is scoped to this repository.
- name: Generate the giantswarm-release token
id: release-token
if: steps.decide.outputs.tag != ''
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
client-id: ${{ secrets.RELEASE_BOT_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}
permission-contents: write

# Create the tag AND the GitHub Release in one atomic API call. GitHub's
# release-create endpoint accepts a tag_name + target_commitish and, if
# the tag doesn't already exist, creates it pointing at that commitish
Expand All @@ -498,7 +543,7 @@ jobs:
id: release
if: steps.decide.outputs.tag != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ steps.release-token.outputs.token }}
GH_REPO: ${{ github.repository }}
TAG: ${{ steps.decide.outputs.tag }}
PRERELEASE: ${{ steps.decide.outputs.prerelease }}
Expand Down
10 changes: 8 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# devctl
#
# https://github.com/giantswarm/devctl/blob/95d98f7c606e2f51e53c284b5f1410044b36ea20/pkg/gen/input/precommit/internal/file/pre-commit-config.yaml.template
# https://github.com/giantswarm/devctl/blob/70705527cb6300cabe9bd3ba6af5bdf9bf0ae1dd/pkg/gen/input/precommit/internal/file/pre-commit-config.yaml.template
#
minimum_pre_commit_version: '2.17'
default_install_hook_types: [pre-commit, commit-msg]
Expand Down Expand Up @@ -51,6 +51,8 @@ repos:
- id: go-mod-tidy
- id: golangci-lint
args:
# Let independent sessions and worktrees lint at the same time.
- --allow-parallel-runners
# No --timeout: golangci-lint v2 has none by default and a flag would
# override a repo's `run.timeout` in .golangci.yml, its place to set one.
# List all issues found
Expand Down Expand Up @@ -139,7 +141,7 @@ repos:
python3 -c 'import json,sys; h=lambda o: {**{k:v for k,v in o.items() if k!="additionalProperties"},"unevaluatedProperties":False} if ("$ref" in o and o.get("additionalProperties") is False) else o; p=sys.argv[1]; f=open(p,encoding="utf-8"); d=json.load(f,object_hook=h); f.close(); f=open(p,"w",encoding="utf-8"); json.dump(d,f); f.close()' "$tmp"
schemalint normalize "$tmp" -o "$tmp" --force
if ! diff -u helm/skill-manager/values.schema.json "$tmp"; then
echo "helm/skill-manager/values.schema.json is out of date -- run 'devctl gen precommit' and commit the result" >&2
printf '%s\n' "helm/skill-manager/values.schema.json is out of date; run from the repository root and commit the result:" 'devctl gen precommit --language='"'"'go'"'"' --repo-name='"'"'github.com/giantswarm/skill-manager'"'"' --flavors='"'"'helmchart'"'"' --k8s-schema-version='"'"'v1.33.1'"'"'' >&2
exit 1
fi
- repo: https://github.com/giantswarm/schemalint
Expand All @@ -157,6 +159,10 @@ repos:
rev: "v1.14.2"
hooks:
- id: helm-docs
# The upstream script hook uses helm-docs from PATH. Build this rev
# in pre-commit's isolated Go environment so local and CI runs agree.
language: golang
entry: helm-docs
args:
- --chart-search-root=helm
- --chart-to-generate=helm/skill-manager
Expand Down
15 changes: 4 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
# Changelog

All notable changes to this project will be documented in this file.
The changes of each release are in its notes on GitHub Releases:
https://github.com/giantswarm/skill-manager/releases

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).



## [Unreleased]



[Unreleased]: https://github.com/giantswarm/skill-manager/tree/main
This file is not updated any more: a pull request does not edit it. The
pull request title is the release note.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#
# devctl
#
# https://github.com/giantswarm/devctl/blob/c0a255e412bf450e122f71e563d74a9bd9f9cddf/pkg/gen/input/makefile/internal/file/Makefile.template
# https://github.com/giantswarm/devctl/blob/1db8df846716412f82889c81256ff31c9acf2638/pkg/gen/input/makefile/internal/file/Makefile.template
#

include Makefile.*.mk
-include Makefile.*.mk

##@ General

Expand Down
58 changes: 42 additions & 16 deletions Makefile.gen.go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# devctl
#
# https://github.com/giantswarm/devctl/blob/c64a781d7ee888be4af92da9cce27c321300a589/pkg/gen/input/makefile/internal/file/Makefile.gen.go.mk.template
# https://github.com/giantswarm/devctl/blob/2da48e8e991a721cdb632ba78fb4c3cbea2e06f6/pkg/gen/input/makefile/internal/file/Makefile.gen.go.mk.template
#

APPLICATION := $(shell go list -m | cut -d '/' -f 3)
Expand All @@ -12,12 +12,17 @@ MODULE := $(shell go list -m)
# main() is usually in `main.go`, but sometimes in `cmd/main.go` (for example in newer kubebuilder projects)
MAIN_SOURCE := $(shell if test -e cmd/main.go; then echo cmd/main.go; else echo main.go; fi)
OS := $(shell go env GOOS)
ARCH := $(shell go env GOARCH)
SOURCES := $(shell find . -name '*.go')
VERSION := $(shell gitsemver get)
# Expanded first in every recipe that stamps VERSION into its output, so a failed
# `gitsemver get` fails the build instead of producing an unversioned binary.
# Older gitsemver releases cannot open a worktree's .git file. Fall back to
# local version tags; without one, leave VERSION empty so shipping targets fail.
VERSION := $(shell if version=$$(gitsemver get 2>/dev/null) && [ -n "$$version" ]; then \
printf '%s\n' "$$version"; \
else git describe --tags --match 'v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null | sed 's/^v//'; fi)
# Expanded first in every recipe that stamps VERSION into its output, so failed
# lookups fail the build instead of producing an unversioned binary.
# Targets that do not ship a version (test, lint, ...) never expand it.
REQUIRE_VERSION = $(if $(VERSION),,$(error VERSION is empty: `gitsemver get` failed in $(CURDIR); pass VERSION=<version> to override))
REQUIRE_VERSION = $(if $(VERSION),,$(error VERSION is empty: `gitsemver get` and `git describe` found no version in $(CURDIR); pass VERSION=<version> to override))
ifeq ($(OS), linux)
EXTLDFLAGS := -static
endif
Expand All @@ -26,6 +31,13 @@ LDFLAGS ?= -w -linkmode 'auto' -extldflags '$(EXTLDFLAGS)' \
-X '$(MODULE)/pkg/project.buildTimestamp=$(BUILDTIMESTAMP)' \
-X '$(MODULE)/pkg/project.gitSHA=$(GITSHA1)'

# Copy to a unique sibling before renaming so a running binary keeps its inode
# and readers only see complete files. Keep the versioned artifact for packaging.
INSTALL_BINARY = tmp=$$(mktemp "$(2).tmp.XXXXXX") || exit $$?; \
trap 'rm -f "$$tmp"' EXIT; \
trap 'exit 1' HUP INT TERM; \
cp -a "$(1)" "$$tmp" && mv -f "$$tmp" "$(2)"

.DEFAULT_GOAL := build

##@ Go
Expand All @@ -46,27 +58,31 @@ build-windows-amd64: $(APPLICATION)-windows-amd64.exe ## Builds a local binary f

$(APPLICATION): $(APPLICATION)-v$(VERSION)-$(OS)-amd64
@echo "====> $@"
cp -a $< $@
@$(call INSTALL_BINARY,$<,$@)

$(APPLICATION)-darwin: $(APPLICATION)-v$(VERSION)-darwin-amd64
@echo "====> $@"
cp -a $< $@
@$(call INSTALL_BINARY,$<,$@)

$(APPLICATION)-darwin-arm64: $(APPLICATION)-v$(VERSION)-darwin-arm64
@echo "====> $@"
cp -a $< $@
@$(call INSTALL_BINARY,$<,$@)

$(APPLICATION)-linux: $(APPLICATION)-v$(VERSION)-linux-amd64
@echo "====> $@"
cp -a $< $@
@$(call INSTALL_BINARY,$<,$@)

$(APPLICATION)-linux-amd64: $(APPLICATION)-v$(VERSION)-linux-amd64
@echo "====> $@"
@$(call INSTALL_BINARY,$<,$@)

$(APPLICATION)-linux-arm64: $(APPLICATION)-v$(VERSION)-linux-arm64
@echo "====> $@"
cp -a $< $@
@$(call INSTALL_BINARY,$<,$@)

$(APPLICATION)-windows-amd64.exe: $(APPLICATION)-v$(VERSION)-windows-amd64.exe
@echo "====> $@"
cp -a $< $@
@$(call INSTALL_BINARY,$<,$@)

$(APPLICATION)-v$(VERSION)-%-amd64: $(SOURCES)
$(REQUIRE_VERSION)
Expand All @@ -87,7 +103,7 @@ $(APPLICATION)-v$(VERSION)-windows-amd64.exe: $(SOURCES)
install: ## Install the application.
$(REQUIRE_VERSION)
@echo "====> $@"
go build -ldflags "$(LDFLAGS)" -o "$(shell go env GOPATH)/bin/$(APPLICATION)" "$(MAIN_SOURCE)"
CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o "$(shell go env GOPATH)/bin/$(APPLICATION)" "$(MAIN_SOURCE)"

.PHONY: run
run: ## Runs go run main.go.
Expand All @@ -106,10 +122,20 @@ imports: ## Runs goimports.
goimports -local $(MODULE) -w .

.PHONY: lint
lint: ## Runs golangci-lint.
@echo "====> $@"
lint: ## Checks import formatting and runs golangci-lint (requires goimports).
@echo "====> $@"
@files=$$(goimports -local "$(MODULE)" -l .) || exit $$?; \
if [ -n "$$files" ]; then \
printf '%s\n' "$$files"; \
echo "Run 'make imports' to fix import formatting."; \
exit 1; \
fi
golangci-lint run --timeout=15m ./...

# Extend lint from Makefile.custom.mk without replacing its generated recipe.
.PHONY: lint-custom
lint: lint-custom

.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...
Expand Down Expand Up @@ -141,8 +167,8 @@ test: ## Runs go test with default values (race detector when a C toolchain is a
go test -ldflags "$(LDFLAGS)" $(RACE) ./...

.PHONY: build-docker
build-docker: build-linux ## Builds docker image to registry.
build-docker: $(APPLICATION)-linux-$(ARCH) ## Builds docker image to registry for the host architecture.
$(REQUIRE_VERSION)
@echo "====> $@"
cp -a $(APPLICATION)-linux $(APPLICATION)
@$(call INSTALL_BINARY,$<,$(APPLICATION))
docker build -t ${APPLICATION}:${VERSION} .
9 changes: 5 additions & 4 deletions cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# devctl
#
# https://github.com/giantswarm/devctl/blob/88a5399393f41a2aacc8da4ed639e5a0107d85e9/pkg/gen/input/workflows/internal/file/cliff.toml.template
# https://github.com/giantswarm/devctl/blob/1fe81de8e59667b8a9aa1f3f55beae176492f6a9/pkg/gen/input/workflows/internal/file/cliff.toml.template
#
# git-cliff config for the push-based auto-release flow.
#
Expand Down Expand Up @@ -96,9 +96,10 @@ commit_preprocessors = [
# ships. git-cliff decides the bump from the commits that are NOT skipped: a
# breaking change bumps the major, `feat` the minor, every other type at least
# the patch. A skipped commit is left out of the release notes and of the
# bump, so a docs-, style- or test-only push to main computes the current
# version and the workflow tags nothing; the change ships with the next
# release. `chore` and `ci` keep releasing: a `chore(deps)` bump changes what
# bump, so a docs-, style- or test-only push outside a candidate cycle computes
# the current version and the workflow tags nothing. During a cycle the workflow
# lets a new test commit advance an existing candidate without changing its
# version or notes. `chore` and `ci` keep releasing: a `chore(deps)` bump changes what
# ships, a `ci` change how it is built.
commit_parsers = [
{ message = "^feat", group = "Added" },
Expand Down
2 changes: 1 addition & 1 deletion renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// without an ats/ Pipfile, so it is safe to extend for all generated-CI repos.
'github>giantswarm/renovate-presets:tests-ats.json5',
],
// Our own bots commit onto Renovate branches. The giantswarm-release
// Our automation commits onto Renovate branches. The giantswarm-release
// GitHub App pushes what the generated workflows produce
// (zz_generated.helm-docs-regen.yaml, the update-chart and
// sync-from-upstream flows); taylorbot <dev@giantswarm.io> did so before
Expand Down
Loading