Enable auto-release
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build CSS
|
||||
run: npx gulp css
|
||||
|
||||
- name: Extract version from tag
|
||||
id: version
|
||||
run: |
|
||||
TAG="${{ github.ref_name }}"
|
||||
VERSION="${TAG#v}"
|
||||
echo "TAG=${TAG}" >> $GITHUB_OUTPUT
|
||||
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set system.json URLs and version
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
TAG="${{ steps.version.outputs.TAG }}"
|
||||
BASE_URL="https://www.uberwald.me/gitea/uberwald/fvtt-prism-rpg"
|
||||
MANIFEST="${BASE_URL}/raw/tag/${TAG}/system.json"
|
||||
DOWNLOAD="${BASE_URL}/releases/download/${TAG}/fvtt-prism-rpg.zip"
|
||||
|
||||
sed -i "s|#{MANIFEST}#|${MANIFEST}|g" system.json
|
||||
sed -i "s|#{DOWNLOAD}#|${DOWNLOAD}|g" system.json
|
||||
sed -i "s|#{URL}#|${BASE_URL}|g" system.json
|
||||
sed -i "s|\"version\": \"[^\"]*\"|\"version\": \"${VERSION}\"|g" system.json
|
||||
|
||||
echo "--- system.json after substitution ---"
|
||||
cat system.json
|
||||
|
||||
- name: Package release archive
|
||||
run: |
|
||||
zip -r fvtt-prism-rpg.zip \
|
||||
assets/ \
|
||||
css/ \
|
||||
lang/ \
|
||||
module/ \
|
||||
templates/ \
|
||||
prism-rpg.mjs \
|
||||
system.json \
|
||||
LICENSE \
|
||||
README.md \
|
||||
changelog.md
|
||||
|
||||
- name: Create Gitea release
|
||||
run: |
|
||||
TAG="${{ steps.version.outputs.TAG }}"
|
||||
GITEA_URL="https://www.uberwald.me/gitea"
|
||||
REPO="uberwald/fvtt-prism-rpg"
|
||||
|
||||
# Create the release
|
||||
RELEASE_RESPONSE=$(curl -s -X POST \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases" \
|
||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"tag_name\": \"${TAG}\",
|
||||
\"name\": \"Prism RPG ${TAG}\",
|
||||
\"body\": \"Release ${TAG}\",
|
||||
\"draft\": false,
|
||||
\"prerelease\": false
|
||||
}")
|
||||
|
||||
echo "Release response: ${RELEASE_RESPONSE}"
|
||||
RELEASE_ID=$(echo "${RELEASE_RESPONSE}" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
||||
echo "Release ID: ${RELEASE_ID}"
|
||||
|
||||
# Upload fvtt-prism-rpg.zip
|
||||
curl -s -X POST \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=fvtt-prism-rpg.zip" \
|
||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||
-H "Content-Type: application/zip" \
|
||||
--data-binary @fvtt-prism-rpg.zip
|
||||
|
||||
# Upload system.json (for direct manifest URL)
|
||||
curl -s -X POST \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=system.json" \
|
||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data-binary @system.json
|
||||
Reference in New Issue
Block a user