Some checks failed
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
64 lines
1.6 KiB
Bash
Executable File
64 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
START_DIR="$(pwd)"
|
|
echo "[bump-version] invoked from ${START_DIR}"
|
|
|
|
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
echo "[bump-version] repo root resolved to ${REPO_ROOT}"
|
|
cd "${REPO_ROOT}"
|
|
|
|
VERSION_FILE="./version"
|
|
if [ ! -f "${VERSION_FILE}" ]; then
|
|
if git cat-file -e "HEAD:version" 2>/dev/null; then
|
|
echo "[bump-version] version file missing in workspace, restoring from HEAD" >&2
|
|
git show "HEAD:version" > "${VERSION_FILE}"
|
|
else
|
|
echo "[bump-version] version file not found: ${VERSION_FILE}" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
CURRENT_VERSION="$(cat "${VERSION_FILE}")"
|
|
NEXT_VERSION="$(printf '%s' "${CURRENT_VERSION}" | awk -F. -v OFS=. '
|
|
function pad(value, width, result, i) {
|
|
result=value ""
|
|
if (length(result) >= width) {
|
|
return result
|
|
}
|
|
i = width - length(result)
|
|
while (i-- > 0) {
|
|
result = "0" result
|
|
}
|
|
return result
|
|
}
|
|
NF==1 { print ++$NF; next }
|
|
{
|
|
last = $NF + 1
|
|
$NF = pad(last, length($NF))
|
|
print
|
|
}')"
|
|
|
|
printf '%s\n' "${NEXT_VERSION}" > "${VERSION_FILE}"
|
|
echo "[bump-version] ${CURRENT_VERSION} -> ${NEXT_VERSION}"
|
|
|
|
git add "${VERSION_FILE}"
|
|
if git diff --cached --quiet; then
|
|
echo "[bump-version] no changes staged, skipping commit"
|
|
exit 0
|
|
fi
|
|
|
|
AUTHOR_NAME="${GIT_AUTHOR_NAME:-woodpecker}"
|
|
AUTHOR_EMAIL="${GIT_AUTHOR_EMAIL:-ci@sendico.io}"
|
|
git config user.name "${AUTHOR_NAME}"
|
|
git config user.email "${AUTHOR_EMAIL}"
|
|
|
|
git commit -m "chore(ci): bump version to ${NEXT_VERSION}"
|
|
|
|
BRANCH="${WOODPECKER_BRANCH:-}"
|
|
if [ -z "${BRANCH}" ] || [ "${BRANCH}" = "HEAD" ]; then
|
|
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
|
|
fi
|
|
|
|
git push origin "HEAD:${BRANCH}"
|