-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: 'Generate Assets' | ||
on: | ||
schedule: | ||
- cron: "30 0,12 * * *" # Runs at 00:30 and 12:30, every day | ||
|
||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
actions: read | ||
checks: write | ||
|
||
jobs: | ||
check-version: | ||
name: 'Check version' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: 'Check for version change' | ||
id: 'minecraft-manifest' | ||
uses: MinecraftPlayground/minecraft-manifest@main | ||
with: | ||
token: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: 'Check for existing version' | ||
id: 'check-existing-tag' | ||
if: steps.minecraft-manifest.outputs.version-changed | ||
uses: mukunku/tag-exists-action@v1.6.0 | ||
with: | ||
tag: ${{steps.minecraft-manifest.outputs.version-current-snapshot}} | ||
|
||
outputs: | ||
generate-new: ${{steps.minecraft-manifest.outputs.version-changed && steps.check-existing-tag.outputs.exists == 'false'}} | ||
version-current-snapshot: ${{steps.minecraft-manifest.outputs.version-current-snapshot}} | ||
version-current-snapshot-url: ${{steps.minecraft-manifest.outputs.version-current-snapshot-url}} | ||
|
||
generate-new-assets: | ||
name: 'Generate new assets' | ||
runs-on: ubuntu-latest | ||
needs: [check-version] | ||
if: needs.check-version.outputs.generate-new == 'true' | ||
steps: | ||
- name: 'Download JSON manifest file' | ||
run: | | ||
mkdir ./download | ||
curl -L -o ./download/manifest.json ${{needs.check-version.outputs.version-current-snapshot-url}} | ||
- name: 'Downloading client.jar' | ||
run: | | ||
JAR_URL=$(jq -r '.downloads.client.url' ./download/manifest.json) | ||
echo "Downloading client.jar from $JAR_URL" | ||
curl -L -o ./download/client.jar $JAR_URL | ||
- name: 'Extracting assets' | ||
run: | | ||
mkdir -p ./generated | ||
unzip ./download/client.jar "pack.png" -d "./generated" | ||
unzip ./download/client.jar "assets/*" -d "./generated" | ||
- name: 'Uploading artifact' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: 'generated' | ||
path: './generated' | ||
|
||
outputs: | ||
version-current-snapshot: ${{needs.check-version.outputs.version-current-snapshot}} | ||
|
||
commit-and-tag-new-assets: | ||
name: 'Commit and tag new assets' | ||
runs-on: ubuntu-latest | ||
needs: [generate-new-assets] | ||
env: | ||
VERSION_CURRENT_SNAPSHOT: "${{needs.generate-new-assets.outputs.version-current-snapshot}}" | ||
|
||
steps: | ||
- name: 'Checkout repository' | ||
uses: actions/checkout@v4 | ||
|
||
- name: 'Remove old assets' | ||
run: | | ||
git rm -rf --ignore-unmatch "./generated" | ||
- name: 'Add new assets' | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: 'generated' | ||
path: './generated' | ||
|
||
- name: 'Commit and push assets' | ||
run: | | ||
echo "Commit Message: New assets for version ${{env.VERSION_CURRENT_SNAPSHOT}}" | ||
echo "Tag: ${{env.VERSION_CURRENT_SNAPSHOT}}" | ||
echo "Tag Message: Release ${{env.VERSION_CURRENT_SNAPSHOT}}" | ||
git config --local user.name "github-actions[bot]" | ||
git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
git add "./generated" | ||
git commit -a -m "New assets for version ${{env.VERSION_CURRENT_SNAPSHOT}}" || exit 0 | ||
git tag -a "${{env.VERSION_CURRENT_SNAPSHOT}}" -m "Release ${{env.VERSION_CURRENT_SNAPSHOT}}" | ||
git push origin main --tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.vscode/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
# data | ||
# Version controlled history of Minecraft's generated assets | ||
This repository runs a workflow every 12 hours to check for a new version and generate new assets for the latest version. New versions are tagged and pushed to the repository. | ||
|
||
## Disclaimer | ||
This repository is working under the assumption that, because they intentionally provide a public API for downloading the `client.jar`, Mojang does not have anything against the resulting generated assets existing somewhere on the internet for public consumption. If ever this assumption is contradicted, the repository will be promptly removed. |