diff --git a/.github/scripts/ClientPkgReformat.py b/.github/scripts/ClientPkgReformat.py new file mode 100644 index 0000000..da92714 --- /dev/null +++ b/.github/scripts/ClientPkgReformat.py @@ -0,0 +1,48 @@ +# pip install pyunpack patool + +import sys +import os +import patoolib + +def is_multi_part_zip(file_path): + z01_file = file_path[:-4] + ".z01" # Replace the last .zip with .z01 + return os.path.exists(z01_file) + +def delete_original_files(file_path): + base_name = file_path[:-4] + files_to_delete = [file_path] + [base_name + ext for ext in ['.zip', '.z01', '.z02', '.z03', '.z04', '.z05', '.z06', '.z07', '.z08', '.z09']] + for file in files_to_delete: + if os.path.exists(file): + os.remove(file) + print(f"Deleted: {file}") + +def unzip_files(directory): + for root, dirs, files in os.walk(directory): + for file in files: + file_path = os.path.join(root, file) + if (file.endswith('.jar.zip') or file.endswith('.zip.zip')) and is_multi_part_zip(file_path): + print(f"Processing file: {file_path}") + try: + patoolib.extract_archive(file_path, outdir=root) + print(f"Unzipped: {file_path}") + # Delete original files after successful extraction + delete_original_files(file_path) + except Exception as e: + print(f"Error unzipping {file_path}: {e}") + +def main(): + if len(sys.argv) != 2: + print("Usage: ClientPkgReformat.py ") + sys.exit(1) + + directory = sys.argv[1] + + if not os.path.isdir(directory): + print(f"Error: {directory} is not a valid directory.") + sys.exit(1) + + unzip_files(directory) + +if __name__ == "__main__": + main() + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7fb406e..af4f4b9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -103,26 +103,41 @@ jobs: REPO_NAME_LOWER=$(echo $REPO_NAME | tr '[:upper:]' '[:lower:]') RELEASE_TAG=$(echo ${{ github.ref }} | sed 's/refs\/tags\///') RELEASE_TAG_LOWER=$(echo $RELEASE_TAG | tr '[:upper:]' '[:lower:]') - TEMP_DIR="client-version-pkg_${REPO_NAME_LOWER}_${RELEASE_TAG_LOWER}" + TEMP_DIR="client-versionpack_${REPO_NAME_LOWER}_${RELEASE_TAG_LOWER}" + TEMP_MOD_DIR="client-modpack_${REPO_NAME_LOWER}_${RELEASE_TAG_LOWER}" echo "::set-output name=repo_name::$REPO_NAME" echo "::set-output name=repo_name_lower::$REPO_NAME_LOWER" echo "::set-output name=release_tag::$RELEASE_TAG" echo "::set-output name=release_tag_lower::$RELEASE_TAG_LOWER" echo "::set-output name=temp_dir::$TEMP_DIR" + echo "::set-output name=temp_mod_dir::$TEMP_MOD_DIR" - - name: Create temporary directory - run: mkdir ${{ steps.vars.outputs.temp_dir }} + - name: Create temporary directory for version package + run: mkdir -p ${{ steps.vars.outputs.temp_dir }} - - name: Copy minecraft_client to temporary directory - run: cp -r minecraft_client ${{ steps.vars.outputs.temp_dir }}/${{ steps.vars.outputs.repo_name }} + - name: Copy minecraft_client_versionpack to temporary directory + run: cp -r minecraft_client_versionpack ${{ steps.vars.outputs.temp_dir }}/${{ steps.vars.outputs.repo_name }} - - name: Zip the directory + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install Python dependencies + run: | + pip install --upgrade pip + pip install pyunpack patool + + - name: Run ClientPkgReformat.py script + run: python .github/scripts/ClientPkgReformat.py ${{ steps.vars.outputs.temp_dir }}/${{ steps.vars.outputs.repo_name }} + + - name: Zip the directory for version package run: | cd ${{ steps.vars.outputs.temp_dir }} zip -r ../${{ steps.vars.outputs.temp_dir }}.zip . cd .. - - name: Upload zip to release + - name: Upload version package zip to release uses: actions/upload-release-asset@v1 with: upload_url: ${{ github.event.release.upload_url }} @@ -132,6 +147,28 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + - name: Create temporary directory for modpack + run: mkdir -p ${{ steps.vars.outputs.temp_mod_dir }} + + - name: Copy minecraft_client_modpack to temporary directory for modpack + run: cp -r minecraft_client_modpack/* ${{ steps.vars.outputs.temp_mod_dir }} + + - name: Zip the directory for modpack + run: | + cd ${{ steps.vars.outputs.temp_mod_dir }} + zip -r ../${{ steps.vars.outputs.temp_mod_dir }}.zip . + cd .. + + - name: Upload modpack zip to release + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ${{ steps.vars.outputs.temp_mod_dir }}.zip + asset_name: ${{ steps.vars.outputs.temp_mod_dir }}.zip + asset_content_type: application/zip + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + handle-file-uploads: runs-on: ubuntu-latest @@ -155,15 +192,18 @@ jobs: tag_count=$(echo "$tags" | wc -w) echo "Tag count: $tag_count" if [ "$tag_count" -lt 2 ]; then - echo "Error: Not enough tags to determine previous tag." >&2 - exit 1 - fi - prev_tag=$(echo "$tags" | awk '{print $2}') - if [ -z "$prev_tag" ]; then - echo "Error: Could not determine previous tag." >&2 - exit 1 + echo "Not enough tags to determine previous tag." + echo "UPDATE_README=false" >> $GITHUB_ENV + prev_tag="" + else + prev_tag=$(echo "$tags" | awk '{print $2}') + if [ -z "$prev_tag" ]; then + echo "Error: Could not determine previous tag." >&2 + exit 1 + fi + echo "Previous tag is $prev_tag" + echo "UPDATE_README=true" >> $GITHUB_ENV fi - echo "Previous tag is $prev_tag" echo "PREV_TAG=$prev_tag" >> $GITHUB_ENV - name: Get current tag @@ -175,6 +215,7 @@ jobs: run: echo "BRANCH=main" >> $GITHUB_ENV - name: Update version numbers + if: env.PREV_TAG != '' env: GITHUB_WORKSPACE: ${{ github.workspace }} PREV_TAG: ${{ env.PREV_TAG }} diff --git a/CHANGELOG.md b/CHANGELOG.md index fc3db8f..591445c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,50 @@ §§template§§§§template§§§§template§§ +![Docker Image Size (tag)](https://img.shields.io/docker/image-size/opdmc/template-mcserver/v2.2?arch=amd64&label=AMD64%20v2.2&color=006688) ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/opdmc/template-mcserver/v2.2?arch=arm64&label=ARM64%20v2.2&color=008866) + ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/opdmc/template-mcserver/v2.1?arch=amd64&label=AMD64%20v2.1&color=006688) ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/opdmc/template-mcserver/v2.1?arch=arm64&label=ARM64%20v2.1&color=008866) ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/opdmc/template-mcserver/v2.0?arch=amd64&label=AMD64%20v2.0&color=006688) ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/opdmc/template-mcserver/v2.0?arch=arm64&label=ARM64%20v2.0&color=008866) --- +# [Template-MCServer v2.2](https://github.com/OPDMC/Template-MCServer/releases/tag/v2.2) + +> [!IMPORTANT] +> By using this project, you acknowledge and agree that the [Minecraft EULA](https://account.mojang.com/documents/minecraft_eula) is automatically set to TRUE. +> +> 使用本项目即表示您承认并同意 [Minecraft EULA](https://account.mojang.com/documents/minecraft_eula) 已自动设置为 TRUE。 + +DockerHub Ghcr.io + +![Docker Image Size (tag)](https://img.shields.io/docker/image-size/opdmc/template-mcserver/v2.2?arch=amd64&label=AMD64%20v2.2&color=006688) ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/opdmc/template-mcserver/v2.2?arch=arm64&label=ARM64%20v2.2&color=008866) + +### Release Notes + +- Upgraded Workflows +- Provided Curseforge Modpack for Client + +### Usage + +```shell +# DockerHub +docker pull opdmc/template-mcserver:v2.2 +# Ghcr.io +docker pull ghcr.io/opdmc/template-mcserver:v2.2 +``` + +```shell +docker run -d \ + --name=1.19.4-opdmc \ + -p 127.0.0.1:80:25565/tcp \ + -v /path/to/store/data:/minecraft \ + opdmc/1.19.4-opdmodcarpet:latest +``` + +### Changelog + +**Full Changelog**: https://github.com/OPDMC/Template-MCServer/compare/v2.1...v2.2 + # [Template-MCServer v2.1](https://github.com/OPDMC/Template-MCServer/releases/tag/v2.1) > [!IMPORTANT] diff --git a/minecraft_client_modpack/README.txt b/minecraft_client_modpack/README.txt new file mode 100644 index 0000000..9ca09f9 --- /dev/null +++ b/minecraft_client_modpack/README.txt @@ -0,0 +1,16 @@ +# 玩家指南 For Players + +如果要使用此 Modpack,你不应该解压此文件夹。请直接在支持 Curseforge Modpack 的启动器中导入此 Modpack。 + +If you want to use this Modpack, you should not extract this folder. Please import this Modpack directly in the launcher that supports Curseforge Modpack. + +# For GitHub Users + +这是 Curseforge 的 Modpack 目录。最低要求只有 `manifest.json`。其他文件,如 `overrides` 文件夹,也可以包含在内。 + +This is the modpack dir for Curseforge. Minimal requirements are only `manifest.json`. Other files like `overrides` folder may be included. + +如果客户端没有特殊需要,可以关闭客户端打包的 Action Workflow 并删除此文件夹。 + +If the client has no special needs, you can disable the client packaging Action Workflow and delete this folder. + diff --git a/minecraft_client/README.txt b/minecraft_client_versionpack/README.txt similarity index 100% rename from minecraft_client/README.txt rename to minecraft_client_versionpack/README.txt diff --git a/minecraft_client/mods/README.txt b/minecraft_client_versionpack/mods/README.txt similarity index 100% rename from minecraft_client/mods/README.txt rename to minecraft_client_versionpack/mods/README.txt