# This is an edtied version of abarichello's automation script for gitea and godot mono # https://github.com/abarichello/godot-ci/blob/master/.github/workflows/godot-ci.yml name: "godot-ci export" on: push # NOTE: If your `project.godot` is at the repository root, set `PROJECT_PATH` below to ".". env: GODOT_VERSION: 4.4.1 EXPORT_NAME: videogame PROJECT_PATH: "." ACTIONS_RUNNER_DEBUG: true ACTIONS_STEP_DEBUG: true jobs: prepare-build: name: Prepare Build Assets runs-on: ubuntu-22.04 steps: # Ensure dl link is provided before starting build process - name: Check Gitea Variables run: | if [ -z "${{ secrets.EXPORT_TEMPLATE_DOWNLOAD_LINK }}" ]; then echo "No export template download link provided, cancelling build" echo "Please set the EXPORT_TEMPLATE_DOWNLOAD_LINK secret in Gitea" exit 1 fi # By default ubuntu-22.04 has nodejs 12, but we need a more modern version for the actions/checkout@v4 # Should make my docker image for this step in the future - name: Install Dependencies run: | apt-get update apt-get install -y curl curl -fsSL https://deb.nodesource.com/setup_18.x | bash - apt-get install -y nodejs unzip git git-lfs git lfs install - name: Checkout uses: https://gitea.com/actions/checkout@v4 with: lfs: true # Update the version_info.gd file with info about this build. # If it isn't in the expected spot of game/scripts/version_info.gd skip it - name: Populate Version Text run: | VERSION_FILE="${PROJECT_PATH}/game/scripts/version_info.gd" if [ -f "$VERSION_FILE" ]; then PROJECT_NAME="${EXPORT_NAME}" COMMIT_NUMBER="${GITHUB_RUN_NUMBER}" BRANCH_NAME="${GITHUB_REF_NAME}" SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-8) sed -i "s/var project_name: String = \"X\"/var project_name: String = \"${PROJECT_NAME}\"/" "$VERSION_FILE" sed -i "s/var commit_number: int = 0/var commit_number: int = ${COMMIT_NUMBER}/" "$VERSION_FILE" sed -i "s/var branch_name: String = \"X\"/var branch_name: String = \"${BRANCH_NAME}\"/" "$VERSION_FILE" sed -i "s/var short_sha: String = \"X\"/var short_sha: String = \"${SHORT_SHA}\"/" "$VERSION_FILE" sed -i "s/var build_override: bool = false/var build_override: bool = true/" "$VERSION_FILE" echo "Updated version_info.gd:" cat "$VERSION_FILE" else echo "version_info.gd not found at $VERSION_FILE, skipping." fi # Download the exprot templates from the link provided in the secrets # The expected format is a zip that contains windows and linux export and debug templates - name: Download Export Templates run: | mkdir -p "$PROJECT_PATH/build/build_dependencies/export_templates" curl -L "${{ secrets.EXPORT_TEMPLATE_DOWNLOAD_LINK }}" -o "$PROJECT_PATH/build/build_dependencies/export_templates/export_templates.zip" unzip -o "$PROJECT_PATH/build/build_dependencies/export_templates/export_templates.zip" -d "$PROJECT_PATH/build/build_dependencies/export_templates/" rm "$PROJECT_PATH/build/build_dependencies/export_templates/export_templates.zip" # Debug to see if the export templates were downloaded correctly echo "Export templates downloaded to $PROJECT_PATH/build/build_dependencies/export_templates/" ls -la "$PROJECT_PATH/build/build_dependencies/export_templates/" - name: Upload Prepared Assets uses: https://gitea.com/actions/upload-artifact@v3 with: name: prepared-assets path: | game/scripts/version_info.gd build/build_dependencies/export_templates/ export-windows: name: Windows Export runs-on: ubuntu-22.04 # Use 22.04 with godot 4 needs: prepare-build container: image: barichello/godot-ci:mono-4.4.1 # change to mono steps: # Doing this becuase barichello/godot-ci:4.4 doesn't have nodejs installed, may need to make own docker image in the future # By default ubuntu-22.04 has nodejs 12, but we need a more modern version for the actions/checkout@v4 - name: Install Node.js run: | apt-get update apt-get install -y curl curl -fsSL https://deb.nodesource.com/setup_18.x | bash - apt-get install -y nodejs - name: Checkout uses: https://gitea.com/actions/checkout@v4 with: lfs: true - name: Download Prepared Assets uses: https://gitea.com/actions/download-artifact@v3 with: name: prepared-assets path: . - name: Windows Build run: | mkdir -v -p build/bin/windows EXPORT_DIR="$(readlink -f build/bin)" cd $PROJECT_PATH godot --headless --verbose --export-release "Windows Desktop" "$EXPORT_DIR/windows/$EXPORT_NAME.exe" - name: Upload Artifact uses: https://gitea.com/actions/upload-artifact@v3 # using v3 ad v4 has issues wwith gitea with: name: windows path: build/bin/windows export-linux: name: Linux Export runs-on: ubuntu-22.04 # Use 22.04 with godot 4 needs: prepare-build container: image: barichello/godot-ci:mono-4.4.1 # change to mono steps: # Doing this becuase barichello/godot-ci:4.4 doesn't have nodejs installed, may need to make own docker image in the future # By default ubuntu-22.04 has nodejs 12, but we need a more modern version for the actions/checkout@v4 - name: Install Node.js run: | apt-get update apt-get install -y curl curl -fsSL https://deb.nodesource.com/setup_18.x | bash - apt-get install -y nodejs - name: Checkout uses: https://gitea.com/actions/checkout@v4 with: lfs: true - name: Download Prepared Assets uses: https://gitea.com/actions/download-artifact@v3 with: name: prepared-assets path: . - name: Linux Build run: | mkdir -v -p build/bin/linux EXPORT_DIR="$(readlink -f build/bin)" cd $PROJECT_PATH godot --headless --verbose --export-release "Linux" "$EXPORT_DIR/linux/$EXPORT_NAME.x86_64" - name: Upload Artifact uses: https://gitea.com/actions/upload-artifact@v3 # using v3 ad v4 has issues wwith gitea with: name: linux path: build/bin/linux steam-publish: name: Steam Publish runs-on: ubuntu-22.04 needs: [export-windows, export-linux] steps: # Ensure steam info is provided - name: Check Gitea Variables run: | if [ -z "${{ vars.STEAM_BUILD_USERNAME }}" ]; then echo "No Steam Username variable, cancelling build" echo "Please set the STEAM_BUILD_USERNAME variable in Gitea" exit 1 fi if [ -z "${{ secrets.STEAM_BUILD_PASSWORD }}" ]; then echo "No Steam Password secret, cancelling build" echo "Please set the STEAM_BUILD_PASSWORD secret in Gitea" exit 1 fi if [ -z "${{ secrets.STEAM_GUARD_CODE }}" ]; then echo "No Steam Guard Code secret, cancelling build" echo "Please set the STEAM_GUARD_CODE secret in Gitea" exit 1 fi # I can't use the c2msnetwork/steamcmd bc I need to instlal git and nodejs for the actions/checkout@v4 to work # and I would need root access to install them, which root breaks saving the cache file # So here we setup the dependencies for the missing steamcmd image, nodejs, and git manually - name: Install Dependencies run: | sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install -y --no-install-recommends \ lib32gcc-s1 \ lib32stdc++6 \ curl \ nodejs \ git \ git-lfs git lfs install # Get the file from the link and put it in the required directory - name: Setup SteamCMD run: | mkdir -p ~/steamcmd curl -fsSL 'https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz' | tar xvzf - -C ~/steamcmd # Run once to initialize ~/steamcmd/steamcmd.sh +quit # Get all the files from the repo into the working directory - name: Checkout uses: https://gitea.com/actions/checkout@v4 with: lfs: true # Download artifacts, this isn't done automatially like it was in gitlab - name: Download Windows Artifacts uses: https://gitea.com/actions/download-artifact@v3 with: name: windows path: build/bin/windows - name: Download Linux Artifacts uses: https://gitea.com/actions/download-artifact@v3 with: name: linux path: build/bin/linux # The normal actions/cache@v3 doesn't work here, so need to manully restore the cache in this step # The only file we need is the config.vdf file for the steam gaurd code # If the file doesn't exist, the steam upload will fail and request a new steam guard code. # After a successful upload, the config.vdf file will be created and saved in the cache for future runs - name: Restore Cache uses: https://gitea.com/actions/cache/restore@v3 with: path: | ~/Steam/config/config.vdf ./steam_build_output/ key: steam-cache-${{ runner.os }}-${{ github.ref_name }} restore-keys: | steam-cache-${{ runner.os }} steam-cache # Debug to see if cache file exists - name: Debug Pre-Cache run: | echo "Checking for cached config file in :~/Steam/config/config.vdf" if [ -f ~/Steam/config/config.vdf ]; then echo "config.vdf exists!" ls -la ~/Steam/config/config.vdf else echo "No cached config.vdf file." fi # Update the vdf with steam description from build info - name: Update VDF run: | cd $PROJECT_PATH SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-8) sed -i -e "s/STEAM_DESCRIPTION/${GITHUB_REF_NAME} - ${SHORT_SHA}/" build/build_dependencies/steam/app_build_2739610.vdf # There is a chacne that if you fail enough uplaods, steam will rate limit you. # But to get a new steamguard code, you need to fail at least once to get the emial with the code # The ratelimit time isn't published, but I saw in a reddit commit that its 30 minutes, but if you fail in that 30 mintues, it resets the timer # Waiting 30 mintues worked for me, idk if that supersition is real or not :) - name: Publish to Steam run: | cd $PROJECT_PATH ~/steamcmd/steamcmd.sh +set_steam_guard_code "${{ secrets.STEAM_GUARD_CODE }}" +login "${{ vars.STEAM_BUILD_USERNAME }}" "${{ secrets.STEAM_BUILD_PASSWORD }}" +run_app_build "$PWD/build/build_dependencies/steam/app_build_2739610.vdf" +quit # Sanity check make sure file exists - name: Debug Post-Cache run: | echo "Checking for config file in :~/Steam/config/config.vdf" if [ -f ~/Steam/config/config.vdf ]; then echo "File exists!" ls -la ~/Steam/config/config.vdf else echo "No file found." fi # Manually save the cache file, normal method doesn't work - name: Save Cache uses: https://gitea.com/actions/cache/save@v3 with: path: | ~/Steam/config/config.vdf ./steam_build_output/ key: steam-cache-${{ runner.os }}-${{ github.ref_name }}