1+ name : " Commit and Build TelegramChat"
2+
3+ on :
4+ push :
5+ branches : ['master']
6+
7+ jobs :
8+ build-and-release :
9+ runs-on : ubuntu-latest
10+ name : " Check and Package"
11+ steps :
12+ - name : " Checkout"
13+ uses : actions/checkout@v4
14+
15+ - name : " Generate Short Hash"
16+ id : short_hash
17+ run : |
18+ SHORT_HASH=$(echo "${{ github.sha }}" | cut -c1-7)
19+ echo "short_hash=$SHORT_HASH" >> $GITHUB_OUTPUT
20+
21+ - name : " Install Python"
22+ run : |
23+ sudo apt-get update
24+ sudo apt-get install -y python3 python3-pip git zip
25+
26+ - name : " Check Version from Files"
27+ id : check_version
28+ run : |
29+ PLUGIN_VERSION=$(jq -r '.version' mcdreforged.plugin.json)
30+
31+ echo "Plugin version from mcdreforged.plugin.json: $PLUGIN_VERSION"
32+
33+ PYTHON_VERSION=$(python -c "import importlib.util, sys; spec = importlib.util.spec_from_file_location('version', 'telegram_chat/const.py'); version = importlib.util.module_from_spec(spec); sys.modules['version'] = version; spec.loader.exec_module(version); print(version.VERSION_STR)")
34+
35+ echo "Python VERSION_STR: $PYTHON_VERSION"
36+
37+ if [ "$PLUGIN_VERSION" != "$PYTHON_VERSION" ]; then
38+ echo "Version mismatch: Plugin version and Python VERSION_STR do not match."
39+ exit 1
40+ else
41+ echo "Version match: Proceeding with the build."
42+ fi
43+
44+ echo "version=$TAG_VERSION" >> $GITHUB_OUTPUT
45+
46+ - name : " Create Exclude List from .packignore"
47+ id : exclude_list
48+ run : |
49+ # Check if .packignore exists and create an exclude list
50+ if [ -f ".packignore" ]; then
51+ # Read the .packignore file and format for zip exclusion
52+ EXCLUDE_LIST=$(cat .packignore | sed 's|^|"|' | sed 's|$|"|' | tr '\n' ' ')
53+ echo "Exclude list: $EXCLUDE_LIST"
54+ echo "exclude_list=-x $EXCLUDE_LIST" >> $GITHUB_OUTPUT
55+ else
56+ echo ".packignore not found, no files will be excluded."
57+ echo "exclude_list=" >> $GITHUB_OUTPUT
58+ fi
59+
60+ - name : " Package the Plugin"
61+ run : |
62+ # Create the zip file excluding files listed in .packignore
63+ zip -r TelegramChat-${{ steps.check_version.outputs.version }}-beta-${{ steps.short_hash.outputs.short_hash }}.zip * \
64+ ${{ steps.exclude_list.outputs.exclude_list }}
65+ mv TelegramChat-${{ steps.check_version.outputs.version }}-beta-${{ steps.short_hash.outputs.short_hash }}.zip TelegramChat-${{ steps.check_version.outputs.version }}-beta-${{ steps.short_hash.outputs.short_hash }}.mcdr
66+
67+ - name : " Upload Artifact"
68+ uses : actions/upload-artifact@v4
69+ with :
70+ name : " TelegramChat-${{ steps.check_version.outputs.version }}-beta-${{ steps.short_hash.outputs.short_hash }}.mcdr"
71+ path : " TelegramChat-${{ steps.check_version.outputs.version }}-beta-${{ steps.short_hash.outputs.short_hash }}.mcdr"
0 commit comments