forked from DHJComical/Minecraft-mod-classifier
-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (133 loc) · 5.04 KB
/
Copy pathpython-build.yml
File metadata and controls
148 lines (133 loc) · 5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Python Build and Package
on:
push:
branches: [ main, pr0 ]
pull_request:
branches: [ main ]
release:
types: [published]
jobs:
build:
name: Build ${{ matrix.os }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
# Windows builds
- os: windows
arch: x86_64
runner: windows-latest
executable_suffix: ".exe"
archive_ext: zip
# Linux builds (x86_64 only)
- os: linux
arch: x86_64
runner: ubuntu-latest
executable_suffix: ""
archive_ext: tar.gz
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
architecture: ${{ matrix.arch == 'aarch64' && 'arm64' || 'x64' }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller
- name: Create config directory and default config
run: |
mkdir -p config
echo '[]' > config/mods_data.json
# Copy mod_rules.json if exists
if [ -f "config/mod_rules.json" ]; then
cp config/mod_rules.json config/mod_rules.json.bak
fi
shell: bash
- name: Build executable (Windows)
if: matrix.os == 'windows'
run: |
pyinstaller --clean --noconfirm `
--name "Minecraft-mod-classifier" `
--onedir `
--console `
--paths src/python `
--add-data "config/mods_data.json;config" `
--add-data "config/mod_rules.json;config" `
src/python/main.py
shell: pwsh
- name: Build executable (Linux)
if: matrix.os == 'linux'
run: |
pyinstaller --clean --noconfirm \
--name "Minecraft-mod-classifier" \
--onedir \
--console \
--paths src/python \
--add-data "config/mods_data.json:config" \
--add-data "config/mod_rules.json:config" \
src/python/main.py
- name: Prepare release package (Windows)
if: matrix.os == 'windows'
run: |
mkdir -p release/Minecraft-mod-classifier
Copy-Item "dist\Minecraft-mod-classifier\*" "release\Minecraft-mod-classifier\" -Recurse -Force
Copy-Item "README.md" "release\Minecraft-mod-classifier\"
Copy-Item "LICENSE" "release\Minecraft-mod-classifier\"
Copy-Item "docs\QUICKSTART.md" "release\Minecraft-mod-classifier\"
Copy-Item "docs\BUILD_GUIDE.md" "release\Minecraft-mod-classifier\"
Copy-Item "GITHUB_INTEGRATION.md" "release\Minecraft-mod-classifier\"
Remove-Item "release\Minecraft-mod-classifier\Input\*" -Recurse -ErrorAction SilentlyContinue
Remove-Item "release\Minecraft-mod-classifier\Output\*" -Recurse -ErrorAction SilentlyContinue
shell: pwsh
- name: Prepare release package (Linux)
if: matrix.os == 'linux'
run: |
mkdir -p release/Minecraft-mod-classifier
cp -r dist/Minecraft-mod-classifier/* release/Minecraft-mod-classifier/
cp README.md release/Minecraft-mod-classifier/
cp LICENSE release/Minecraft-mod-classifier/
cp docs/QUICKSTART.md release/Minecraft-mod-classifier/
cp docs/BUILD_GUIDE.md release/Minecraft-mod-classifier/
cp GITHUB_INTEGRATION.md release/Minecraft-mod-classifier/
rm -rf release/Minecraft-mod-classifier/Input/*
rm -rf release/Minecraft-mod-classifier/Output/*
chmod +x release/Minecraft-mod-classifier/Minecraft-mod-classifier
- name: Create archive (Windows)
if: matrix.os == 'windows'
run: |
cd release
Compress-Archive -Path Minecraft-mod-classifier -DestinationPath "minecraft-mod-classifier-${{ matrix.os }}-${{ matrix.arch }}.${{ matrix.archive_ext }}"
shell: pwsh
- name: Create archive (Linux)
if: matrix.os == 'linux'
run: |
cd release
tar -czf "minecraft-mod-classifier-${{ matrix.os }}-${{ matrix.arch }}.${{ matrix.archive_ext }}" Minecraft-mod-classifier
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: minecraft-mod-classifier-${{ matrix.os }}-${{ matrix.arch }}
path: release/minecraft-mod-classifier-${{ matrix.os }}-${{ matrix.arch }}.${{ matrix.archive_ext }}
retention-days: 30
release:
if: github.event_name == 'release'
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
files: |
release-artifacts/*/*.zip
release-artifacts/*/*.tar.gz
token: ${{ secrets.GITHUB_TOKEN }}