Upload files to "ggt"
https://github.com/go-gitea/gitea/blob/e8befe026853a90a9efca559ca9f9cac8b41fc88/contrib/upgrade.sh https://github.com/lutinglt/gitea-github-theme/blob/7c20142ab980addb2725628b997644fff73567f5/.github/workflows/release.yml
This commit is contained in:
1 parent
170b4f2eae
commit
58c5ab1dda
3 files changed
+254
No files matched your search
+64
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
readonly REPOSITORY="lutinglt/gitea-github-theme"
|
||||
readonly SCRIPT_DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
|
||||
usage() {
|
||||
printf 'Usage: %s <gitea-version> <custom-path>\n' "${0##*/}" >&2
|
||||
printf 'Example: %s 1.27.0 "$(gitea help | awk '\''/CustomPath:/ {print $2}'\'')"\n' "${0##*/}" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
require_command() {
|
||||
command -v "$1" >/dev/null 2>&1 || {
|
||||
printf 'Required command not found: %s\n' "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
[[ $# -eq 2 ]] || usage
|
||||
|
||||
gitea_version="$1"
|
||||
custom_path="$2"
|
||||
|
||||
if [[ -z "$custom_path" || "$custom_path" == *$'\n'* ]]; then
|
||||
printf 'CustomPath must be exactly one non-empty path.\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! "$gitea_version" =~ ^v?([0-9]+\.[0-9]+) ]]; then
|
||||
printf 'Unable to determine major.minor from Gitea version: %s\n' "$gitea_version" >&2
|
||||
exit 1
|
||||
fi
|
||||
release_prefix="v${BASH_REMATCH[1]}."
|
||||
|
||||
require_command curl
|
||||
require_command jq
|
||||
|
||||
theme_version="$(
|
||||
curl --connect-timeout 10 --fail --silent --show-error --location \
|
||||
"https://api.github.com/repos/${REPOSITORY}/releases" \
|
||||
| jq -r --arg prefix "$release_prefix" '
|
||||
[ .[]
|
||||
| select(.prerelease == false and (.tag_name | startswith($prefix)))
|
||||
| .tag_name
|
||||
]
|
||||
| first // empty
|
||||
'
|
||||
)"
|
||||
|
||||
if [[ -z "$theme_version" ]]; then
|
||||
printf 'No stable %s* theme release was found; removing any installed matching theme files.\n' "$release_prefix" >&2
|
||||
exec "$SCRIPT_DIRECTORY/install-gitea-github-theme.sh" --remove \
|
||||
"$custom_path/public/assets/css" \
|
||||
"$custom_path/templates" \
|
||||
"$custom_path/.gitea-github-theme-files"
|
||||
fi
|
||||
|
||||
exec "$SCRIPT_DIRECTORY/install-gitea-github-theme.sh" \
|
||||
"$theme_version" \
|
||||
"$custom_path/public/assets/css" \
|
||||
"$custom_path/templates" \
|
||||
"$custom_path/.gitea-github-theme-files"
|
||||
Reference in new issue
Block a user