Compare commits
7 Commits
83723bd989
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 662db558bd | |||
| c5cd0f0430 | |||
| 69fe519f7a | |||
| 6f1913a542 | |||
| cb84cb354d | |||
| 43d4a2b35e | |||
| 03513bb1e4 |
@@ -12,6 +12,10 @@ inputs:
|
|||||||
description: Override image tag (defaults to standard tags)
|
description: Override image tag (defaults to standard tags)
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
|
checkout_ref:
|
||||||
|
description: Git ref to checkout before build (e.g. refs/tags/v1.2.3)
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
dockerfile:
|
dockerfile:
|
||||||
description: Path to Dockerfile
|
description: Path to Dockerfile
|
||||||
required: false
|
required: false
|
||||||
@@ -42,6 +46,7 @@ runs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
fetch-tags: true
|
fetch-tags: true
|
||||||
|
ref: ${{ inputs.checkout_ref != '' && inputs.checkout_ref || '' }}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|||||||
10
.github/actions/build-and-push/action.yaml
vendored
10
.github/actions/build-and-push/action.yaml
vendored
@@ -12,6 +12,10 @@ inputs:
|
|||||||
description: Override image tag (defaults to standard tags)
|
description: Override image tag (defaults to standard tags)
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
|
checkout_ref:
|
||||||
|
description: Git ref to checkout before build (e.g. refs/tags/v1.2.3)
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
dockerfile:
|
dockerfile:
|
||||||
description: Path to Dockerfile
|
description: Path to Dockerfile
|
||||||
required: false
|
required: false
|
||||||
@@ -24,6 +28,10 @@ inputs:
|
|||||||
description: Push image after build
|
description: Push image after build
|
||||||
required: false
|
required: false
|
||||||
default: "true"
|
default: "true"
|
||||||
|
additional_build_args:
|
||||||
|
description: Additional Docker build args as newline-separated KEY=VALUE pairs
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
registry_username:
|
registry_username:
|
||||||
description: Registry username
|
description: Registry username
|
||||||
required: true
|
required: true
|
||||||
@@ -38,6 +46,7 @@ runs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
fetch-tags: true
|
fetch-tags: true
|
||||||
|
ref: ${{ inputs.checkout_ref != '' && inputs.checkout_ref || '' }}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -108,3 +117,4 @@ runs:
|
|||||||
VITE_KEYCLOAK_CLIENT_ID=${{ env.VITE_KEYCLOAK_CLIENT_ID != '' && env.VITE_KEYCLOAK_CLIENT_ID || vars.VITE_KEYCLOAK_CLIENT_ID }}
|
VITE_KEYCLOAK_CLIENT_ID=${{ env.VITE_KEYCLOAK_CLIENT_ID != '' && env.VITE_KEYCLOAK_CLIENT_ID || vars.VITE_KEYCLOAK_CLIENT_ID }}
|
||||||
VITE_BASE_PATH=${{ env.VITE_BASE_PATH != '' && env.VITE_BASE_PATH || vars.VITE_BASE_PATH }}
|
VITE_BASE_PATH=${{ env.VITE_BASE_PATH != '' && env.VITE_BASE_PATH || vars.VITE_BASE_PATH }}
|
||||||
VITE_ADMIN_API_BASE=${{ env.VITE_ADMIN_API_BASE != '' && env.VITE_ADMIN_API_BASE || vars.VITE_ADMIN_API_BASE }}
|
VITE_ADMIN_API_BASE=${{ env.VITE_ADMIN_API_BASE != '' && env.VITE_ADMIN_API_BASE || vars.VITE_ADMIN_API_BASE }}
|
||||||
|
${{ inputs.additional_build_args }}
|
||||||
|
|||||||
212
.github/actions/bump-version/action.yaml
vendored
212
.github/actions/bump-version/action.yaml
vendored
@@ -5,6 +5,10 @@ inputs:
|
|||||||
description: Node.js version to use
|
description: Node.js version to use
|
||||||
required: false
|
required: false
|
||||||
default: "24"
|
default: "24"
|
||||||
|
release_line:
|
||||||
|
description: Release line for dev builds (e.g. 2.4 or 2.4.1) when it cannot be derived from the branch or PR target
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
gitea_token:
|
gitea_token:
|
||||||
description: Token for checkout/push (optional)
|
description: Token for checkout/push (optional)
|
||||||
required: false
|
required: false
|
||||||
@@ -34,25 +38,167 @@ runs:
|
|||||||
with:
|
with:
|
||||||
node-version: ${{ inputs.node_version }}
|
node-version: ${{ inputs.node_version }}
|
||||||
|
|
||||||
- name: Bump patch version and tag
|
- name: Bump version and tag
|
||||||
id: bump
|
id: bump
|
||||||
shell: bash
|
shell: bash
|
||||||
|
env:
|
||||||
|
INPUT_RELEASE_LINE: ${{ inputs.release_line }}
|
||||||
run: |
|
run: |
|
||||||
EXISTING_TAG="$(git tag --points-at HEAD "v*" | head -n 1)"
|
set -euo pipefail
|
||||||
if [ -n "${EXISTING_TAG}" ]; then
|
|
||||||
echo "Tag ${EXISTING_TAG} already points at this commit; skipping bump."
|
REF="${GITHUB_HEAD_REF:-${GITEA_HEAD_REF:-${GITHUB_REF:-${GITEA_REF:-}}}}"
|
||||||
echo "tag=${EXISTING_TAG}" >> "${GITHUB_OUTPUT}"
|
BASE_REF="${GITHUB_BASE_REF:-${GITEA_BASE_REF:-}}"
|
||||||
exit 0
|
BRANCH="${REF#refs/heads/}"
|
||||||
|
BASE_BRANCH="${BASE_REF#refs/heads/}"
|
||||||
|
|
||||||
|
if [[ -z "${BRANCH}" ]]; then
|
||||||
|
echo "Unable to determine branch from workflow context." >&2
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
REF="${GITHUB_REF:-${GITEA_REF}}"
|
|
||||||
BRANCH="${REF#refs/heads/}"
|
|
||||||
git fetch origin "${BRANCH}" --tags
|
git fetch origin "${BRANCH}" --tags
|
||||||
git checkout "${BRANCH}"
|
git checkout "${BRANCH}"
|
||||||
git pull --ff-only origin "${BRANCH}"
|
git pull --ff-only origin "${BRANCH}"
|
||||||
BRANCH_SAFE="$(echo "${BRANCH}" | tr '/[:space:].' '-' | tr -cd '[:alnum:]_-')"
|
|
||||||
BRANCH_SAFE="$(echo "${BRANCH_SAFE}" | sed 's/^-*//;s/-*$//')"
|
set_version() {
|
||||||
BRANCH_SAFE="${BRANCH_SAFE:-unknown}"
|
npm version "$1" --no-git-tag-version --allow-same-version >/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
read_package_version() {
|
||||||
|
node -p "require('./package.json').version"
|
||||||
|
}
|
||||||
|
|
||||||
|
normalize_release_base() {
|
||||||
|
local value="$1"
|
||||||
|
if [[ "${value}" =~ ^v?([0-9]+)\.([0-9]+)$ ]]; then
|
||||||
|
echo "${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.0"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if [[ "${value}" =~ ^v?([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
|
||||||
|
echo "${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
extract_release_base() {
|
||||||
|
local ref_name="$1"
|
||||||
|
local normalized
|
||||||
|
if [[ "${ref_name}" =~ ^release/(.+)$ ]]; then
|
||||||
|
if normalized="$(normalize_release_base "${BASH_REMATCH[1]}")"; then
|
||||||
|
echo "${normalized}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
infer_release_base_from_ancestor_release_branch() {
|
||||||
|
local best_release_base=""
|
||||||
|
local best_commit_time=0
|
||||||
|
local remote_ref
|
||||||
|
local release_branch
|
||||||
|
local release_base
|
||||||
|
local commit_time
|
||||||
|
|
||||||
|
# Best effort: not every repository has release branches.
|
||||||
|
git fetch --no-tags origin "+refs/heads/release/*:refs/remotes/origin/release/*" >/dev/null 2>&1 || true
|
||||||
|
|
||||||
|
while IFS= read -r remote_ref; do
|
||||||
|
release_branch="${remote_ref#origin/}"
|
||||||
|
if ! release_base="$(extract_release_base "${release_branch}")"; 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/*)
|
||||||
|
|
||||||
|
if [[ -n "${best_release_base}" ]]; then
|
||||||
|
echo "${best_release_base}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve_release_base() {
|
||||||
|
local package_version
|
||||||
|
local normalized
|
||||||
|
local inferred_release_base
|
||||||
|
|
||||||
|
if [[ -n "${INPUT_RELEASE_LINE}" ]]; then
|
||||||
|
if ! normalized="$(normalize_release_base "${INPUT_RELEASE_LINE}")"; then
|
||||||
|
echo "Invalid release_line input '${INPUT_RELEASE_LINE}'. Expected format: <major>.<minor> or <major>.<minor>.<patch>" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "${normalized}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if extract_release_base "${BRANCH}" >/dev/null; then
|
||||||
|
extract_release_base "${BRANCH}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${BASE_BRANCH}" ]] && extract_release_base "${BASE_BRANCH}" >/dev/null; then
|
||||||
|
extract_release_base "${BASE_BRANCH}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if inferred_release_base="$(infer_release_base_from_ancestor_release_branch)"; then
|
||||||
|
echo "${inferred_release_base}"
|
||||||
|
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
|
||||||
|
|
||||||
|
echo "Unable to determine release base for branch '${BRANCH}'. Use release/<major>.<minor>[.<patch>], provide inputs.release_line, or ensure package.json contains a semantic version." >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
next_beta_version() {
|
||||||
|
local release_base="$1"
|
||||||
|
local escaped_base
|
||||||
|
local highest_beta
|
||||||
|
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
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
case "${BRANCH}" in
|
case "${BRANCH}" in
|
||||||
main)
|
main)
|
||||||
COMMIT_MSG="$(git log -1 --pretty=%B)"
|
COMMIT_MSG="$(git log -1 --pretty=%B)"
|
||||||
@@ -66,42 +212,36 @@ runs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${TARGET_VERSION}" ]]; then
|
if [[ -n "${TARGET_VERSION}" ]]; then
|
||||||
npm version "${TARGET_VERSION}" --no-git-tag-version --allow-same-version
|
set_version "${TARGET_VERSION}"
|
||||||
BUMP_CMD="npm version patch --no-git-tag-version"
|
|
||||||
else
|
else
|
||||||
npm version patch --no-git-tag-version
|
npm version patch --no-git-tag-version >/dev/null
|
||||||
BUMP_CMD="npm version patch --no-git-tag-version"
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
develop)
|
release/*)
|
||||||
npm version prerelease --preid=dev --no-git-tag-version
|
RELEASE_BASE="$(resolve_release_base)"
|
||||||
BUMP_CMD="npm version prerelease --preid=dev --no-git-tag-version"
|
set_version "$(next_beta_version "${RELEASE_BASE}")"
|
||||||
;;
|
|
||||||
release*)
|
|
||||||
RELEASE_VERSION=""
|
|
||||||
if [[ "${BRANCH}" =~ ^release/v?([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
|
|
||||||
RELEASE_VERSION="${BASH_REMATCH[1]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n "${RELEASE_VERSION}" ]]; then
|
|
||||||
npm version "${RELEASE_VERSION}-rc.0" --no-git-tag-version --allow-same-version
|
|
||||||
BUMP_CMD="npm version prerelease --preid=rc --no-git-tag-version"
|
|
||||||
else
|
|
||||||
npm version prerelease --preid=rc-${BRANCH_SAFE} --no-git-tag-version
|
|
||||||
BUMP_CMD="npm version prerelease --preid=rc-${BRANCH_SAFE} --no-git-tag-version"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
npm version prerelease --preid=nightly-${BRANCH_SAFE} --no-git-tag-version
|
RELEASE_BASE="$(resolve_release_base)"
|
||||||
BUMP_CMD="npm version prerelease --preid=nightly-${BRANCH_SAFE} --no-git-tag-version"
|
set_version "$(next_dev_version "${RELEASE_BASE}")"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
VERSION="$(node -p "require('./package.json').version")"
|
VERSION="$(node -p "require('./package.json').version")"
|
||||||
while git rev-parse -q --verify "refs/tags/v${VERSION}" >/dev/null; do
|
while git rev-parse -q --verify "refs/tags/v${VERSION}" >/dev/null; do
|
||||||
echo "Tag v${VERSION} already exists; trying next version."
|
echo "Tag v${VERSION} already exists; trying next version."
|
||||||
${BUMP_CMD}
|
case "${BRANCH}" in
|
||||||
VERSION="$(node -p "require('./package.json').version")"
|
main)
|
||||||
|
npm version patch --no-git-tag-version >/dev/null
|
||||||
|
;;
|
||||||
|
release/*)
|
||||||
|
set_version "$(next_beta_version "${RELEASE_BASE}")"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
set_version "$(next_dev_version "${RELEASE_BASE}")"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
VERSION="$(read_package_version)"
|
||||||
done
|
done
|
||||||
|
|
||||||
if git diff --quiet; then
|
if git diff --quiet; then
|
||||||
|
|||||||
56
README.md
56
README.md
@@ -4,6 +4,47 @@ This repo provides reusable Gitea Actions as composite actions that can be refer
|
|||||||
|
|
||||||
### Bump Version
|
### Bump Version
|
||||||
|
|
||||||
|
Creates or updates the version in `package.json`, commits it, creates a matching Git tag, and pushes both.
|
||||||
|
|
||||||
|
Inputs:
|
||||||
|
|
||||||
|
- `node_version`: Node.js version to use. Default: `24`
|
||||||
|
- `release_line`: optional release line for dev builds. Format: `<major>.<minor>` or `<major>.<minor>.<patch>`. Overrides branch, PR target, inferred ancestor release branch, and `package.json`.
|
||||||
|
- `gitea_token`: optional token used for checkout and push
|
||||||
|
|
||||||
|
Branch and tag rules:
|
||||||
|
|
||||||
|
- `main`: creates release tags from the latest commit message (`release/x.y.z`, `release/x.y`, `hotfix/x.y.z`) or falls back to a patch bump.
|
||||||
|
- `release/<major>.<minor>` or `release/<major>.<minor>.<patch>`: creates the next beta tag for that release base, e.g. `v2.4.0-beta.3` or `v2.4.1-beta.3`.
|
||||||
|
- all other branches: create a dev tag for the resolved release base using a UTC timestamp, e.g. `v2.4.0-dev.20260314153045`.
|
||||||
|
|
||||||
|
Dev release line resolution order:
|
||||||
|
|
||||||
|
- `inputs.release_line`
|
||||||
|
- current branch if it matches `release/<major>.<minor>` or `release/<major>.<minor>.<patch>`
|
||||||
|
- PR target branch if it matches `release/<major>.<minor>` or `release/<major>.<minor>.<patch>`
|
||||||
|
- newest ancestor branch from `origin/release/*` (for feature branches created from release branches outside PR context)
|
||||||
|
- `major.minor` from `package.json`
|
||||||
|
|
||||||
|
If no release line can be resolved for a dev build, the action fails intentionally.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
Commit message examples on `main`:
|
||||||
|
|
||||||
|
- `release/2.4.0` -> `v2.4.0`
|
||||||
|
- `release/2.4` -> `v2.4.0`
|
||||||
|
- `hotfix/2.4.1` -> `v2.4.1`
|
||||||
|
|
||||||
|
Branch examples:
|
||||||
|
|
||||||
|
- `release/2.4` -> next `v2.4.0-beta.N`
|
||||||
|
- `release/v2.4.1` -> next `v2.4.1-beta.N`
|
||||||
|
- feature branch in a PR to `release/2.4` -> `v2.4.0-dev.<UTC_TIMESTAMP>`
|
||||||
|
- feature branch created from `release/v2.4.1` (without PR base) -> `v2.4.1-dev.<UTC_TIMESTAMP>` when the release branch tip is an ancestor
|
||||||
|
- feature branch outside a PR with `package.json` version `2.4.0` -> `v2.4.0-dev.<UTC_TIMESTAMP>`
|
||||||
|
- feature branch outside a PR with `release_line: 2.4` -> `v2.4.0-dev.<UTC_TIMESTAMP>`
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -18,6 +59,21 @@ jobs:
|
|||||||
gitea_token: ${{ secrets.GITEA_TOKEN }}
|
gitea_token: ${{ secrets.GITEA_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Feature branch outside a PR:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
bump-version:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- uses: tanztee/ci-cd/.github/actions/bump-version@main
|
||||||
|
with:
|
||||||
|
gitea_token: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
release_line: 2.4
|
||||||
|
```
|
||||||
|
|
||||||
### Build and Push Docker Image
|
### Build and Push Docker Image
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|||||||
Reference in New Issue
Block a user