Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c4d997cb75 | |||
| 8804bfabaf | |||
| 13117e475b | |||
| 377b0f60ca | |||
| b285201cba | |||
| e14afd8dfa | |||
| 6bcd4d3144 | |||
| 790c34efff | |||
| 43385c8bf6 | |||
| c404c766cd | |||
| 9700806a92 | |||
| 6e9b787e41 |
@@ -1,6 +1,6 @@
|
|||||||
name: Release
|
name: Release
|
||||||
|
|
||||||
# Packs the mod into an installable .zip and publishes it as a Gitea Release,
|
# Packs the mod into an installable .zip and publishes it as a GitHub Release,
|
||||||
# once per push to main.
|
# once per push to main.
|
||||||
#
|
#
|
||||||
# Archive layout: every mod file at the archive root, manifest.json included.
|
# Archive layout: every mod file at the archive root, manifest.json included.
|
||||||
@@ -24,10 +24,10 @@ name: Release
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [master, dev]
|
branches: [master]
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- ".gitea/**"
|
- '.github/**'
|
||||||
- "**.md"
|
- '**.md'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
@@ -113,7 +113,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Refuse to clobber an existing release
|
- name: Refuse to clobber an existing release
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
TAG: ${{ steps.ver.outputs.tag }}
|
TAG: ${{ steps.ver.outputs.tag }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@@ -121,13 +121,7 @@ jobs:
|
|||||||
echo "::error::Tag $TAG already exists. Pick a different version."
|
echo "::error::Tag $TAG already exists. Pick a different version."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
if gh release view "$TAG" >/dev/null 2>&1; then
|
||||||
# Replaced `gh release view` with a direct HTTP check to the Gitea API
|
|
||||||
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
|
||||||
"$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/tags/$TAG")
|
|
||||||
|
|
||||||
if [ "$HTTP_STATUS" -eq 200 ]; then
|
|
||||||
echo "::error::Release $TAG already exists. Pick a different version."
|
echo "::error::Release $TAG already exists. Pick a different version."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -170,16 +164,16 @@ jobs:
|
|||||||
with open(path, encoding="utf-8") as fh:
|
with open(path, encoding="utf-8") as fh:
|
||||||
version = json.load(fh)["version"]
|
version = json.load(fh)["version"]
|
||||||
if version != expected:
|
if version != expected:
|
||||||
raise SystemExit(f":error::packed manifest says {version}, expected {expected}")
|
raise SystemExit(f"::error::packed manifest says {version}, expected {expected}")
|
||||||
print(f"manifest.json is at the archive root and reports {version}")
|
print(f"manifest.json is at the archive root and reports {version}")
|
||||||
PY
|
PY
|
||||||
|
|
||||||
(cd "$out" && sha256sum "${MOD_ID}"-*.zip > sha256sums.txt)
|
(cd "$out" && sha256sum "${MOD_ID}"-*.zip > sha256sums.txt)
|
||||||
cat "$out/sha256sums.txt"
|
cat "$out/sha256sums.txt"
|
||||||
|
|
||||||
- name: Publish Gitea Release
|
- name: Publish GitHub Release
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
VERSION: ${{ steps.ver.outputs.version }}
|
VERSION: ${{ steps.ver.outputs.version }}
|
||||||
TAG: ${{ steps.ver.outputs.tag }}
|
TAG: ${{ steps.ver.outputs.tag }}
|
||||||
MOD_ID: "DRAMATIC_SHAPE"
|
MOD_ID: "DRAMATIC_SHAPE"
|
||||||
@@ -196,34 +190,11 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
printf 'Release notes:\n%s\n' "$notes"
|
printf 'Release notes:\n%s\n' "$notes"
|
||||||
|
|
||||||
# Create the release via Gitea's REST API
|
gh release create "$TAG" \
|
||||||
RESPONSE=$(curl -s -X POST "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases" \
|
--target "$GITHUB_SHA" \
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
--title "$VERSION" \
|
||||||
-H "Content-Type: application/json" \
|
--notes "$notes" \
|
||||||
-d "$(jq -n \
|
"dist/${MOD_ID}-${VERSION}.zip" \
|
||||||
--arg tag "$TAG" \
|
"dist/sha256sums.txt"
|
||||||
--arg target "$GITHUB_SHA" \
|
|
||||||
--arg name "$VERSION" \
|
|
||||||
--arg body "$notes" \
|
|
||||||
'{tag_name: $tag, target_commitish: $target, name: $name, body: $body}')"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Extract the numeric release ID needed to upload assets
|
|
||||||
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id')
|
|
||||||
|
|
||||||
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
|
|
||||||
echo "::error::Failed to create release. Gitea responded with: $RESPONSE"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Upload the Mod .zip asset to the newly created release
|
|
||||||
curl -s -f -X POST "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID/assets" \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
|
||||||
-F "attachment=@dist/${MOD_ID}-${VERSION}.zip"
|
|
||||||
|
|
||||||
# Upload the sha256sums.txt file
|
|
||||||
curl -s -f -X POST "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID/assets" \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
|
||||||
-F "attachment=@dist/sha256sums.txt"
|
|
||||||
|
|
||||||
echo "Published release $TAG"
|
echo "Published release $TAG"
|
||||||
Reference in New Issue
Block a user