Merge pull request #16 from WendellCraft/dev #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release MDK | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'version' | |
| - '.github/workflows/build-and-release.yml' | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| os: [windows-latest, ubuntu-latest, macos-latest] | |
| include: | |
| - os: windows-latest | |
| asset_os_name: Win64 | |
| - os: ubuntu-latest | |
| asset_os_name: Linux | |
| - os: macos-latest | |
| asset_os_name: macOS | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Read version from file | |
| id: get_version | |
| run: | | |
| V=$(sed 's/[[:space:]]//g' version) | |
| if [ -z "$V" ]; then | |
| echo "Error: Version file is empty or invalid" | |
| exit 1 | |
| fi | |
| echo "VERSION=$V" >> $GITHUB_ENV | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pyinstaller | |
| pip install -r requirements.txt | |
| - name: Build with PyInstaller | |
| run: pyinstaller modpack_debugger.py --name ModpackDebuggerKit --noconsole | |
| - name: Zip the build (Windows) | |
| if: runner.os == 'Windows' | |
| run: Compress-Archive -Path dist/ModpackDebuggerKit -DestinationPath ModpackDebuggerKit_${{ env.VERSION }}_${{ matrix.asset_os_name }}.zip | |
| - name: Zip the build (Linux/macOS) | |
| if: runner.os != 'Windows' | |
| run: | | |
| cd dist | |
| zip -r ../ModpackDebuggerKit_${{ env.VERSION }}_${{ matrix.asset_os_name }}.zip ModpackDebuggerKit | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ModpackDebuggerKit_${{ env.VERSION }}_${{ matrix.asset_os_name }} | |
| path: ModpackDebuggerKit_${{ env.VERSION }}_${{ matrix.asset_os_name }}.zip | |
| create-release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Read version from file | |
| id: get_version | |
| run: echo "VERSION=$(cat version)" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Download all build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts/ | |
| - name: Generate Release Body | |
| id: generate_body | |
| run: | | |
| PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
| if [ -z "$PREVIOUS_TAG" ]; then | |
| BODY="This is the first release of Modpack Debugger Kit." | |
| else | |
| COMPARE_URL="https://github.com/${{ github.repository }}/compare/${PREVIOUS_TAG}...${{ env.VERSION }}" | |
| BODY="See the changes made since the last release: [${PREVIOUS_TAG}...${{ env.VERSION }}](${COMPARE_URL})" | |
| fi | |
| if [ -f vernotes ] && [ -s vernotes ] && grep -q '[^[:space:]]' vernotes; then | |
| ADDITIONAL=$(cat vernotes) | |
| BODY="$BODY"$'\n\n'"$ADDITIONAL" | |
| fi | |
| echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV | |
| echo "$BODY" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ env.VERSION }} | |
| name: ${{ env.VERSION }} | |
| body: ${{ env.RELEASE_BODY }} | |
| files: artifacts/*/*.zip |