Skip to content

Extract BitCraft assets #271

Extract BitCraft assets

Extract BitCraft assets #271

Workflow file for this run

name: Extract BitCraft assets
on:
workflow_dispatch:
schedule:
- cron: '37 5 * * *'
jobs:
extract-assets:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download DepotDownloader
run: |
mkdir -p workspace/assets
cd workspace/assets
wget -qO DepotDownloader.zip https://github.com/SteamRE/DepotDownloader/releases/download/DepotDownloader_3.4.0/DepotDownloader-linux-x64.zip
unzip DepotDownloader.zip DepotDownloader
- name: Steam auth cache
id: auth-cache
uses: actions/cache@v4
with:
path: ~/.local/share/IsolatedStorage
key: steamauth
- name: Steam auth
if: steps.auth-cache.outputs.cache-hit != 'true'
working-directory: workspace/assets
run: |
./DepotDownloader -app 3454650 -qr -remember-password -os windows -branch preview -manifest-only
- uses: actions/cache/save@v5
if: steps.auth-cache.outputs.cache-hit != 'true'
id: save-auth-cache
with:
path: ~/.local/share/IsolatedStorage
key: steamauth
# --- Step 1: Check client manifest; if new, download and extract immediately ---
- name: Check depot manifest
working-directory: workspace/assets
env:
STEAM_USER: ${{ secrets.STEAM_USER }}
run: |
./DepotDownloader -app 3454650 -username $STEAM_USER -remember-password -os windows -branch preview -manifest-only \
| grep Manifest | cut -d " " -f 2 > manifest.txt
- name: Cache depot manifest
id: manifest-cache
uses: actions/cache@v4
with:
path: workspace/assets/manifest.txt
key: manifest-${{ hashFiles('workspace/assets/manifest.txt') }}
- name: Extract and catalog assets
if: steps.manifest-cache.outputs.cache-hit != 'true'
uses: ./.github/actions/extract-and-catalog
with:
steam-user: ${{ secrets.STEAM_USER }}
actions-token: ${{ secrets.ACTIONS_TOKEN }}
# --- Step 2: Check game data; build path list and cache on its hash ---
- name: Checkout game data repo
uses: actions/checkout@v4
with:
repository: BitCraftToolBox/BitCraft_GameData
ref: cereal/cs
path: workspace/assets/game-data
- name: Build game data path list
working-directory: workspace/assets
run: |
cp ../../scripts/assets/wanted_sprites.json .
chmod +x ../../scripts/assets/build_gamedata_paths.sh
../../scripts/assets/build_gamedata_paths.sh
- name: Cache game data paths
id: gamedata-paths-cache
uses: actions/cache@v4
with:
path: workspace/assets/gamedata_paths.json
key: gamedata-paths-${{ hashFiles('workspace/assets/gamedata_paths.json') }}
# --- Step 3: If game data paths changed but client manifest did not, extract the client now ---
- name: Extract and catalog assets (game data changed, same client)
if: steps.gamedata-paths-cache.outputs.cache-hit != 'true' && steps.manifest-cache.outputs.cache-hit == 'true'
uses: ./.github/actions/extract-and-catalog
with:
steam-user: ${{ secrets.STEAM_USER }}
actions-token: ${{ secrets.ACTIONS_TOKEN }}
# --- Step 3.5: If either client manifest or game data paths changed, save lists to artifacts
- name: Save catalog and game data paths to artifacts
if: steps.manifest-cache.outputs.cache-hit != 'true' || steps.gamedata-paths-cache.outputs.cache-hit != 'true'
uses: actions/upload-artifact@v7
with:
name: asset-extraction-metadata
path: |
workspace/assets/sprites.json
workspace/assets/gamedata_paths.json
workspace/assets/extracted_pngs.txt
# --- Step 4: Build asset map and convert ---
- name: Map and convert assets
if: steps.manifest-cache.outputs.cache-hit != 'true' || steps.gamedata-paths-cache.outputs.cache-hit != 'true'
working-directory: workspace/assets
run: |
chmod +x ../../scripts/assets/map_and_convert_assets.sh
../../scripts/assets/map_and_convert_assets.sh
- name: Commit and push assets
if: steps.manifest-cache.outputs.cache-hit != 'true' || steps.gamedata-paths-cache.outputs.cache-hit != 'true'
working-directory: workspace/assets/publish
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
if ! git diff --cached --quiet; then
git commit -m "Update assets: $(date +%Y-%m-%d)"
git push origin
fi