Skip to content

Commit

Permalink
Merge pull request #103 from macarooni-man/dev
Browse files Browse the repository at this point in the history
v2.2.4
  • Loading branch information
macarooni-man authored Nov 11, 2024
2 parents eddad79 + e0475a7 commit a4bfcf1
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 52 deletions.
95 changes: 92 additions & 3 deletions .github/workflows/compiler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ jobs:
chmod +x dist/auto-mcs.app/Contents/MacOS/auto-mcs
# Create .dmg from .app
while : ; do
[[ -f "$root/build-tools/dist/auto-mcs.dmg" ]] && break
sleep 1
max_attempts=5
attempt=1
set +e
while [ $attempt -le $max_attempts ]; do
# Attempt to create the disk image
sudo create-dmg \
--volname "auto-mcs" \
--volicon "$root/other/macos-dmg/icon.icns" \
Expand All @@ -122,6 +125,23 @@ jobs:
--app-drop-link 593 277 \
"$root/build-tools/dist/auto-mcs.dmg" \
"$root/build-tools/dist/auto-mcs.app"
# Check if the .dmg file was created successfully
if [[ -f "$root/build-tools/dist/auto-mcs.dmg" ]]; then
echo "Disk image created successfully."
break
else
echo "Attempt $attempt failed: Disk image creation resource is busy."
attempt=$(( attempt + 1 ))
sleep 5 # Wait for a few seconds before retrying
fi
# Fail if max attempts are reached
if [ $attempt -gt $max_attempts ]; then
echo "Failed to create disk image after $max_attempts attempts."
set -e
exit 1
fi
done
- name: Upload Binary
Expand Down Expand Up @@ -414,6 +434,75 @@ jobs:



# Upload artifacts to auto-mcs cloud
upload-cloud:
name: Upload to auto-mcs cloud
runs-on: ubuntu-latest
needs: [setup-env, windows, macos, linux, linux-arm, alpine, alpine-arm]
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts

- name: List Downloaded Artifacts (Debugging)
run: |
echo "Downloaded artifacts:"
ls -R ./artifacts
- name: Upload Artifacts
env:
CLOUD_URL: ${{ secrets.CLOUD_URL }}
CLOUD_USERNAME: ${{ secrets.CLOUD_USERNAME }}
CLOUD_PASSWORD: ${{ secrets.CLOUD_PASSWORD }}
APP_VERSION: ${{ needs.setup-env.outputs.APP_VERSION }}
run: |
# Verify remote folder exists
version_folder="${APP_VERSION}-beta"
echo "Creating directory ${version_folder} if it doesn't exist..."
curl -u "$CLOUD_USERNAME:$CLOUD_PASSWORD" -X MKCOL "${CLOUD_URL}/${version_folder}" || echo "Directory already exists or creation failed"
find ./artifacts -type f | while read file; do
# Extract platform name by removing version numbers and trailing hyphens
dir_name=$(basename $(dirname "$file"))
platform_name=$(echo "$dir_name" | sed -E 's/-[0-9]+(\.[0-9]+)*(-beta\.[0-9]+)?$//')
platform_name="${platform_name%-}" # Remove any trailing hyphens
# Check if the file has an extension; if not, add ".bin" as a placeholder
base_filename=$(basename "$file")
if [[ "$base_filename" == *.* ]]; then
extension="${base_filename##*.}"
new_filename="${platform_name}-${APP_VERSION}-beta.${extension}"
else
new_filename="${platform_name}-${APP_VERSION}-beta.bin"
fi
echo "Uploading $new_filename to ${CLOUD_URL}/${version_folder}..."
# Upload the file to the versioned subfolder with the new name
curl -u "$CLOUD_USERNAME:$CLOUD_PASSWORD" -T "$file" "${CLOUD_URL}/${version_folder}/${new_filename}"
done
# Upload metadata
echo "Commit: ${{ github.sha }}" > ./commit-metadata.txt
echo "URL: https://github.com/macarooni-man/auto-mcs/commit/${{ github.sha }}" >> ./commit-metadata.txt
echo "Author: ${{ github.actor }}" >> ./commit-metadata.txt
echo "Repository: ${{ github.repository }}" >> ./commit-metadata.txt
echo "Branch: ${{ github.ref_name }}" >> ./commit-metadata.txt
echo "Workflow Run: ${{ github.run_id }}" >> ./commit-metadata.txt
echo "Timestamp: $(date)" >> ./commit-metadata.txt
curl -u "$CLOUD_USERNAME:$CLOUD_PASSWORD" -T "./commit-metadata.txt" "${CLOUD_URL}/${version_folder}/commit-metadata.txt"
# Upload source code
source="auto-mcs-source-${APP_VERSION}-beta.zip"
curl -L -o ./${source} \
https://github.com/${{ github.repository }}/archive/refs/heads/${{ github.ref_name }}.zip
curl -u "$CLOUD_USERNAME:$CLOUD_PASSWORD" -T "${source}" "${CLOUD_URL}/${version_folder}/${source}"
# Publish images to Docker Hub
publish-docker:
name: Publish Docker image
Expand Down
10 changes: 5 additions & 5 deletions source/addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def get_addon_file(addon_path: str, server_properties, enabled=False):
if server_type == "bukkit":
try:
jar_file.extract('plugin.yml', addon_tmp)
with open(os.path.join(addon_tmp, 'plugin.yml'), 'r') as yml:
with open(os.path.join(addon_tmp, 'plugin.yml'), 'r', encoding='utf-8', errors='ignore') as yml:
addon_type = server_type
next_line_desc = False
for line in yml.readlines():
Expand Down Expand Up @@ -420,7 +420,7 @@ def get_addon_file(addon_path: str, server_properties, enabled=False):
# Check if mcmod.info exists
try:
jar_file.extract('mcmod.info', addon_tmp)
with open(os.path.join(addon_tmp, 'mcmod.info'), 'r') as info:
with open(os.path.join(addon_tmp, 'mcmod.info'), 'r', encoding='utf-8', errors='ignore') as info:
addon_type = server_type
for line in info.readlines():
if addon_author and addon_name and addon_version and addon_subtitle and addon_id:
Expand Down Expand Up @@ -456,7 +456,7 @@ def get_addon_file(addon_path: str, server_properties, enabled=False):
except:
pass
for file in glob(os.path.join(addon_tmp, 'META-INF', '*mods.toml')):
with open(file, 'r') as toml:
with open(file, 'r', encoding='utf-8', errors='ignore') as toml:
addon_type = server_type
file_contents = toml.read().split("[[dependencies")[0].replace(' = ', '=')
for line in file_contents.splitlines():
Expand Down Expand Up @@ -499,7 +499,7 @@ def get_addon_file(addon_path: str, server_properties, enabled=False):
except:
pass

with open(file_path, 'r') as mod:
with open(file_path, 'r', encoding='utf-8', errors='ignore') as mod:
file_contents = json.loads(mod.read())

# Quilt mods
Expand Down Expand Up @@ -1100,7 +1100,7 @@ def find_addon(name, server_properties):
try:
new_addon = sorted(
[
[addon, round(SequenceMatcher(None, addon.name.lower(), name.lower()).ratio(), 2) if addon.id.lower() != name else 1000]
[addon, round(SequenceMatcher(None, addon.name.lower(), name.lower()).ratio(), 2) if (not addon.id or addon.id.lower() != name) else 1000]
for addon in search_addons(name, server_properties)
], key=lambda x: x[1], reverse=True)[0][0]

Expand Down
Loading

0 comments on commit a4bfcf1

Please sign in to comment.