refactor(ci): organize workflow scripts and gate publish on main
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
git fetch --no-tags origin main
|
||||
|
||||
if git merge-base --is-ancestor "${GITHUB_SHA}" "origin/main"; then
|
||||
echo "is_on_main=true" >> "$GITHUB_OUTPUT"
|
||||
echo "Tagged commit ${GITHUB_SHA} is contained in origin/main."
|
||||
else
|
||||
echo "is_on_main=false" >> "$GITHUB_OUTPUT"
|
||||
echo "Tagged commit ${GITHUB_SHA} is not contained in origin/main. Skipping stable update."
|
||||
fi
|
||||
14
scripts/github/common/check-tagged-commit-on-main.sh
Normal file
14
scripts/github/common/check-tagged-commit-on-main.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
TARGET_SHA="${TARGET_SHA:-${GITHUB_SHA:?GITHUB_SHA must be set}}"
|
||||
|
||||
git fetch --no-tags origin main
|
||||
|
||||
if git merge-base --is-ancestor "${TARGET_SHA}" "origin/main"; then
|
||||
echo "is_on_main=true" >> "$GITHUB_OUTPUT"
|
||||
echo "Target commit ${TARGET_SHA} is contained in origin/main."
|
||||
else
|
||||
echo "is_on_main=false" >> "$GITHUB_OUTPUT"
|
||||
echo "Target commit ${TARGET_SHA} is not contained in origin/main. Skipping main-only action."
|
||||
fi
|
||||
0
scripts/github/mark-stable-if-highest-version.sh → scripts/github/mark-stable/mark-stable-if-highest-version.sh
Executable file → Normal file
0
scripts/github/mark-stable-if-highest-version.sh → scripts/github/mark-stable/mark-stable-if-highest-version.sh
Executable file → Normal file
0
scripts/github/wait-for-main-ci-success.sh → scripts/github/mark-stable/wait-for-main-ci-success.sh
Executable file → Normal file
0
scripts/github/wait-for-main-ci-success.sh → scripts/github/mark-stable/wait-for-main-ci-success.sh
Executable file → Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
WORKFLOW_RUN_SHA="${WORKFLOW_RUN_SHA:?WORKFLOW_RUN_SHA must be set}"
|
||||
|
||||
git checkout -f "${WORKFLOW_RUN_SHA}"
|
||||
git fetch --tags --force
|
||||
git tag --list 'stable' 'v*' --sort=version:refname | tail -n 20
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SHA="$(git rev-parse HEAD)"
|
||||
|
||||
V_TAG="$(git tag --points-at "${SHA}" --list 'v*' | sort -V | tail -n1)"
|
||||
if [[ -z "${V_TAG}" ]]; then
|
||||
echo "No version tag found for ${SHA}. Skipping publish."
|
||||
echo "should_publish=false" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
VERSION="${V_TAG#v}"
|
||||
|
||||
STABLE_SHA="$(git rev-parse -q --verify 'refs/tags/stable^{commit}' 2>/dev/null || true)"
|
||||
IS_STABLE=false
|
||||
[[ -n "${STABLE_SHA}" && "${STABLE_SHA}" == "${SHA}" ]] && IS_STABLE=true
|
||||
|
||||
{
|
||||
echo "should_publish=true"
|
||||
echo "version=${VERSION}"
|
||||
echo "is_stable=${IS_STABLE}"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
: "${OWNER:?OWNER must be set}"
|
||||
: "${VERSION:?VERSION must be set}"
|
||||
: "${IS_STABLE:?IS_STABLE must be set}"
|
||||
|
||||
bash scripts/build/publish.sh
|
||||
Reference in New Issue
Block a user