Skip to content

Update godot-ci.yml #27

Update godot-ci.yml

Update godot-ci.yml #27

Workflow file for this run

name: "godot-ci export"
on:
push:
branches:
- main
tags:
- 'v*'
# NOTE: If your `project.godot` is at the repository root, set `PROJECT_PATH` below to ".".
env:
GODOT_VERSION: 4.3
EXPORT_NAME: onlyoneladder
PROJECT_PATH: .
jobs:
export-windows:
name: Windows Export
runs-on: ubuntu-22.04 # Use 22.04 with godot 4
container:
image: barichello/godot-ci:4.3
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
- name: Setup
run: |
mkdir -v -p ~/.local/share/godot/export_templates/
mkdir -v -p ~/.config/
mv /root/.config/godot ~/.config/godot
mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable
- name: Windows Build
run: |
mkdir -v -p build/windows
EXPORT_DIR="$(readlink -f build)"
cd $PROJECT_PATH
godot --headless --verbose --export-release "Windows Desktop" "$EXPORT_DIR/windows/$EXPORT_NAME.exe"
mv "$EXPORT_DIR/windows/$EXPORT_NAME.pck" "$EXPORT_DIR/windows/$EXPORT_NAME.windows.pck"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: windows
path: build/windows
export-linux:
name: Linux Export
runs-on: ubuntu-22.04 # Use 22.04 with godot 4
container:
image: barichello/godot-ci:4.3
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
- name: Setup
run: |
mkdir -v -p ~/.local/share/godot/export_templates/
mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable
- name: Linux Build
run: |
mkdir -v -p build/linux
EXPORT_DIR="$(readlink -f build)"
cd $PROJECT_PATH
godot --headless --verbose --export-release "Linux" "$EXPORT_DIR/linux/$EXPORT_NAME.x86_64"
mv "$EXPORT_DIR/linux/$EXPORT_NAME.pck" "$EXPORT_DIR/linux/$EXPORT_NAME.linux.pck"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: linux
path: build/linux
export-web:
name: Web Export
runs-on: ubuntu-22.04 # Use 22.04 with godot 4
container:
image: barichello/godot-ci:4.3
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: Setup
run: |
mkdir -v -p ~/.local/share/godot/export_templates/
mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable
- name: Web Build
run: |
mkdir -v -p build/web
EXPORT_DIR="$(readlink -f build)"
cd $PROJECT_PATH
godot --headless --verbose --export-release "Web" "$EXPORT_DIR/web/index.html"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: web
path: build/web
- name: Install rsync 📚
run: |
apt-get update && apt-get install -y rsync
- name: Git Fetch
run: |
git config --global --add safe.directory "$(pwd)"
git fetch --tags origin
git fetch origin main
- name: Deploy to GitHub Pages 🚀
if: always()
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: build/web
target-folder: ${{ startsWith(github.ref, 'refs/tags/v') && 'stable' || 'dev' }}
- name: Generate index.html with build metadata and alt builds
run: |
git config --global --add safe.directory "$(pwd)"
git fetch --tags origin
git fetch origin +refs/heads/*:refs/remotes/origin/*
# Get latest tag
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
# Get commit difference and dates
COMMITS_BEHIND=$(git rev-list --count ${LATEST_TAG}..origin/main)
DEV_DATE=$(git log -1 --format=%cd origin/main)
STABLE_DATE=$(git log -1 --format=%cd ${LATEST_TAG})
# Clone the gh-pages branch into a temp directory
git clone --branch gh-pages --depth=1 https://github.com/${{ github.repository }} ghpages-tmp
# Build alternative builds list
ALT_LINKS=""
for dir in ghpages-tmp/*/; do
NAME=$(basename "$dir")
if [ "$NAME" != "dev" ] && [ "$NAME" != "stable" ]; then
ALT_LINKS="${ALT_LINKS}<li><a href=\"./${NAME}/\">${NAME}</a></li>\\n"
fi
done
# Generate index.html
mkdir -p deploy-root
cat <<EOF > deploy-root/index.html
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Only One Ladder</title>
</head>
<body>
<h1>Only One Ladder</h1>
<ul>
<li><a href='./stable/'>Stable Build</a> - Last updated: ${STABLE_DATE}</li>
<li><a href='./dev/'>Development Build</a> - Last updated: ${DEV_DATE}</li>
</ul>
<p>The development build is <strong>${COMMITS_BEHIND} commits ahead</strong> of the last stable build (${LATEST_TAG}).</p>
<h2>Alternative Builds</h2>
<ul>
${ALT_LINKS}
</ul>
</body>
</html>
EOF
- name: Upload index.html to root of GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: deploy-root
clean: false
export-mac:
name: Mac Export
runs-on: ubuntu-22.04 # Use 22.04 with godot 4
container:
image: barichello/godot-ci:4.3
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
- name: Setup
run: |
mkdir -v -p ~/.local/share/godot/export_templates/
mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable
- name: Enable ETC2 ASTC for macOS only
run: |
FILE="$PROJECT_PATH/project.godot"
# Ensure [rendering] section exists
if ! grep -q "^\[rendering\]" "$FILE"; then
echo -e "\n[rendering]" >> "$FILE"
fi
# Remove any existing setting for the ETC2 ASTC line
sed -i '/^textures\/vram_compression\/import_etc2_astc/d' "$FILE"
# Insert the setting right after the [rendering] section
awk '
BEGIN { inserted=0 }
/^\[rendering\]/ {
print
getline nextLine
print nextLine
print "textures/vram_compression/import_etc2_astc=true"
inserted=1
next
}
{ print }
END {
if (!inserted) print "textures/vram_compression/import_etc2_astc=true"
}
' "$FILE" > temp && mv temp "$FILE"
- name: Mac Build
run: |
mkdir -v -p build/mac
EXPORT_DIR="$(readlink -f build)"
cd $PROJECT_PATH
godot --headless --verbose --export-release "macOS" "$EXPORT_DIR/mac/$EXPORT_NAME.zip"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: mac
path: build/mac
release:
name: Publish GitHub Release
needs: [export-windows, export-linux, export-web, export-mac]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download Windows build
uses: actions/download-artifact@v4
with:
name: windows
path: dist/windows
- name: Download Linux build
uses: actions/download-artifact@v4
with:
name: linux
path: dist/linux
- name: Download Web build
uses: actions/download-artifact@v4
with:
name: web
path: dist/web
- name: Download macOS build
uses: actions/download-artifact@v4
with:
name: mac
path: dist/mac
- name: Zip Web Build
run: |
cd dist/web
zip -r ../web.zip .
- name: Determine release context
id: releaseinfo
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG="${GITHUB_REF#refs/tags/}"
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "name=Release $TAG" >> $GITHUB_OUTPUT
echo "prerelease=false" >> $GITHUB_OUTPUT
git log --pretty=format:"- %s (%an)" $(git describe --tags --abbrev=0)..HEAD > release_notes.md
else
echo "tag=dev" >> $GITHUB_OUTPUT
echo "name=Development Build" >> $GITHUB_OUTPUT
echo "prerelease=true" >> $GITHUB_OUTPUT
echo "Latest development build from main." > release_notes.md
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.releaseinfo.outputs.tag }}
name: ${{ steps.releaseinfo.outputs.name }}
body_path: release_notes.md
prerelease: ${{ steps.releaseinfo.outputs.prerelease }}
files: |
dist/windows/*
dist/linux/*
dist/mac/*
dist/web.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}