3 Commits
Author SHA1 Message Date
tuandClaude Fable 5.1 8c5d7f26bb ci: Plugin-Images mit oumta-ci und Secret oumta_ci_token veröffentlichen
ci/woodpecker/pr/plugins Pipeline was successful
ci/woodpecker/push/plugins Pipeline was successful
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-30 17:41:35 +01:00
tuandClaude Opus 5.5 3ea9d0308d ci: plugin-docker-buildx:6 wie in WOODPECKER_PLUGINS_PRIVILEGED
Die Liste vergleicht mit Tag exakt, :6.1.2 liefe nicht privilegiert.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 17:40:06 +01:00
tuandClaude Opus 5.5 14e760b6eb feat: Woodpecker-Plugin bump (Entwurf)
Setzt Version und Tag für den gepushten Branch wie bump-version, dazu
hotfix/* -> beta, Bump nur des auslösenden Commits, [skip ci] im
Bump-Commit. Nutzer und Autor oumta-ci, Secret oumta_ci_token
(oumta-deploy docs/zugaenge.md). plugins.yaml baut beide Plugins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 17:35:17 +01:00
3 changed files with 171 additions and 124 deletions

No files matched your search

+11 -18
View File
@@ -120,9 +120,7 @@ jobs:
## Woodpecker plugins ## Woodpecker plugins
Plugins are Docker images built from `woodpecker/<name>/` by `.woodpecker/plugins.yaml`. A tag `<name>-vX.Y.Z` publishes `git.uesome.de/actions/ci-cd/<name>:vX.Y.Z`; pipelines pin that version. The push uses `oumta-ci` with the Woodpecker secret `oumta_ci_token`, so `oumta-ci` needs package write access in the org `actions`. Plugins are Docker images built from `woodpecker/<name>/` by `.woodpecker/plugins.yaml`. A tag `<name>-vX.Y.Z` publishes `git.uesome.de/actions/ci-cd/<name>:vX.Y.Z`; pipelines pin that version.
The secret `oumta_ci_token` holds the one token `oumta-ci` writes with. Limit it in Woodpecker to the images `woodpeckerci/plugin-docker-buildx:6`, `git.uesome.de/actions/ci-cd/bump` and `git.uesome.de/actions/ci-cd/deploy` and to the events `push`, `tag` and `manual` (zugaenge.md in oumta-deploy).
### deploy ### deploy
@@ -154,8 +152,6 @@ steps:
registry: git.uesome.de registry: git.uesome.de
repo: git.uesome.de/tanztee/oumta-auth repo: git.uesome.de/tanztee/oumta-auth
tags: ${CI_COMMIT_TAG} tags: ${CI_COMMIT_TAG}
build_args:
VERSION: ${CI_COMMIT_TAG##v}
username: oumta-ci username: oumta-ci
password: password:
from_secret: oumta_ci_token from_secret: oumta_ci_token
@@ -173,23 +169,20 @@ steps:
### bump ### bump
Derives the next version for the pushed branch and pushes it as a tag on the triggering commit. There is no version commit: the build takes the version from the tag (`CI_COMMIT_TAG`, e.g. as build arg `VERSION: ${CI_COMMIT_TAG##v}`), `package.json` stays untouched. The tag event then starts the build. Sets the version for the pushed branch in `package.json`, commits it as `update version: vX [skip ci]`, tags it and pushes branch and tag. The tag event then starts the build; `[skip ci]` only suppresses push and pull_request events.
- `release/X.Y[.Z]`, `hotfix/X.Y.Z`: next `vX.Y.Z-beta.N` of that line (D8). A hotfix needs a patch number. - `main`: release from the commit message (`release/x.y[.z]`, `hotfix/x.y.z`), otherwise a patch bump
- `production/*`: no bump, the step fails. A release is a retag of a beta image (D9). - `release/*`, `hotfix/*`: next `vX.Y.Z-beta.N`
- the branch in `release_branch` (repos without majors, e.g. oumta-keyklo `main`): next stable `vX.Y.Z`, the highest existing patch of the line plus one - any other branch: `vX.Y.Z-dev.<UTC timestamp>`; the release line comes from `release_line`, the newest ancestor `release/*` branch, or `package.json`
- any other branch: `vX.Y.Z-dev.<UTC timestamp>`; the line comes from `release_line`, the branch name, the nearest `release/*` or `hotfix/*` branch (newest merge base), or `major.minor` from `package.json`
If the stable tag of a line exists (`v2.4.0` after the release), the next patch of that line is used (`v2.4.1-beta.0`, `v2.4.1-dev.…`). Only the commit that triggered the pipeline is bumped; if the branch moved on, the step exits without a bump and the newer pipeline takes over.
Only the commit that triggered the pipeline is tagged; if the branch moved on, the step exits without a tag and the newer pipeline takes over. A commit that already carries a `v*` tag is not tagged again, so a re-run does not build twice.
Settings: Settings:
- `git_token` (required): token of `oumta-ci` (`oumta_ci_token`), write access to the repo - `git_token` (required): token with write access to the repo (`oumta_ci_token`)
- `git_user`: default `oumta-ci` - `git_user`: default `oumta-ci`
- `release_branch`: optional, branch that gets stable tags instead of dev tags - `release_line`: optional, `<major>.<minor>[.<patch>]`
- `release_line`: optional, `<major>.<minor>[.<patch>]`, overrides every other rule - `author_name`, `author_email`: default `oumta-ci`, `oumta-ci@noreply.git.uesome.de`
- `remote`: default `CI_REPO_CLONE_URL` - `remote`: default `CI_REPO_CLONE_URL`
Example: Example:
@@ -197,12 +190,12 @@ Example:
```yaml ```yaml
when: when:
- event: push - event: push
branch: ['feature/**', 'release/**', 'hotfix/**'] branch: [develop, 'feature/**', 'release/**', 'hotfix/**']
- event: manual - event: manual
steps: steps:
- name: bump - name: bump
image: git.uesome.de/actions/ci-cd/bump:v2.0.0 image: git.uesome.de/actions/ci-cd/bump:v1.0.0
settings: settings:
git_token: git_token:
from_secret: oumta_ci_token from_secret: oumta_ci_token
+2 -2
View File
@@ -1,5 +1,5 @@
# Woodpecker plugin: derives the next version and pushes it as a tag # Woodpecker plugin: bumps the version in package.json, tags and pushes
FROM alpine:3.20 FROM node:24-alpine
RUN apk add --no-cache bash git ca-certificates RUN apk add --no-cache bash git ca-certificates
COPY bump.sh /usr/local/bin/bump.sh COPY bump.sh /usr/local/bin/bump.sh
ENTRYPOINT ["/usr/local/bin/bump.sh"] ENTRYPOINT ["/usr/local/bin/bump.sh"]
+158 -104
View File
@@ -1,13 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Woodpecker plugin "bump": derives the next version for the pushed branch and # Woodpecker plugin "bump": sets the version for the pushed branch, commits it
# pushes it as a tag on the triggering commit. No commit is made; the build # with [skip ci], tags it and pushes both. The tag event then starts the build;
# takes the version from the tag (CI_COMMIT_TAG). The tag event then starts # [skip ci] only suppresses push and pull_request events, not tag events.
# the build.
# #
# release/X.Y[.Z], hotfix/X.Y.Z next vX.Y.Z-beta.N (D8) # main release from the commit message (release/x.y[.z],
# production/* nothing: releases are retags (D9) # hotfix/x.y.z), otherwise a patch bump
# settings.release_branch next free vX.Y.Z (repos without majors) # release/*, hotfix/* next vX.Y.Z-beta.N
# any other branch vX.Y.Z-dev.<UTC timestamp> # any other branch vX.Y.Z-dev.<UTC timestamp>
set -euo pipefail set -euo pipefail
die() { echo "bump: $*" >&2; exit 1; } die() { echo "bump: $*" >&2; exit 1; }
@@ -16,13 +15,11 @@ BRANCH=${CI_COMMIT_BRANCH:?CI_COMMIT_BRANCH is missing (push event only)}
SHA=${CI_COMMIT_SHA:?CI_COMMIT_SHA is missing} SHA=${CI_COMMIT_SHA:?CI_COMMIT_SHA is missing}
REMOTE=${PLUGIN_REMOTE:-${CI_REPO_CLONE_URL:?CI_REPO_CLONE_URL is missing}} REMOTE=${PLUGIN_REMOTE:-${CI_REPO_CLONE_URL:?CI_REPO_CLONE_URL is missing}}
GIT_USER=${PLUGIN_GIT_USER:-oumta-ci} GIT_USER=${PLUGIN_GIT_USER:-oumta-ci}
RELEASE_LINE=${PLUGIN_RELEASE_LINE:-}
RELEASE_BRANCH=${PLUGIN_RELEASE_BRANCH:-}
[[ -n ${PLUGIN_GIT_TOKEN:-} ]] || die "settings.git_token is missing" [[ -n ${PLUGIN_GIT_TOKEN:-} ]] || die "settings.git_token is missing"
INPUT_RELEASE_LINE=${PLUGIN_RELEASE_LINE:-}
case $BRANCH in export GIT_AUTHOR_NAME=${PLUGIN_AUTHOR_NAME:-oumta-ci} GIT_AUTHOR_EMAIL=${PLUGIN_AUTHOR_EMAIL:-oumta-ci@noreply.git.uesome.de}
production/*) die "no bump on $BRANCH: a release is a retag of a beta image (D9)" ;; export GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
esac
# Token only via credential helper, never in a URL or config, so no log shows it # Token only via credential helper, never in a URL or config, so no log shows it
export GIT_USER PLUGIN_GIT_TOKEN export GIT_USER PLUGIN_GIT_TOKEN
@@ -36,123 +33,180 @@ if [[ $(git rev-parse --is-shallow-repository) == true ]]; then
fi fi
git fetch --quiet --tags --force origin "+refs/heads/*:refs/remotes/origin/*" git fetch --quiet --tags --force origin "+refs/heads/*:refs/remotes/origin/*"
# Tag exactly the commit that triggered the pipeline. A newer push on the # Bump exactly the commit that triggered the pipeline. A newer push on the
# branch starts its own pipeline, so this one steps aside. # branch starts its own pipeline, so this one steps aside.
head=$(git rev-parse -q --verify "origin/$BRANCH") || die "$BRANCH no longer exists on origin" if [[ $(git rev-parse "origin/$BRANCH") != "$SHA" ]]; then
if [[ $head != "$SHA" ]]; then
echo "bump: $BRANCH moved past ${SHA:0:8}, the newer pipeline bumps" echo "bump: $BRANCH moved past ${SHA:0:8}, the newer pipeline bumps"
exit 0 exit 0
fi fi
git checkout --quiet "$SHA" git checkout --quiet -B "$BRANCH" "$SHA"
# A re-run must not produce a second tag and a second build for the same commit. set_version() {
if existing=$(git tag --points-at HEAD 'v*' | head -n 1) && [[ -n $existing ]]; then npm version "$1" --no-git-tag-version --allow-same-version >/dev/null
echo "bump: ${SHA:0:8} already carries $existing, nothing to do"
exit 0
fi
tag_exists() { git rev-parse -q --verify "refs/tags/v$1" >/dev/null; }
# "2.4" or "v2.4.1" -> "2.4.0" / "2.4.1"; fails for anything else
parse_line() {
[[ $1 =~ ^v?([0-9]+)\.([0-9]+)(\.([0-9]+))?$ ]] || return 1
echo "${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[4]:-0}"
} }
# release/2.4 -> 2.4.0, hotfix/2.4.1 -> 2.4.1; a hotfix without a patch fails read_package_version() {
line_of_branch() { node -p "require('./package.json').version"
local kind name
[[ $1 =~ ^(release|hotfix)/(.+)$ ]] || return 1
kind=${BASH_REMATCH[1]} name=${BASH_REMATCH[2]}
[[ $kind == hotfix && ! $name =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]] && return 1
parse_line "$name"
} }
# The release or hotfix branch whose merge base with HEAD is the newest, i.e. normalize_release_base() {
# the line this commit was branched from most recently. On a tie (a hotfix local value="$1"
# forked from the same commit as the release) the lower line wins. if [[ "${value}" =~ ^v?([0-9]+)\.([0-9]+)$ ]]; then
line_of_nearest_branch() { echo "${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.0"
local ref line base return 0
while read -r ref; do
line=$(line_of_branch "${ref#origin/}") || continue
base=$(git merge-base "$ref" HEAD 2>/dev/null) || continue
echo "$(git show -s --format=%ct "$base") ${line//./ } $line"
done < <(git for-each-ref --format='%(refname:short)' refs/remotes/origin/release/ refs/remotes/origin/hotfix/) |
sort -k1,1nr -k2,2n -k3,3n -k4,4n | head -n 1 | { read -r _ _ _ _ line && echo "$line"; }
}
# major.minor.0 from the version in package.json, if there is one
line_of_package() {
local version
[[ -f package.json ]] || return 1
version=$(sed -nE 's/^[[:space:]]*"version"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/p' package.json | head -n 1)
version=$(parse_line "${version%%[-+]*}") || return 1
echo "${version%.*}.0"
}
# The line for this branch: setting, branch name, nearest release/hotfix
# branch, else major.minor of package.json.
resolve_line() {
if [[ -n $RELEASE_LINE ]]; then
parse_line "$RELEASE_LINE" || die "invalid settings.release_line '$RELEASE_LINE', expected <major>.<minor>[.<patch>]"
return
fi fi
line_of_branch "$BRANCH" && return if [[ "${value}" =~ ^v?([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
line_of_nearest_branch && return echo "${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}"
line_of_package && return return 0
die "no release line for '$BRANCH': use settings.release_line or a semantic version in package.json" fi
return 1
} }
# The next stable version of a line: highest existing vX.Y.Z plus one patch. extract_release_base() {
next_stable() { local ref_name="$1"
local line=$1 highest local normalized
highest=$(git tag --list "v${line%.*}.*" | sed -nE 's/^v[0-9]+\.[0-9]+\.([0-9]+)$/\1/p' | sort -n | tail -n 1) if [[ "${ref_name}" =~ ^(release|hotfix)/(.+)$ ]]; then
echo "${line%.*}.$(( ${highest:--1} + 1 ))" if normalized="$(normalize_release_base "${BASH_REMATCH[2]}")"; then
echo "${normalized}"
return 0
fi
fi
return 1
} }
# A line whose stable tag exists was released; the next patch is the open one. # Only release branches: a fresh hotfix branch is an ancestor of everything.
next_free_patch() { infer_release_base_from_ancestor_release_branch() {
local line=$1 patch local best_release_base=""
while tag_exists "$line"; do local best_commit_time=0
patch=${line##*.} local remote_ref
line=${line%.*}.$((patch + 1)) local release_base
done local commit_time
echo "$line"
while IFS= read -r remote_ref; do
if ! release_base="$(extract_release_base "${remote_ref#origin/}")"; then
continue
fi
if ! git merge-base --is-ancestor "$(git rev-parse "${remote_ref}")" HEAD; then
continue
fi
commit_time="$(git show -s --format=%ct "${remote_ref}")"
if [[ "${commit_time}" -gt "${best_commit_time}" ]]; then
best_commit_time="${commit_time}"
best_release_base="${release_base}"
fi
done < <(git for-each-ref --format='%(refname:short)' refs/remotes/origin/release/)
[[ -n "${best_release_base}" ]] && echo "${best_release_base}"
} }
next_beta() { resolve_release_base() {
local line=$1 highest local package_version
highest=$(git tag --list "v$line-beta.*" | sed -nE 's/^.*-beta\.([0-9]+)$/\1/p' | sort -n | tail -n 1) local normalized
echo "$line-beta.$(( ${highest:--1} + 1 ))"
if [[ -n "${INPUT_RELEASE_LINE}" ]]; then
normalized="$(normalize_release_base "${INPUT_RELEASE_LINE}")" ||
die "invalid settings.release_line '${INPUT_RELEASE_LINE}', expected <major>.<minor>[.<patch>]"
echo "${normalized}"
return 0
fi
if extract_release_base "${BRANCH}"; then
return 0
fi
if infer_release_base_from_ancestor_release_branch; then
return 0
fi
package_version="$(read_package_version)"
if [[ "${package_version}" =~ ^([0-9]+)\.([0-9]+)\.[0-9]+([-.].*)?$ ]]; then
echo "${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.0"
return 0
fi
die "no release base for '${BRANCH}': use release/<major>.<minor>[.<patch>], settings.release_line or a semantic version in package.json"
} }
next_dev() { next_beta_version() {
local line=$1 stamp local release_base="$1"
while :; do local escaped_base
stamp=$(date -u +%Y%m%d%H%M%S) local highest_beta
tag_exists "$line-dev.$stamp" || { echo "$line-dev.$stamp"; return; } escaped_base="$(printf '%s' "${release_base}" | sed 's/\./\\./g')"
highest_beta="$(
git tag --list "v${release_base}-beta.*" \
| sed -nE "s/^v${escaped_base}-beta\.([0-9]+)$/\\1/p" \
| sort -n \
| tail -n 1
)"
if [[ -z "${highest_beta}" ]]; then
echo "${release_base}-beta.0"
else
echo "${release_base}-beta.$((highest_beta + 1))"
fi
}
next_dev_version() {
local release_base="$1"
local timestamp
while true; do
timestamp="$(date -u +%Y%m%d%H%M%S)"
if ! git rev-parse -q --verify "refs/tags/v${release_base}-dev.${timestamp}" >/dev/null; then
echo "${release_base}-dev.${timestamp}"
return 0
fi
sleep 1 sleep 1
done done
} }
case $BRANCH in next_version() {
release/* | hotfix/*) case "${BRANCH}" in
line=$(line_of_branch "$BRANCH") || die "unusable branch name '$BRANCH', expected release/X.Y[.Z] or hotfix/X.Y.Z" main) npm version patch --no-git-tag-version >/dev/null ;;
VERSION=$(next_beta "$(next_free_patch "$line")") release/* | hotfix/*) set_version "$(next_beta_version "${RELEASE_BASE}")" ;;
;; *) set_version "$(next_dev_version "${RELEASE_BASE}")" ;;
*) esac
if [[ -n $RELEASE_BRANCH && $BRANCH == "$RELEASE_BRANCH" ]]; then }
VERSION=$(next_stable "$(resolve_line)")
case "${BRANCH}" in
main)
COMMIT_MSG="$(git log -1 --pretty=%B)"
TARGET_VERSION=""
if [[ "${COMMIT_MSG}" =~ release/v?([0-9]+\.[0-9]+\.[0-9]+) ]]; then
TARGET_VERSION="${BASH_REMATCH[1]}"
elif [[ "${COMMIT_MSG}" =~ release/([0-9]+)\.([0-9]+) ]]; then
TARGET_VERSION="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.0"
elif [[ "${COMMIT_MSG}" =~ hotfix/([0-9]+\.[0-9]+\.[0-9]+) ]]; then
TARGET_VERSION="${BASH_REMATCH[1]}"
fi
if [[ -n "${TARGET_VERSION}" ]]; then
set_version "${TARGET_VERSION}"
else else
VERSION=$(next_dev "$(next_free_patch "$(resolve_line)")") next_version
fi fi
;; ;;
*)
RELEASE_BASE="$(resolve_release_base)"
next_version
;;
esac esac
TAG=v$VERSION
git tag "$TAG" VERSION="$(read_package_version)"
if ! git push --quiet origin "refs/tags/$TAG"; then while git rev-parse -q --verify "refs/tags/v${VERSION}" >/dev/null; do
echo "bump: push of $TAG rejected, the newer pipeline bumps" echo "bump: tag v${VERSION} already exists, trying the next version"
next_version
VERSION="$(read_package_version)"
done
TAG="v${VERSION}"
if git diff --quiet; then
echo "bump: no version file changes, tagging the current commit"
else
git add package.json
[[ -f package-lock.json ]] && git add package-lock.json
git commit --quiet -m "update version: ${TAG} [skip ci]"
fi
git tag "${TAG}"
# Branch first, then the tag, so the tag never points at an unpushed commit.
# If the branch moved meanwhile, the push is rejected and nothing is tagged.
if ! git push --quiet origin "HEAD:refs/heads/${BRANCH}"; then
echo "bump: push to ${BRANCH} rejected, the newer pipeline bumps"
exit 0 exit 0
fi fi
echo "bump: $TAG on $BRANCH (${SHA:0:8})" git push --quiet origin "refs/tags/${TAG}"
echo "bump: ${TAG} on ${BRANCH}"