mirror of
https://github.com/NekoMonci12/mine-compress.git
synced 2025-12-19 15:09:20 +00:00
Initial Commit
This commit is contained in:
2
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
2
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links: []
|
||||||
25
.github/ISSUE_TEMPLATE/optimize_request.yml
vendored
Normal file
25
.github/ISSUE_TEMPLATE/optimize_request.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
name: Optimize Resource Pack
|
||||||
|
description: Upload your resource pack as a .zip and get back an optimized version.
|
||||||
|
title: "[Optimize] Resource Pack Optimization Request"
|
||||||
|
labels: [optimize-request]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
🎯 **This request will automatically trigger an optimization workflow.**
|
||||||
|
Please ensure your `.zip` file is uploaded somewhere publicly accessible (GitHub, GDrive, Dropbox with direct links, etc).
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: zip_link
|
||||||
|
attributes:
|
||||||
|
label: Public Download Link to .zip
|
||||||
|
description: Paste the full URL to the .zip file that contains your resource pack.
|
||||||
|
placeholder: "https://example.com/my-pack.zip"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: notes
|
||||||
|
attributes:
|
||||||
|
label: Notes or Extra Info (Optional)
|
||||||
|
description: Add anything else we need to know (e.g. Minecraft version, compression preferences).
|
||||||
66
.github/workflows/optimize.yml
vendored
Normal file
66
.github/workflows/optimize.yml
vendored
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
name: Optimize Resource Pack
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [labeled]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
process_resource_pack:
|
||||||
|
# Only run if the added label is 'optimize-request'
|
||||||
|
if: github.event.label.name == 'optimize-request'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Extract .zip link from issue body
|
||||||
|
id: extract
|
||||||
|
run: |
|
||||||
|
echo "Issue body:"
|
||||||
|
echo "${{ github.event.issue.body }}"
|
||||||
|
|
||||||
|
ZIP_URL=$(echo "${{ github.event.issue.body }}" | grep -oP 'https?://\S+\.zip')
|
||||||
|
|
||||||
|
if [[ -z "$ZIP_URL" ]]; then
|
||||||
|
echo "No .zip URL found in issue body. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "zip_url=$ZIP_URL" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Download and unzip resource pack
|
||||||
|
run: |
|
||||||
|
mkdir input
|
||||||
|
cd input
|
||||||
|
curl -L "${{ steps.extract.outputs.zip_url }}" -o pack.zip
|
||||||
|
unzip pack.zip -d unpacked
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y optipng ffmpeg zip
|
||||||
|
|
||||||
|
- name: Optimize PNG files
|
||||||
|
run: |
|
||||||
|
find input/unpacked -type f -iname '*.png' | while read -r file; do
|
||||||
|
echo "Optimizing: $file"
|
||||||
|
optipng -o7 "$file"
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Compress OGG files
|
||||||
|
run: |
|
||||||
|
find input/unpacked -type f -iname '*.ogg' | while read -r file; do
|
||||||
|
echo "Compressing: $file"
|
||||||
|
ffmpeg -y -i "$file" -ac 1 -ab 64k "${file}.tmp.ogg"
|
||||||
|
if [[ -f "${file}.tmp.ogg" ]]; then
|
||||||
|
mv -f "${file}.tmp.ogg" "$file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Re-zip optimized pack
|
||||||
|
run: |
|
||||||
|
cd input/unpacked
|
||||||
|
zip -r ../../optimized-pack.zip .
|
||||||
|
|
||||||
|
- name: Upload optimized resource pack
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: optimized-pack
|
||||||
|
path: optimized-pack.zip
|
||||||
68
optimize_script.sh
Normal file
68
optimize_script.sh
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# =========[ Auto Dependency Installer ]=========
|
||||||
|
install_dependencies() {
|
||||||
|
echo "Checking and installing dependencies: optipng, ffmpeg"
|
||||||
|
|
||||||
|
# Detect package manager
|
||||||
|
if command -v apt >/dev/null; then
|
||||||
|
PKG_INSTALL="sudo apt install -y"
|
||||||
|
PKG_UPDATE="sudo apt update"
|
||||||
|
elif command -v dnf >/dev/null; then
|
||||||
|
PKG_INSTALL="sudo dnf install -y"
|
||||||
|
PKG_UPDATE="sudo dnf check-update"
|
||||||
|
elif command -v pacman >/dev/null; then
|
||||||
|
PKG_INSTALL="sudo pacman -S --noconfirm"
|
||||||
|
PKG_UPDATE="sudo pacman -Sy"
|
||||||
|
else
|
||||||
|
echo "Unsupported package manager. Please install 'optipng' and 'ffmpeg' manually."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update package list and install
|
||||||
|
$PKG_UPDATE
|
||||||
|
$PKG_INSTALL optipng ffmpeg
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if tools are already installed
|
||||||
|
if ! command -v optipng >/dev/null || ! command -v ffmpeg >/dev/null; then
|
||||||
|
install_dependencies
|
||||||
|
else
|
||||||
|
echo "Dependencies already installed."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# =========[ User Input ]=========
|
||||||
|
read -rp "Enter the full path to your resource pack folder: " target_folder
|
||||||
|
|
||||||
|
if [[ ! -d "$target_folder" ]]; then
|
||||||
|
echo "Folder does not exist: $target_folder"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# =========[ PNG Optimization ]=========
|
||||||
|
echo "========================"
|
||||||
|
echo "Optimizing PNG files..."
|
||||||
|
echo "========================"
|
||||||
|
|
||||||
|
find "$target_folder" -type f -iname '*.png' | while read -r file; do
|
||||||
|
echo "Processing: $file"
|
||||||
|
optipng -o7 "$file"
|
||||||
|
done
|
||||||
|
|
||||||
|
# =========[ OGG Compression ]=========
|
||||||
|
echo "========================"
|
||||||
|
echo "Compressing OGG files..."
|
||||||
|
echo "========================"
|
||||||
|
|
||||||
|
find "$target_folder" -type f -iname '*.ogg' | while read -r file; do
|
||||||
|
echo "Processing: $file"
|
||||||
|
ffmpeg -y -i "$file" -ac 1 -ab 64k "${file}.tmp.ogg"
|
||||||
|
if [[ -f "${file}.tmp.ogg" ]]; then
|
||||||
|
mv -f "${file}.tmp.ogg" "$file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "========================"
|
||||||
|
echo "Optimization complete."
|
||||||
Reference in New Issue
Block a user