Skip to content

Commit

Permalink
v2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehver committed Jun 7, 2024
1 parent 149f7a2 commit e5f805e
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 15 deletions.
48 changes: 48 additions & 0 deletions .github/scripts/ClientPkgReformat.py
Original file line number Diff line number Diff line change
@@ -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 <DIRECTORY>")
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()

71 changes: 56 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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 }}
Expand Down
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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。
<a href='https://hub.docker.com/r/opdmc/template-mcserver'><img src="https://img.shields.io/badge/-DockerHub-1c90ed?style=flat&amp;logo=Docker&amp;logoColor=white" referrerpolicy="no-referrer" alt="DockerHub"></a> <a href='https://github.com/OPDMC/Template-MCServer/pkgs/container/template-mcserver'><img src="https://img.shields.io/badge/-Ghcr.io-8957E5?style=flat&amp;logo=GitHub&amp;logoColor=white" referrerpolicy="no-referrer" alt="Ghcr.io"></a>

![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]
Expand Down
16 changes: 16 additions & 0 deletions minecraft_client_modpack/README.txt
Original file line number Diff line number Diff line change
@@ -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.

File renamed without changes.
File renamed without changes.

0 comments on commit e5f805e

Please sign in to comment.