LoVisual/.github/workflows/release.yml
loki5512344 2d96f28091
Some checks failed
CI / backend (cargo test + clippy) (push) Has been cancelled
CI / frontend (lint + test + build) (push) Has been cancelled
CI / mod (gradle test + checkFolderLimit) (push) Has been cancelled
feat(site): redesigned /download, releases and links moved from GitHub to Forgejo
- /download: the jar as an in-game item (pixel heart in an inventory slot, vanilla-style tooltip with version, size and SHA-256, copy button), spec list, three install steps, release timeline
- releases read through a cached nginx proxy (/api/releases): Forgejo's API has no CORS headers
- README, footer and landing links point to git.wihuk.pro/boba/LoVisual (the GitHub repo they used does not exist)
- release workflow publishes through the Forgejo API and ships lovisual.jar.sha256
- fix i18n interpolation placeholders ({{x}}) in the download strings
2026-10-09 22:15:55 +02:00

75 lines
2.8 KiB
YAML

name: Release
# Publish a mod build on every version tag. Every release carries both a
# versioned jar and a stable `lovisual.jar`, so the site's one-click download
# link (releases/latest/download/lovisual.jar) always resolves.
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '25'
- name: Grant the Gradle wrapper the exec bit
working-directory: mod
run: chmod +x ./gradlew
- name: Build the mod
working-directory: mod
run: ./gradlew --no-daemon build
- name: Collect the remapped jar
id: jar
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
jar="$(find mod/build/libs -maxdepth 1 -type f -name '*.jar' \
! -name '*-sources.jar' ! -name '*-javadoc.jar' \
-printf '%s %p\n' | sort -rn | head -1 | cut -d' ' -f2-)"
test -n "$jar"
cp "$jar" lovisual-"$version".jar
cp "$jar" lovisual.jar
echo "version=$version" >>"$GITHUB_OUTPUT"
echo "Packaged $jar as lovisual-$version.jar and lovisual.jar"
# The repository lives on Forgejo, so the release goes through its API.
# One-time setup: Settings > Actions > Secrets > RELEASE_TOKEN (an API
# token with write access to this repository's releases).
- name: Publish the Forgejo release
env:
TOKEN: ${{ secrets.RELEASE_TOKEN }}
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
TAG: ${{ github.ref_name }}
VERSION: ${{ steps.jar.outputs.version }}
run: |
set -euo pipefail
test -n "$TOKEN" || { echo "RELEASE_TOKEN secret is missing"; exit 1; }
sha256sum lovisual.jar > lovisual.jar.sha256
prev="$(git describe --tags --abbrev=0 "$TAG^" 2>/dev/null || true)"
range="${prev:+$prev..}$TAG"
notes="$(git log --no-merges --pretty='- %s' "$range" | head -60)"
body="$(python3 -c 'import json,sys; print(json.dumps({"tag_name":sys.argv[1],"name":sys.argv[1],"body":sys.argv[2]}))' "$TAG" "$notes")"
id="$(curl -fsS -X POST "$API/releases" -H "Authorization: token $TOKEN" \
-H 'Content-Type: application/json' -d "$body" \
| python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])')"
for f in "lovisual-$VERSION.jar" lovisual.jar lovisual.jar.sha256; do
curl -fsS -X POST "$API/releases/$id/assets?name=$f" -H "Authorization: token $TOKEN" \
-F "attachment=@$f" >/dev/null
echo "uploaded $f"
done