1- name : Build and Release ModpackDebuggerKit
1+ name : Build and Release MDK
22
33on :
44 push :
5- branches : [ main ]
5+ branches :
6+ - main
67 paths :
7- - " version"
8- - " .github/workflows/build-and-release.yml"
9- workflow_dispatch :
8+ - ' version'
9+ - ' .github/workflows/build-and-release.yml'
1010
1111jobs :
1212 build :
13- name : Build for ${{ matrix.os }}
14- runs-on : ${{ matrix.runner }}
1513 strategy :
1614 matrix :
15+ os : [windows-latest, ubuntu-latest, macos-latest]
1716 include :
18- - os : Windows
19- runner : windows-latest
20- suffix : Win64
21- - os : Linux
22- runner : ubuntu-latest
23- suffix : Linux
24- - os : macOS
25- runner : macos-latest
26- suffix : macOS
17+ - os : windows-latest
18+ asset_os_name : Win64
19+ - os : ubuntu-latest
20+ asset_os_name : Linux
21+ - os : macos-latest
22+ asset_os_name : macOS
23+
24+ runs-on : ${{ matrix.os }}
2725
2826 steps :
2927 - name : Checkout repository
3028 uses : actions/checkout@v4
3129
30+ - name : Read version from file
31+ id : get_version
32+ run : echo "VERSION=$(cat version)" >> $GITHUB_ENV
33+
3234 - name : Set up Python
3335 uses : actions/setup-python@v5
3436 with :
35- python-version : " 3.11"
37+ python-version : ' 3.11'
3638
37- - name : Install PyInstaller
38- run : pip install --quiet pyinstaller
39+ - name : Install dependencies
40+ run : |
41+ python -m pip install --upgrade pip
42+ pip install -r requirements.txt
3943
40- - name : Read version
41- id : version
42- run : echo "version=$(cat version)" >> $GITHUB_OUTPUT
44+ - name : Build with PyInstaller
45+ run : pyinstaller modpack_debugger.py --name ModpackDebuggerKit
4346
44- - name : Build executable (multi-file)
47+ - name : Zip the build (Windows)
48+ if : runner.os == 'Windows'
4549 run : |
46- echo "Building PyInstaller package..."
47- pyinstaller --noconfirm --onedir modpack_debugger.py --name modpack_debugger --clean --quiet
48- shell : bash
50+ Compress-Archive -Path dist/ModpackDebuggerKit -DestinationPath ModpackDebuggerKit_${{ env.VERSION }}_${{ matrix.asset_os_name }}.zip
4951
50- - name : Zip distribution
52+ - name : Zip the build (Linux/macOS)
53+ if : runner.os != 'Windows'
5154 run : |
5255 cd dist
53- folder=$(ls -1 | head -n 1)
54- zip -r "../ModpackDebuggerKit_${{ steps.version.outputs.version }}_${{ matrix.suffix }}.zip" "$folder"
55- shell : bash
56+ zip -r ../ModpackDebuggerKit_${{ env.VERSION }}_${{ matrix.asset_os_name }}.zip ModpackDebuggerKit
5657
57- - name : Upload artifact
58+ - name : Upload build artifact
5859 uses : actions/upload-artifact@v4
5960 with :
60- name : ModpackDebuggerKit_${{ matrix.suffix }}
61- path : ModpackDebuggerKit_${{ steps.version.outputs.version }}_${{ matrix.suffix }}.zip
61+ name : ModpackDebuggerKit_${{ env.VERSION }}_${{ matrix.asset_os_name }}
62+ path : ModpackDebuggerKit_${{ env.VERSION }}_${{ matrix.asset_os_name }}.zip
6263
63- release :
64- name : Create GitHub Release
65- runs-on : ubuntu-latest
64+ create-release :
6665 needs : build
66+ runs-on : ubuntu-latest
67+ permissions :
68+ contents : write
6769
6870 steps :
6971 - name : Checkout repository
7072 uses : actions/checkout@v4
73+ with :
74+ fetch-depth : 0
7175
72- - name : Read version
73- id : version
74- run : echo "version =$(cat version)" >> $GITHUB_OUTPUT
76+ - name : Read version from file
77+ id : get_version
78+ run : echo "VERSION =$(cat version)" >> $GITHUB_ENV
7579
7680 - name : Download all build artifacts
7781 uses : actions/download-artifact@v4
82+ with :
83+ path : artifacts/
7884
79- - name : Get previous release tag (if any)
80- id : prev
85+ - name : Generate Release Body
86+ id : generate_body
8187 run : |
82- prev=$(gh release list --limit 1 --json tagName --jq '.[0].tagName' || true)
83- echo "previous=$prev" >> $GITHUB_OUTPUT
84- env :
85- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
86-
87- - name : Create release
88- env :
89- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
90- run : |
91- v="${{ steps.version.outputs.version }}"
92- prev="${{ steps.prev.outputs.previous }}"
93- if [ -n "$prev" ]; then
94- changes="See changes since previous release: https://github.com/${{ github.repository }}/compare/$prev...$v"
88+ PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
89+
90+ if [ -z "$PREVIOUS_TAG" ]; then
91+ BODY="This is the first release of Modpack Debugger Kit."
9592 else
96- changes="Initial release."
93+ COMPARE_URL="https://github.com/${{ github.repository }}/compare/${PREVIOUS_TAG}...${{ env.VERSION }}"
94+ BODY="See the changes made since the last release: [${PREVIOUS_TAG}...${{ env.VERSION }}](${COMPARE_URL})"
9795 fi
96+ echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV
97+ echo "$BODY" >> $GITHUB_ENV
98+ echo "EOF" >> $GITHUB_ENV
9899
99- gh release create "$v" \
100- --title "$v" \
101- --notes "$changes" \
102- ModpackDebuggerKit_Win64/ModpackDebuggerKit_${v}_Win64.zip \
103- ModpackDebuggerKit_Linux/ModpackDebuggerKit_${v}_Linux.zip \
104- ModpackDebuggerKit_macOS/ModpackDebuggerKit_${v}_macOS.zip
100+ - name : Create GitHub Release
101+ uses : softprops/action-gh-release@v2
102+ with :
103+ tag_name : ${{ env.VERSION }}
104+ name : ${{ env.VERSION }}
105+ body : ${{ env.RELEASE_BODY }}
106+ files : artifacts/*/*.zip
0 commit comments