cleanup, migrate to mkdocs
Some checks failed
Build and publish CMBA rulebooks (Gitea) / build-release (push) Failing after 49s
Some checks failed
Build and publish CMBA rulebooks (Gitea) / build-release (push) Failing after 49s
This commit is contained in:
137
.github/workflows/release-docs.yml
vendored
137
.github/workflows/release-docs.yml
vendored
@@ -8,128 +8,21 @@ on:
|
||||
jobs:
|
||||
build-release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
uses: actions/checkout@v6
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: '3.13'
|
||||
- run: pip install -r mkdocs/requirements.txt
|
||||
- run: mkdocs build -f mkdocs/mkdocs.yml -d $RUNNER_TEMP/${{ github.ref_name }}
|
||||
# - run: mkdocs gh-deploy --force
|
||||
- name: Zip Folder
|
||||
run: |
|
||||
sudo apt-get update
|
||||
|
||||
# texlive-latex-recommended \
|
||||
# texlive-fonts-recommended \
|
||||
# texlive-latex-extra \
|
||||
|
||||
sudo apt-get install -y pandoc \
|
||||
jq \
|
||||
curl
|
||||
- name: Build pandoc after-body include from .js files
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
mkdir -p build
|
||||
out="build/after-body.html"
|
||||
: > "$out" # truncate
|
||||
|
||||
# Ensure deterministic order
|
||||
shopt -s nullglob
|
||||
files=(js/*.js)
|
||||
if [ ${#files[@]} -eq 0 ]; then
|
||||
echo "No JS files found in js/; generating empty after-body.html"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for f in "${files[@]}"; do
|
||||
{
|
||||
echo "<script>"
|
||||
echo "$f"
|
||||
echo "</script>"
|
||||
} >> "$out"
|
||||
done
|
||||
- name: Build artifacts
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p dist
|
||||
|
||||
for doc in *.md; do
|
||||
# Skip README.md
|
||||
[[ "$doc" == "README.md" ]] && continue
|
||||
basename="${doc%.md}"
|
||||
# Mobile-friendly HTML with TOC + serif styling
|
||||
pandoc "${doc}" \
|
||||
--toc \
|
||||
--standalone \
|
||||
--number-sections \
|
||||
--toc-depth=2 \
|
||||
--lua-filter pandoc-filters/shift-numbering.lua \
|
||||
--metadata-file metadata.yml \
|
||||
--embed-resources \
|
||||
--metadata title="CMBA ${basename}" \
|
||||
--include-after-body=build/after-body.html \
|
||||
--css styles/style.css \
|
||||
-o "dist/${basename}.html"
|
||||
|
||||
# PDF
|
||||
# pandoc "${doc}" \
|
||||
# --metadata title="CMBA ${doc}" \
|
||||
# -o "dist/${doc}.pdf"
|
||||
|
||||
# Include source markdown for transparency
|
||||
cp ${doc} dist/
|
||||
done
|
||||
|
||||
|
||||
- name: Create or update Gitea Release and upload assets
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
GITEA_BASE_URL: ${{ secrets.GITEA_BASE_URL }}
|
||||
# Gitea provides these variables in Actions:
|
||||
REPO: ${{ gitea.repository }} # "owner/repo"
|
||||
TAG: ${{ gitea.ref_name }} # e.g. "v2026.0"
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
OWNER="$(echo "$REPO" | cut -d/ -f1)"
|
||||
NAME="$(echo "$REPO" | cut -d/ -f2)"
|
||||
API="${GITHUB_API_URL}"
|
||||
AUTH="Authorization: token ${GITEA_TOKEN}"
|
||||
|
||||
echo "Repo: $OWNER/$NAME"
|
||||
echo "Tag: $TAG"
|
||||
echo "API: $API"
|
||||
|
||||
# Check if release exists for this tag
|
||||
existing_release_json="$(curl -sS -H "$AUTH" \
|
||||
"$API/repos/$OWNER/$NAME/releases/tags/$TAG" || true)"
|
||||
|
||||
if echo "$existing_release_json" | jq -e '.id' >/dev/null 2>&1; then
|
||||
RELEASE_ID="$(echo "$existing_release_json" | jq -r '.id')"
|
||||
echo "Release exists (id=$RELEASE_ID)."
|
||||
else
|
||||
echo "Creating release for tag $TAG..."
|
||||
create_json="$(curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" \
|
||||
"$API/repos/$OWNER/$NAME/releases" \
|
||||
-d "$(jq -n --arg tag "$TAG" --arg name "$TAG" \
|
||||
'{tag_name:$tag, name:$name, draft:false, prerelease:false, body:"CMBA rulebooks release."}')")"
|
||||
RELEASE_ID="$(echo "$create_json" | jq -r '.id')"
|
||||
echo "Created release (id=$RELEASE_ID)."
|
||||
fi
|
||||
|
||||
# Upload each file as an asset. If an asset already exists with same name, delete then re-upload.
|
||||
assets_json="$(curl -sS -H "$AUTH" "$API/repos/$OWNER/$NAME/releases/$RELEASE_ID/assets" || echo '[]')"
|
||||
|
||||
for f in dist/*; do
|
||||
filename="$(basename "$f")"
|
||||
existing_asset_id="$(echo "$assets_json" | jq -r --arg n "$filename" '.[] | select(.name==$n) | .id' | head -n1 || true)"
|
||||
|
||||
if [ -n "${existing_asset_id:-}" ] && [ "$existing_asset_id" != "null" ]; then
|
||||
echo "Deleting existing asset: $filename (id=$existing_asset_id)"
|
||||
curl -sS -X DELETE -H "$AUTH" \
|
||||
"$API/repos/$OWNER/$NAME/releases/$RELEASE_ID/assets/$existing_asset_id" >/dev/null
|
||||
fi
|
||||
echo "Uploading $filename"
|
||||
curl -sS --fail -X POST -H "$AUTH" -H "Accept: application/json" -F "attachment=@$f" "$API/repos/$OWNER/$NAME/releases/$RELEASE_ID/assets?name=$filename" >/dev/null
|
||||
done
|
||||
|
||||
echo "Done. Release page: ${GITEA_BASE_URL}/${OWNER}/${NAME}/releases/tag/${TAG}"
|
||||
zip -r dist/{{ github.ref_name }}.zip $RUNNER_TEMP/${{ github.ref_name }}
|
||||
- name: Release
|
||||
if: ${{ !env.ACT }}
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: |
|
||||
dist/*.zip
|
||||
Reference in New Issue
Block a user