feat(ci): scripts/ci 基座(_env/lib-forgejo/notify)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-07-05 23:49:59 +08:00
parent 6be777dff5
commit b8343a8788
3 changed files with 172 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# _env.sh — shared CI mirror env + tag-version helper. `source` this from other
# scripts; do not execute directly. Idempotent: only sets vars if not already
# provided by the environment (e.g. workflow-level overrides).
export GOPROXY="${GOPROXY:-https://goproxy.cn,direct}"
export PUB_HOSTED_URL="${PUB_HOSTED_URL:-https://pub.flutter-io.cn}"
export FLUTTER_STORAGE_BASE_URL="${FLUTTER_STORAGE_BASE_URL:-https://storage.flutter-io.cn}"
# Forgejo/Gitea repo coordinates (used by lib-forgejo.sh). Secrets
# FORGEJO_TOKEN / FORGEJO_URL are injected by the CI runner, not set here.
export FORGEJO_REPO="${FORGEJO_REPO:-wangjia/pangolin}"
# Ensure Homebrew tools are on PATH (macOS runners); harmless elsewhere.
case ":${PATH}:" in
*":/opt/homebrew/bin:"*) ;;
*) export PATH="/opt/homebrew/bin:${PATH}" ;;
esac
# ver_from_tag <prefix> <ref>
# Strips an optional "refs/tags/" prefix, then the "<prefix>-v" prefix,
# leaving a bare semver. Uses parameter expansion only (no command
# substitution). Examples:
# ver_from_tag server server-v1.2.3 -> 1.2.3
# ver_from_tag server refs/tags/server-v1.2.3 -> 1.2.3
ver_from_tag() {
local prefix="$1" ref="$2"
ref="${ref#refs/tags/}"
ref="${ref#"${prefix}"-v}"
printf '%s' "$ref"
}