mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-08-20 09:57:09 +00:00
fix(workflow): migrate to Forgejo
This commit is contained in:
parent
9f148e8d3b
commit
2e8b4b43b8
|
|
@ -4,15 +4,12 @@ on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'main'
|
- main
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '.gitignore'
|
- '.gitignore'
|
||||||
- '*.md'
|
- '*.md'
|
||||||
- '.gitea/**'
|
- '.forgejo/**'
|
||||||
- '!.gitea/workflows/nightly.yml'
|
- '!.forgejo/workflows/nightly.yml'
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: nightly
|
group: nightly
|
||||||
|
|
@ -20,144 +17,126 @@ concurrency:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: linux
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: https://code.forgejo.org/actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: https://github.com/cachix/install-nix-action@v27
|
uses: https://github.com/cachix/install-nix-action@v27
|
||||||
with:
|
with:
|
||||||
extra_nix_config: |
|
extra_nix_config: |
|
||||||
experimental-features = nix-command flakes
|
experimental-features = nix-command flakes
|
||||||
accept-flake-config = true
|
accept-flake-config = true
|
||||||
|
|
||||||
# Caches the Nix store so the Windows SDK fixed-output derivation
|
- name: Cache Nix store
|
||||||
# (downloaded via xwin) is not re-fetched on every run.
|
uses: https://code.forgejo.org/actions/cache@v4
|
||||||
- name: Cache Nix store
|
with:
|
||||||
uses: actions/cache@v4
|
path: |
|
||||||
with:
|
~/.cache/nix
|
||||||
path: |
|
/nix/store
|
||||||
~/.cache/nix
|
/nix/var/nix/db
|
||||||
/nix/store
|
/nix/var/nix/gcroots
|
||||||
/nix/var/nix/db
|
key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }}
|
||||||
/nix/var/nix/gcroots
|
restore-keys: |
|
||||||
key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }}
|
nix-${{ runner.os }}-
|
||||||
restore-keys: |
|
|
||||||
nix-${{ runner.os }}-
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: nix build .#unwrapped --out-link result-unwrapped
|
run: nix build .#unwrapped --out-link result-unwrapped
|
||||||
|
|
||||||
- name: Package artifacts
|
- name: Package artifacts
|
||||||
run: |
|
run: |
|
||||||
mkdir -p staging
|
mkdir -p staging
|
||||||
|
cd result-unwrapped/client
|
||||||
|
zip -r ../../staging/LCEWindows64.zip .
|
||||||
|
cp Minecraft.Client.exe ../../staging/
|
||||||
|
cd ../..
|
||||||
|
|
||||||
# Client zip (full runtime)
|
- name: Upload build artifacts
|
||||||
cd result-unwrapped/client
|
uses: https://code.forgejo.org/actions/upload-artifact@v3
|
||||||
zip -r ../../staging/LCEWindows64.zip .
|
with:
|
||||||
# Standalone exe for quick updates
|
name: build-windows64
|
||||||
cp Minecraft.Client.exe ../../staging/
|
path: staging/*
|
||||||
cd ../..
|
|
||||||
|
|
||||||
- name: Upload build artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: build-windows64
|
|
||||||
path: staging/*
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
needs: build
|
needs: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download build artifacts
|
- name: Download build artifacts
|
||||||
uses: actions/download-artifact@v4
|
uses: https://code.forgejo.org/actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: artifacts
|
path: artifacts
|
||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
|
|
||||||
- name: Publish nightly release
|
- name: Publish nightly release
|
||||||
env:
|
env:
|
||||||
FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
REPO: ${{ forge.repository }}
|
||||||
set -euo pipefail
|
API: ${{ forge.server_url }}/api/v1
|
||||||
|
run: |
|
||||||
API="${{ github.server_url }}/api/v1"
|
set -euo pipefail
|
||||||
REPO="${{ github.repository }}"
|
TAG="nightly"
|
||||||
TAG="nightly"
|
AUTH="Authorization: token $GITHUB_TOKEN"
|
||||||
AUTH="Authorization: token $FORGEJO_TOKEN"
|
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||||
|
|
||||||
# Check whether the nightly tag/release already exists
|
|
||||||
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
||||||
-H "$AUTH" \
|
|
||||||
"$API/repos/$REPO/releases/tags/$TAG")
|
|
||||||
|
|
||||||
if [[ "$HTTP_STATUS" == "200" ]]; then
|
|
||||||
echo "[info] Updating existing nightly release..."
|
|
||||||
RELEASE=$(curl -s -H "$AUTH" "$API/repos/$REPO/releases/tags/$TAG")
|
|
||||||
RELEASE_ID=$(echo "$RELEASE" | jq -r '.id')
|
|
||||||
|
|
||||||
# Wipe all existing assets so the release stays current
|
|
||||||
ASSETS=$(curl -s -H "$AUTH" "$API/repos/$REPO/releases/$RELEASE_ID/assets")
|
|
||||||
for ASSET_ID in $(echo "$ASSETS" | jq -r '.[].id'); do
|
|
||||||
curl -s -X DELETE -H "$AUTH" \
|
|
||||||
"$API/repos/$REPO/releases/$RELEASE_ID/assets/$ASSET_ID"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Update release metadata
|
|
||||||
curl -s -X PATCH \
|
|
||||||
-H "$AUTH" -H "Content-Type: application/json" \
|
|
||||||
"$API/repos/$REPO/releases/$RELEASE_ID" \
|
|
||||||
-d '{
|
|
||||||
"name": "Nightly Client Release",
|
|
||||||
"prerelease": true,
|
|
||||||
"body": "Requires at least Windows 7 and a DirectX 11 compatible GPU.\n\n# \ud83d\udea8 First time here? \ud83d\udea8\nDownload `LCEWindows64.zip` and extract it to the folder where you want to keep the game. The other files are already inside the `.zip`!"
|
|
||||||
}'
|
|
||||||
else
|
|
||||||
echo "[info] Creating new nightly release..."
|
|
||||||
RELEASE=$(curl -s -X POST \
|
|
||||||
-H "$AUTH" -H "Content-Type: application/json" \
|
|
||||||
"$API/repos/$REPO/releases" \
|
|
||||||
-d '{
|
|
||||||
"tag_name": "'"$TAG"'",
|
|
||||||
"name": "Nightly Client Release",
|
|
||||||
"prerelease": true,
|
|
||||||
"body": "Requires at least Windows 7 and a DirectX 11 compatible GPU.\n\n# \ud83d\udea8 First time here? \ud83d\udea8\nDownload `LCEWindows64.zip` and extract it to the folder where you want to keep the game. The other files are already inside the `.zip`!"
|
|
||||||
}')
|
|
||||||
RELEASE_ID=$(echo "$RELEASE" | jq -r '.id')
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "[info] Uploading assets to release $RELEASE_ID..."
|
|
||||||
for FILE in artifacts/*; do
|
|
||||||
FILENAME=$(basename "$FILE")
|
|
||||||
echo "[info] -> $FILENAME"
|
|
||||||
curl -s -X POST \
|
|
||||||
-H "$AUTH" \
|
-H "$AUTH" \
|
||||||
-F "attachment=@$FILE;filename=$FILENAME" \
|
"$API/repos/$REPO/releases/tags/$TAG")
|
||||||
"$API/repos/$REPO/releases/$RELEASE_ID/assets" > /dev/null
|
if [[ "$HTTP_STATUS" == "200" ]]; then
|
||||||
done
|
echo "[info] Updating existing nightly release..."
|
||||||
echo "[info] Done."
|
RELEASE=$(curl -s -H "$AUTH" "$API/repos/$REPO/releases/tags/$TAG")
|
||||||
|
RELEASE_ID=$(echo "$RELEASE" | jq -r '.id')
|
||||||
|
ASSETS=$(curl -s -H "$AUTH" "$API/repos/$REPO/releases/$RELEASE_ID/assets")
|
||||||
|
for ASSET_ID in $(echo "$ASSETS" | jq -r '.[].id'); do
|
||||||
|
curl -s -X DELETE -H "$AUTH" \
|
||||||
|
"$API/repos/$REPO/releases/$RELEASE_ID/assets/$ASSET_ID"
|
||||||
|
done
|
||||||
|
curl -s -X PATCH \
|
||||||
|
-H "$AUTH" -H "Content-Type: application/json" \
|
||||||
|
"$API/repos/$REPO/releases/$RELEASE_ID" \
|
||||||
|
-d '{
|
||||||
|
"name": "Nightly Client Release",
|
||||||
|
"prerelease": true,
|
||||||
|
"body": "Requires at least Windows 7 and a DirectX 11 compatible GPU.\n\n# 🚨 First time here? 🚨\nDownload `LCEWindows64.zip` and extract it."
|
||||||
|
}'
|
||||||
|
else
|
||||||
|
echo "[info] Creating new nightly release..."
|
||||||
|
RELEASE=$(curl -s -X POST \
|
||||||
|
-H "$AUTH" -H "Content-Type: application/json" \
|
||||||
|
"$API/repos/$REPO/releases" \
|
||||||
|
-d '{
|
||||||
|
"tag_name": "'"$TAG"'",
|
||||||
|
"name": "Nightly Client Release",
|
||||||
|
"prerelease": true,
|
||||||
|
"body": "Requires at least Windows 7 and a DirectX 11 compatible GPU.\n\n# 🚨 First time here? 🚨\nDownload `LCEWindows64.zip` and extract it."
|
||||||
|
}')
|
||||||
|
RELEASE_ID=$(echo "$RELEASE" | jq -r '.id')
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[info] Uploading assets..."
|
||||||
|
for FILE in artifacts/*; do
|
||||||
|
FILENAME=$(basename "$FILE")
|
||||||
|
curl -s -X POST \
|
||||||
|
-H "$AUTH" \
|
||||||
|
-F "attachment=@$FILE;filename=$FILENAME" \
|
||||||
|
"$API/repos/$REPO/releases/$RELEASE_ID/assets" > /dev/null
|
||||||
|
done
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
needs: [build, release]
|
needs: [build, release]
|
||||||
if: always()
|
if: always()
|
||||||
runs-on: ubuntu-latest
|
runs-on: linux
|
||||||
steps:
|
steps:
|
||||||
- name: Delete build artifacts
|
- name: Delete build artifacts
|
||||||
env:
|
env:
|
||||||
FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
REPO: ${{ forge.repository }}
|
||||||
API="${{ github.server_url }}/api/v1"
|
API: ${{ forge.server_url }}/api/v1
|
||||||
REPO="${{ github.repository }}"
|
run: |
|
||||||
AUTH="Authorization: token $FORGEJO_TOKEN"
|
AUTH="Authorization: token $GITHUB_TOKEN"
|
||||||
|
|
||||||
ARTIFACTS=$(curl -s -H "$AUTH" \
|
ARTIFACTS=$(curl -s -H "$AUTH" \
|
||||||
"$API/repos/$REPO/actions/artifacts?name=build-windows64")
|
"$API/repos/$REPO/actions/artifacts?name=build-windows64")
|
||||||
|
|
||||||
for ARTIFACT_ID in $(echo "$ARTIFACTS" | jq -r '.artifacts[].id // empty'); do
|
for ARTIFACT_ID in $(echo "$ARTIFACTS" | jq -r '.artifacts[].id // empty'); do
|
||||||
echo "[info] Deleting artifact $ARTIFACT_ID"
|
curl -s -X DELETE -H "$AUTH" \
|
||||||
curl -s -X DELETE -H "$AUTH" \
|
"$API/repos/$REPO/actions/artifacts/$ARTIFACT_ID"
|
||||||
"$API/repos/$REPO/actions/artifacts/$ARTIFACT_ID"
|
done
|
||||||
done
|
|
||||||
Loading…
Reference in a new issue