157 lines
4.9 KiB
YAML
157 lines
4.9 KiB
YAML
name: Nightly Release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
paths-ignore:
|
|
- '.gitignore'
|
|
- '*.md'
|
|
- '.gitea/**'
|
|
- '!.gitea/workflows/nightly.yml'
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
concurrency:
|
|
group: nightly
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: codeberg-medium
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://code.forgejo.org/actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
sudo apt-get update -qq
|
|
sudo apt-get install -y --no-install-recommends \
|
|
cmake ninja-build rsync zip \
|
|
clang lld llvm
|
|
|
|
- name: Install Rust toolchain
|
|
uses: https://codeberg.org/wackbyte/rust-toolchain@trunk
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Install xwin
|
|
run: |
|
|
cargo install xwin --locked
|
|
|
|
- name: Cache Windows SDK
|
|
uses: https://code.forgejo.org/actions/cache@v4
|
|
with:
|
|
path: ~/.cache/xwin
|
|
key: xwin-${{ runner.os }}-v1
|
|
restore-keys: |
|
|
xwin-${{ runner.os }}-
|
|
|
|
- name: Build
|
|
run: |
|
|
chmod +x build-linux.sh
|
|
INSTALL_PREFIX=$PWD/result ./build-linux.sh . Release
|
|
|
|
- name: Package artifacts
|
|
run: |
|
|
mkdir -p staging
|
|
cd result/client
|
|
zip -r ../../staging/LCEWindows64.zip .
|
|
cp Minecraft.Client.exe ../../staging/
|
|
cd ../..
|
|
cd result/server
|
|
zip -r ../../staging/LCEWindows64Server.zip .
|
|
cp Minecraft.Server.exe ../../staging/
|
|
cd ../..
|
|
|
|
- name: Upload build artifacts
|
|
uses: https://code.forgejo.org/actions/upload-artifact@v3
|
|
with:
|
|
name: build-windows64
|
|
path: staging/*
|
|
|
|
release:
|
|
needs: build
|
|
runs-on: codeberg-small
|
|
steps:
|
|
- name: Download build artifacts
|
|
uses: https://code.forgejo.org/actions/download-artifact@v3
|
|
with:
|
|
path: artifacts
|
|
merge-multiple: true
|
|
|
|
- name: Publish nightly release
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
REPO: ${{ forge.repository }}
|
|
API: ${{ forge.server_url }}/api/v1
|
|
run: |
|
|
set -euo pipefail
|
|
TAG="nightly"
|
|
AUTH="Authorization: token $GITHUB_TOKEN"
|
|
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')
|
|
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 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 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:
|
|
needs: [build, release]
|
|
if: always()
|
|
runs-on: codeberg-tiny
|
|
steps:
|
|
- name: Delete build artifacts
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
REPO: ${{ forge.repository }}
|
|
API: ${{ forge.server_url }}/api/v1
|
|
run: |
|
|
AUTH="Authorization: token $GITHUB_TOKEN"
|
|
|
|
ARTIFACTS=$(curl -s -H "$AUTH" \
|
|
"$API/repos/$REPO/actions/artifacts?name=build-windows64")
|
|
|
|
for ARTIFACT_ID in $(echo "$ARTIFACTS" | jq -r '.artifacts[].id // empty'); do
|
|
curl -s -X DELETE -H "$AUTH" \
|
|
"$API/repos/$REPO/actions/artifacts/$ARTIFACT_ID"
|
|
done
|