name: build-elsword-ge on: push: branches: - main tags: - "v*" workflow_dispatch: permissions: contents: write jobs: build: runs-on: self-hosted steps: - name: Checkout repository run: | git init . git config --global --add safe.directory "$PWD" git remote add origin "${{ gitea.server_url }}/${{ gitea.repository }}.git" git -c http.extraHeader="Authorization: token ${{ secrets.GITEA_TOKEN }}" fetch --depth 1 origin "${{ gitea.sha }}" git checkout --detach FETCH_HEAD - name: Build both Elsword Proton variants run: | 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 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=\"\"))" "$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="$(jq -r ".id" /tmp/release.json)" elif [ "$HTTP_CODE" = "404" ]; then 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="$(jq -r ".id" /tmp/release.json)" else cat /tmp/release.json exit 1 fi 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}" \ -H "Content-Type: application/json" \ --data-binary @/tmp/release-update.json \ "${RELEASE_API}/${RELEASE_ID}" > /tmp/release.json curl --fail-with-body \ -H "Authorization: token ${GITEA_TOKEN}" \ "${RELEASE_API}/${RELEASE_ID}/assets" > /tmp/assets.json 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 \ -H "Authorization: token ${GITEA_TOKEN}" \ --data-binary @"${asset}" \ "${RELEASE_API}/${RELEASE_ID}/assets?name=${encoded_name}" done '