This commit is contained in:
+55
-38
@@ -1,15 +1,18 @@
|
||||
name: build-elsword-ge
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 4 * * *"
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build-release:
|
||||
build:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
@@ -20,61 +23,71 @@ jobs:
|
||||
git -c http.extraHeader="Authorization: token ${{ secrets.GITEA_TOKEN }}" fetch --depth 1 origin "${{ gitea.sha }}"
|
||||
git checkout --detach FETCH_HEAD
|
||||
|
||||
- name: Build Elsword Proton-GE 10-34 tool
|
||||
- name: Build both Elsword Proton variants
|
||||
run: |
|
||||
nix develop -c ./build.sh --no-install
|
||||
nix develop -c ./scripts/build.sh all
|
||||
|
||||
- name: Package release archives
|
||||
run: |
|
||||
nix develop -c ./scripts/create-release-archive.sh
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: elsword-ge-builds
|
||||
path: |
|
||||
dist/*.tar.zst
|
||||
dist/*.sha256
|
||||
dist/SHA256SUMS.txt
|
||||
dist/release-notes.md
|
||||
profiles/elsword-launch-options.md
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Create or update Gitea release
|
||||
if: startsWith(gitea.ref, 'refs/tags/v')
|
||||
env:
|
||||
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
GITEA_TAG: ${{ gitea.ref_name }}
|
||||
GITEA_SHA: ${{ gitea.sha }}
|
||||
run: |
|
||||
nix develop -c bash -lc '
|
||||
set -euo pipefail
|
||||
set -a
|
||||
. dist/package-info.env
|
||||
set +a
|
||||
|
||||
RELEASE_API="${GITEA_SERVER_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases"
|
||||
RELEASE_TAG_URL="$(python3 -c "import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=\"\"))" "$RELEASE_TAG")"
|
||||
ARCHIVE_URL_NAME="$(python3 -c "import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=\"\"))" "$ARCHIVE_FILE")"
|
||||
RELEASE_TAG_URL="$(python3 -c "import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=\"\"))" "$GITEA_TAG")"
|
||||
|
||||
HTTP_CODE="$(curl -s -o /tmp/release.json -w "%{http_code}" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${RELEASE_API}/tags/${RELEASE_TAG_URL}")"
|
||||
|
||||
if [ "$HTTP_CODE" = "200" ]; then
|
||||
RELEASE_ID="$(python3 -c "import json; print(json.load(open(\"/tmp/release.json\"))[\"id\"])" )"
|
||||
RELEASE_ID="$(jq -r ".id" /tmp/release.json)"
|
||||
elif [ "$HTTP_CODE" = "404" ]; then
|
||||
python3 -c "import json, pathlib, os; pathlib.Path(\"/tmp/release-create.json\").write_text(json.dumps({
|
||||
\"tag_name\": os.environ[\"RELEASE_TAG\"],
|
||||
\"target_commitish\": os.environ[\"GITEA_SHA\"],
|
||||
\"name\": os.environ[\"RELEASE_TAG\"],
|
||||
\"body\": pathlib.Path(\"dist/release-notes.md\").read_text(),
|
||||
\"draft\": False,
|
||||
\"prerelease\": False,
|
||||
}))"
|
||||
jq -n \
|
||||
--arg tag "$GITEA_TAG" \
|
||||
--arg sha "$GITEA_SHA" \
|
||||
--arg body "$(cat dist/release-notes.md)" \
|
||||
"{tag_name: \$tag, target_commitish: \$sha, name: \$tag, body: \$body, draft: false, prerelease: false}" \
|
||||
> /tmp/release-create.json
|
||||
curl --fail-with-body \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data-binary @/tmp/release-create.json \
|
||||
"${RELEASE_API}" > /tmp/release.json
|
||||
RELEASE_ID="$(python3 -c "import json; print(json.load(open(\"/tmp/release.json\"))[\"id\"])" )"
|
||||
RELEASE_ID="$(jq -r ".id" /tmp/release.json)"
|
||||
else
|
||||
cat /tmp/release.json
|
||||
exit 1
|
||||
fi
|
||||
|
||||
python3 -c "import json, pathlib, os; pathlib.Path(\"/tmp/release-update.json\").write_text(json.dumps({
|
||||
\"tag_name\": os.environ[\"RELEASE_TAG\"],
|
||||
\"target_commitish\": os.environ[\"GITEA_SHA\"],
|
||||
\"name\": os.environ[\"RELEASE_TAG\"],
|
||||
\"body\": pathlib.Path(\"dist/release-notes.md\").read_text(),
|
||||
\"draft\": False,
|
||||
\"prerelease\": False,
|
||||
}))"
|
||||
jq -n \
|
||||
--arg tag "$GITEA_TAG" \
|
||||
--arg sha "$GITEA_SHA" \
|
||||
--arg body "$(cat dist/release-notes.md)" \
|
||||
"{tag_name: \$tag, target_commitish: \$sha, name: \$tag, body: \$body, draft: false, prerelease: false}" \
|
||||
> /tmp/release-update.json
|
||||
curl --fail-with-body \
|
||||
-X PATCH \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
@@ -86,16 +99,20 @@ jobs:
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${RELEASE_API}/${RELEASE_ID}/assets" > /tmp/assets.json
|
||||
|
||||
EXISTING_ASSET_ID="$(python3 -c "import json, os; data=json.load(open(\"/tmp/assets.json\")); target=os.environ[\"ARCHIVE_FILE\"]; print(next((str(item[\"id\"]) for item in data if item.get(\"name\") == target), \"\"))")"
|
||||
if [ -n "$EXISTING_ASSET_ID" ]; then
|
||||
for asset in dist/*.tar.zst dist/*.sha256 dist/SHA256SUMS.txt dist/release-notes.md; do
|
||||
[ -f "$asset" ] || continue
|
||||
name="$(basename "$asset")"
|
||||
existing_id="$(jq -r --arg name "$name" ".[] | select(.name == \$name) | .id" /tmp/assets.json | head -n1)"
|
||||
if [ -n "$existing_id" ]; then
|
||||
curl --fail-with-body \
|
||||
-X DELETE \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${RELEASE_API}/${RELEASE_ID}/assets/${existing_id}"
|
||||
fi
|
||||
encoded_name="$(python3 -c "import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=\"\"))" "$name")"
|
||||
curl --fail-with-body \
|
||||
-X DELETE \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${RELEASE_API}/${RELEASE_ID}/assets/${EXISTING_ASSET_ID}"
|
||||
fi
|
||||
|
||||
curl --fail-with-body \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
--data-binary @"dist/${ARCHIVE_FILE}" \
|
||||
"${RELEASE_API}/${RELEASE_ID}/assets?name=${ARCHIVE_URL_NAME}"
|
||||
--data-binary @"${asset}" \
|
||||
"${RELEASE_API}/${RELEASE_ID}/assets?name=${encoded_name}"
|
||||
done
|
||||
'
|
||||
|
||||
Reference in New Issue
Block a user