Skip to content

Commit

Permalink
build and test
Browse files Browse the repository at this point in the history
  • Loading branch information
csuvajit committed Dec 24, 2023
1 parent fe33357 commit d4332a5
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 1 deletion.
70 changes: 70 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Build and Publish

env:
FINGERPRINT: b8cb4e1c4ee7485bafc34123e4cb2b5b869b4f93
GAME_ASSET_URL: https://game-assets.clashofclans.com
GCP_BUCKET_NAME: game-assets-clashofclans.appspot.com

on:
release:
types: created
workflow_dispatch:
inputs:
fingerprint:
description: 'Fingerprint'
required: true

jobs:
build:
name: Build and Publish
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set ENV
if: ${{ inputs.fingerprint }}
run: echo "FINGERPRINT=$FINGERPRINT" >> "$GITHUB_ENV"
env:
FINGERPRINT: ${{ inputs.fingerprint }}

- name: Download Game Assets
run: |
chmod +x ./scripts/downloader.sh
echo "Downloading files with the fingerprint $FINGERPRINT"
./scripts/downloader.sh $FINGERPRINT
- name: Copy Files
run: cp -r assets/sc/ In-Compressed/

- name: Docker Build
run: docker build --tag dumpsc:latest ./

- name: Docker Run
run: |
docker run \
--name dumpsc \
-v $(pwd)/Out-Sprites:/Out-Sprites \
-v $(pwd)/In-Compressed:/In-Compressed \
dumpsc:latest
- name: Compress Files
run: zip assets.zip Out-Sprites/**/*.png

- id: auth
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS_JSON }}
export_environment_variables: true

- id: upload-to-gcp
uses: google-github-actions/upload-cloud-storage@v2
with:
path: assets.zip
destination: $GCP_BUCKET_NAME

- name: Uploaded URL
run: echo "$FILE"
env:
FILE: ${{ steps.upload-to-gcp.outputs.uploaded }}
66 changes: 66 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build and Test

on:
push:
branches: master

env:
GCP_BUCKET_NAME: game-assets-clashofclans.appspot.com
FINGERPRINT: b8cb4e1c4ee7485bafc34123e4cb2b5b869b4f93
GAME_ASSET_URL: https://game-assets.clashofclans.com
SC_FILE_NAME: ui_cc.sc
SC_TEX_FILE_NAME: ui_cc_tex.sc

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Docker Build
run: docker build --tag dumpsc:latest ./

- name: Download Test File
run: |
mkdir In-Compressed
curl -o In-Compressed/$SC_FILE_NAME $GAME_ASSET_URL/$FINGERPRINT/sc/$SC_FILE_NAME
curl -o In-Compressed/$SC_TEX_FILE_NAME $GAME_ASSET_URL/$FINGERPRINT/sc/$SC_TEX_FILE_NAME
- name: Docker Run
run: |
docker run \
--name dumpsc \
-v $(pwd)/Out-Sprites:/Out-Sprites \
-v $(pwd)/In-Compressed:/In-Compressed \
dumpsc:latest
- name: Showoff
run: |
echo $(ls -R Out-Sprites)
echo "It worked. Damn!"
- name: Compress Files
run: zip assets.zip Out-Sprites/**/*.png

- name: GCP Login
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS_JSON }}
export_environment_variables: true

- name: Upload to GCS
id: upload-to-gcs
uses: google-github-actions/upload-cloud-storage@v2
with:
path: assets.zip
predefinedAcl: publicRead
destination: $GCP_BUCKET_NAME

- name: Uploaded URL
run: echo "https://storage.googleapis.com/$GCP_BUCKET_NAME/$UPLOADED_FILE"
env:
UPLOADED_FILE: ${{ steps.upload-to-gcs.outputs.uploaded }}

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
In-Compressed/
Out-Sprites/
Dumpsc
assets/
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version: "3.6"
services:
dumpsc:
container_name: dumpsc
image: dumpsc:latest
build:
context: .
volumes:
Expand Down
39 changes: 39 additions & 0 deletions scripts/downloader.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

shopt -s extglob # Enable extended globbing

if [ "$#" -eq 1 ]; then
fingerprint="$1"
else
fingerprint="b8cb4e1c4ee7485bafc34123e4cb2b5b869b4f93"
fi

base_url="https://game-assets.clashofclans.com"

# Step 1: Download fingerprint.json
curl -O $base_url/$fingerprint/fingerprint.json

# Step 2: Extract file URLs and SHA from fingerprint.json
file_info=$(grep -Eo '"file":"[^"]+"' fingerprint.json | awk -F'"' '{print $4, $8}')

# Step 3: Download each file from the extracted URLs
while read -r file
do
# Replace backslashes with forward slashes in the file path
file=$(echo "$file" | sed 's/\\\//\//g')

# Check if the file starts with "sc" or "csv", if not, skip it
# if [[ $file == @(sc|csv|logic|localization)/* ]];
if [[ $file == @(sc)/* ]];
then
# Create the directory if it doesn't exist
mkdir -p "assets/$(dirname "$file")"

echo "Downloading $file"
curl -o "assets/$(dirname "$file")/$(basename "$file")" "$base_url/$fingerprint/$file"
# else
# echo "Skipping $file"
fi
done <<< "$file_info"

echo "Download complete!"

0 comments on commit d4332a5

Please sign in to comment.