From c4f27ba93bd01310ca388eddb96a47749457a146 Mon Sep 17 00:00:00 2001 From: suvajit Date: Mon, 18 Dec 2023 15:20:54 +0530 Subject: [PATCH] build and test --- .github/workflows/build-and-publish.yml | 69 +++++++++++++++++++++++++ .github/workflows/build-and-test.yml | 66 +++++++++++++++++++++++ .gitignore | 2 +- docker-compose.yml | 1 + scripts/downloader.sh | 39 ++++++++++++++ 5 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-and-publish.yml create mode 100644 .github/workflows/build-and-test.yml create mode 100755 scripts/downloader.sh diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml new file mode 100644 index 0000000..fa9bfc0 --- /dev/null +++ b/.github/workflows/build-and-publish.yml @@ -0,0 +1,69 @@ +name: Build and Publish + +env: + FINGERPRINT: b8cb4e1c4ee7485bafc34123e4cb2b5b869b4f93 + GAME_ASSET_URL: https://game-assets.clashofclans.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: ${{ secrets.GCP_BUCKET_NAME }}/assets.zip + + - name: Uploaded URL + run: echo "$FILE" + env: + FILE: ${{ steps.upload-to-gcp.outputs.uploaded }} diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..e5da6f1 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,66 @@ +name: Build and Test + +on: + push: + branches: master + +env: + 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: false + + - name: Upload to GCS + id: upload-to-gcs + uses: google-github-actions/upload-cloud-storage@v2 + with: + path: assets.zip + predefinedAcl: publicRead + destination: ${{ secrets.GCP_BUCKET_NAME }} + + - name: Uploaded URL + run: echo "https://storage.googleapis.com/$GCP_BUCKET_NAME/assets.zip" + env: + FILE: ${{ steps.upload-to-gcs.outputs.uploaded }} + GCP_BUCKET_NAME: ${{ secrets.GCP_BUCKET_NAME }} + diff --git a/.gitignore b/.gitignore index 709fa42..1a699f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ In-Compressed/ Out-Sprites/ -Dumpsc \ No newline at end of file +assets/ \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index a0852fb..55b9308 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ version: "3.6" services: dumpsc: container_name: dumpsc + image: dumpsc:latest build: context: . volumes: diff --git a/scripts/downloader.sh b/scripts/downloader.sh new file mode 100755 index 0000000..b39f98d --- /dev/null +++ b/scripts/downloader.sh @@ -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!"