generated from Exiles/coa-template
Initial commit
This commit is contained in:
Executable
+71
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build per-addon zip artefacts from HEAD via git-archive.
|
||||
#
|
||||
# - Discovers top-level addon folders (Foo/Foo.toc).
|
||||
# - Re-creates dist/ each run.
|
||||
# - Always archives HEAD, so the working tree state is irrelevant.
|
||||
# - If more than one addon folder is present, also emits <repo>-all.zip
|
||||
# with every addon folder side-by-side at the zip root.
|
||||
# - When run inside Gitea Actions the working tree lives under a
|
||||
# per-job dir like /var/lib/act_runner/work/.../hostexecutor, so the
|
||||
# repo name comes from $GITHUB_REPOSITORY (set by the runner) and
|
||||
# only falls back to the toplevel basename for local invocations.
|
||||
set -euo pipefail
|
||||
|
||||
root=$(git rev-parse --show-toplevel)
|
||||
cd "$root"
|
||||
|
||||
# Gitea Actions sets GITHUB_REPOSITORY=owner/repo. The basename of
|
||||
# `git rev-parse --show-toplevel` inside the runner is the worker dir
|
||||
# (e.g. `hostexecutor`), which would name the bundle wrong.
|
||||
if [ -n "${GITHUB_REPOSITORY:-}" ]; then
|
||||
repo_name="${GITHUB_REPOSITORY##*/}"
|
||||
else
|
||||
repo_name=$(basename "$root")
|
||||
fi
|
||||
dist="$root/dist"
|
||||
|
||||
# Find Foo/Foo.toc pairs at depth 1; ignore libs nested deeper.
|
||||
addons=()
|
||||
while IFS= read -r toc; do
|
||||
dir=$(dirname "$toc")
|
||||
folder=$(basename "$dir")
|
||||
base=$(basename "$toc" .toc)
|
||||
# Accept Foo.toc and Foo_Wrath.toc style flavour variants; folder must match
|
||||
# at least one toc basename prefix (Foo).
|
||||
case "$base" in
|
||||
"$folder"|"$folder"_*) addons+=("$folder") ;;
|
||||
esac
|
||||
done < <(command find . -mindepth 2 -maxdepth 2 -type f -name '*.toc' | sed 's|^\./||' | sort)
|
||||
|
||||
# Dedupe (a folder with Foo.toc + Foo_Wrath.toc shows up twice).
|
||||
if [ ${#addons[@]} -gt 0 ]; then
|
||||
mapfile -t addons < <(printf '%s\n' "${addons[@]}" | awk '!seen[$0]++')
|
||||
fi
|
||||
|
||||
if [ ${#addons[@]} -eq 0 ]; then
|
||||
echo "no addon folders found (looking for */Foo.toc with matching folder name)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf "$dist"
|
||||
mkdir -p "$dist"
|
||||
|
||||
for folder in "${addons[@]}"; do
|
||||
out="$dist/$folder.zip"
|
||||
# No --prefix: the folder already sits at the repo root, so git-archive
|
||||
# emits entries as <folder>/... which is exactly what
|
||||
# Interface/AddOns/ expects after extraction.
|
||||
git archive HEAD --format=zip -o "$out" -- "$folder"
|
||||
echo "built dist/$folder.zip"
|
||||
done
|
||||
|
||||
# Combined bundle only makes sense when there are multiple addons.
|
||||
if [ ${#addons[@]} -gt 1 ]; then
|
||||
tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
git archive HEAD --format=tar -- "${addons[@]}" | tar -x -C "$tmp"
|
||||
out="$dist/$repo_name-all.zip"
|
||||
( cd "$tmp" && zip -qr "$out" "${addons[@]}" )
|
||||
echo "built dist/$repo_name-all.zip"
|
||||
fi
|
||||
Executable
+99
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env bash
|
||||
# init_from_upstream.sh — bootstrap a new Exiles addon fork from upstream.
|
||||
#
|
||||
# Usage:
|
||||
# tools/init_from_upstream.sh <upstream-url> <AddonFolderName> [upstream-branch]
|
||||
#
|
||||
# Example:
|
||||
# tools/init_from_upstream.sh https://github.com/Ascension-Addons/CallToArms CallToArms
|
||||
#
|
||||
# What it does:
|
||||
# 1. Adds `upstream` remote and fetches it.
|
||||
# 2. Squash-imports the upstream tree at the named branch (default master/main)
|
||||
# into <AddonFolderName>/ at the repo root.
|
||||
# 3. Leaves you with a single staged commit you review and finalise.
|
||||
#
|
||||
# What it does NOT do:
|
||||
# - Push anything.
|
||||
# - Tag anything.
|
||||
# - Modify the upstream history (it's a squash import, not a merge).
|
||||
#
|
||||
# After running, verify with:
|
||||
# bash tools/build_zip.sh
|
||||
# unzip -l dist/<AddonFolderName>.zip | head -5
|
||||
# then `git commit --amend` if you want to edit the message, push,
|
||||
# and tag <upstream-version>-coa.1 to trigger the first release.
|
||||
set -euo pipefail
|
||||
|
||||
if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then
|
||||
echo "usage: $0 <upstream-url> <AddonFolderName> [upstream-branch]" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
upstream_url=$1
|
||||
folder=$2
|
||||
branch=${3:-}
|
||||
|
||||
if [ -d "$folder" ]; then
|
||||
echo "refusing to overwrite existing folder $folder/" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! git remote get-url upstream >/dev/null 2>&1; then
|
||||
git remote add upstream "$upstream_url"
|
||||
else
|
||||
git remote set-url upstream "$upstream_url"
|
||||
fi
|
||||
|
||||
echo "==> fetching upstream"
|
||||
git fetch --tags upstream
|
||||
|
||||
if [ -z "$branch" ]; then
|
||||
# Try master, then main.
|
||||
if git rev-parse --verify "upstream/master" >/dev/null 2>&1; then
|
||||
branch=master
|
||||
elif git rev-parse --verify "upstream/main" >/dev/null 2>&1; then
|
||||
branch=main
|
||||
else
|
||||
echo "couldn't find upstream/master or upstream/main; pass branch explicitly" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
echo "==> importing tree from upstream/$branch into $folder/"
|
||||
|
||||
# Extract upstream tree into a temporary worktree-like dir, then move into folder.
|
||||
tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
git archive "upstream/$branch" | tar -x -C "$tmp"
|
||||
mkdir -p "$folder"
|
||||
# rsync preserves dotfiles; --exclude keeps obvious noise out.
|
||||
rsync -a --exclude '.git/' --exclude '.github/' --exclude '.gitea/' \
|
||||
--exclude '.idea/' --exclude '.vscode/' --exclude '.DS_Store' \
|
||||
"$tmp"/ "$folder"/
|
||||
|
||||
git add "$folder"
|
||||
upstream_sha=$(git rev-parse "upstream/$branch")
|
||||
upstream_short=$(git rev-parse --short "upstream/$branch")
|
||||
git commit -m "Import $folder from upstream@$upstream_short
|
||||
|
||||
upstream: $upstream_url
|
||||
branch: $branch
|
||||
commit: $upstream_sha"
|
||||
|
||||
cat <<EOF
|
||||
|
||||
==> done. next steps:
|
||||
1. bash tools/build_zip.sh
|
||||
2. unzip -l dist/$folder.zip | head -5
|
||||
(expect first entry: $folder/)
|
||||
3. git push origin master
|
||||
4. Read $folder/$folder.toc — look for the version string.
|
||||
Tag with <upstream-version>-coa.1, e.g.:
|
||||
git tag -a 1.2.3-coa.1 -m "first Exiles release"
|
||||
git push origin 1.2.3-coa.1
|
||||
The release workflow picks it up and publishes
|
||||
https://git.sub-net.at/Exiles/<this-repo>/releases/tag/<tag>.
|
||||
|
||||
The upstream remote stays configured so future rebases / re-imports
|
||||
are one-line: \`git fetch upstream && ...\`.
|
||||
EOF
|
||||
Reference in New Issue
Block a user