so, mal sehn
Some checks failed
Bump Version (via reusable workflow) / bump-version (push) Failing after 0s
Some checks failed
Bump Version (via reusable workflow) / bump-version (push) Failing after 0s
This commit is contained in:
80
.github/workflows/bump-version.yaml
vendored
Normal file
80
.github/workflows/bump-version.yaml
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
name: Bump Version
|
||||
run-name: ${{ gitea.actor }} runs patch update
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
node_version:
|
||||
description: Node.js version to use
|
||||
type: string
|
||||
default: "24"
|
||||
secrets:
|
||||
GITEA_TOKEN:
|
||||
description: Token for checkout/push (optional)
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
bump-version:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
token: ${{ secrets.GITEA_TOKEN }}
|
||||
|
||||
- name: Setup Git
|
||||
run: |
|
||||
git config user.name "CI Bot"
|
||||
git config user.email "ci@git.uesome.de"
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ inputs.node_version }}
|
||||
|
||||
- name: Bump patch version and tag
|
||||
run: |
|
||||
REF="${GITHUB_REF:-${GITEA_REF}}"
|
||||
BRANCH="${REF#refs/heads/}"
|
||||
git fetch origin "${BRANCH}" --tags
|
||||
git checkout "${BRANCH}"
|
||||
git pull --ff-only origin "${BRANCH}"
|
||||
BRANCH_SAFE="$(echo "${BRANCH}" | tr '/[:space:].' '-' | tr -cd '[:alnum:]_-')"
|
||||
BRANCH_SAFE="$(echo "${BRANCH_SAFE}" | sed 's/^-*//;s/-*$//')"
|
||||
BRANCH_SAFE="${BRANCH_SAFE:-unknown}"
|
||||
case "${BRANCH}" in
|
||||
main)
|
||||
COMMIT_MSG="$(git log -1 --pretty=%B)"
|
||||
TARGET_VERSION=""
|
||||
if [[ "${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
|
||||
if git rev-parse -q --verify "refs/tags/v${TARGET_VERSION}" >/dev/null; then
|
||||
echo "Tag v${TARGET_VERSION} already exists; skipping version bump."
|
||||
exit 0
|
||||
fi
|
||||
TAG="$(npm version "${TARGET_VERSION}" -m "update version: %s")"
|
||||
else
|
||||
TAG="$(npm version patch -m "update version: %s")"
|
||||
fi
|
||||
;;
|
||||
develop)
|
||||
TAG="$(npm version prerelease --preid=dev -m "update version: %s")"
|
||||
;;
|
||||
release*)
|
||||
TAG="$(npm version prerelease --preid=rc-${BRANCH_SAFE} -m "update version: %s")"
|
||||
;;
|
||||
*)
|
||||
TAG="$(npm version prerelease --preid=nightly-${BRANCH_SAFE} -m "update version: %s")"
|
||||
;;
|
||||
esac
|
||||
|
||||
git push origin HEAD
|
||||
git push origin "${TAG}"
|
||||
Reference in New Issue
Block a user