Release Build #84
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: Release Build | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths-ignore: | |
| - '**.md' | |
| - '.gitignore' | |
| workflow_dispatch: | |
| jobs: | |
| check-release: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_release: ${{ steps.check.outputs.should_release }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Check for [release] in commit message | |
| id: check | |
| run: | | |
| COMMIT_MSG=$(git log -1 --pretty=%B) | |
| if echo "$COMMIT_MSG" | grep -q "\[release\]"; then | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| # Extract version from package.json | |
| VERSION=$(grep -oP '"version":\s*"\K[^"]+' package.json) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Release triggered with version $VERSION" | |
| else | |
| echo "should_release=false" >> $GITHUB_OUTPUT | |
| echo "No [release] tag found in commit message" | |
| fi | |
| # build-deb: | |
| # needs: check-release | |
| # if: needs.check-release.outputs.should_release == 'true' | |
| # runs-on: ubuntu-22.04 | |
| # steps: | |
| # - name: "🧹 Nuclear Disk Cleanup" | |
| # run: | | |
| # echo "Disk space BEFORE cleanup:" | |
| # df -h | |
| # # 1. Remove large frameworks we don't use | |
| # sudo rm -rf /usr/share/dotnet | |
| # sudo rm -rf /usr/local/lib/android | |
| # sudo rm -rf /opt/ghc | |
| # sudo rm -rf /opt/hostedtoolcache/CodeQL | |
| # sudo rm -rf /usr/share/swift | |
| # # 2. Remove Docker images (take up a lot of space) | |
| # sudo docker image prune --all --force | |
| # # 3. Clean apt cached packages | |
| # sudo apt-get clean | |
| # # 4. Remove Tool Cache (old Node, Python, Ruby versions) | |
| # # NOTE: If you use setup-node or setup-python later, they will re-download | |
| # # but only the version you need, not all of them. | |
| # sudo rm -rf /opt/hostedtoolcache | |
| # # 5. Remove Swap (optional, frees ~4GB but may affect if you have low RAM) | |
| # # sudo swapoff -a | |
| # # sudo rm -f /mnt/swapfile | |
| # echo "Disk space AFTER cleanup:" | |
| # df -h | |
| # - uses: actions/checkout@v4 | |
| # - name: Setup Node.js | |
| # uses: actions/setup-node@v4 | |
| # with: | |
| # node-version: '20' | |
| # - name: Install Rust | |
| # uses: dtolnay/rust-toolchain@stable | |
| # - name: Install system dependencies | |
| # run: | | |
| # sudo apt-get update | |
| # sudo apt-get install -y \ | |
| # libwebkit2gtk-4.1-dev \ | |
| # build-essential \ | |
| # curl \ | |
| # wget \ | |
| # file \ | |
| # libxdo-dev \ | |
| # libssl-dev \ | |
| # libayatana-appindicator3-dev \ | |
| # librsvg2-dev | |
| # - name: Install dependencies | |
| # run: npm install | |
| # - name: Build Tauri .deb | |
| # run: npm run tauri build -- --bundles deb | |
| # - name: Rename .deb file | |
| # run: | | |
| # VERSION="${{ needs.check-release.outputs.version }}" | |
| # DEB_FILE=$(find src-tauri/target/release/bundle/deb -name "*.deb" -type f) | |
| # mv "$DEB_FILE" "Klia-Store-${VERSION}.deb" | |
| # - name: Upload .deb artifact | |
| # uses: actions/upload-artifact@v4 | |
| # with: | |
| # name: deb-package | |
| # path: Klia-Store-*.deb | |
| build-flatpak: | |
| needs: check-release | |
| if: needs.check-release.outputs.should_release == 'true' | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: "🧹 Nuclear Disk Cleanup" | |
| run: | | |
| echo "Disk space BEFORE cleanup:" | |
| df -h | |
| # 1. Remove large frameworks we don't use | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /opt/hostedtoolcache/CodeQL | |
| sudo rm -rf /usr/share/swift | |
| # 2. Remove Docker images (take up a lot of space) | |
| sudo docker image prune --all --force | |
| # 3. Clean apt cached packages | |
| sudo apt-get clean | |
| # 4. Remove Tool Cache (old Node, Python, Ruby versions) | |
| # NOTE: If you use setup-node or setup-python later, they will re-download | |
| # but only the version you need, not all of them. | |
| sudo rm -rf /opt/hostedtoolcache | |
| # 5. Remove Swap (optional, frees ~4GB but may affect if you have low RAM) | |
| # sudo swapoff -a | |
| # sudo rm -f /mnt/swapfile | |
| echo "Disk space AFTER cleanup:" | |
| df -h | |
| - uses: actions/checkout@v4 | |
| - name: Install Flatpak and dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y flatpak flatpak-builder | |
| - name: Add Flathub repository | |
| run: | | |
| sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo | |
| - name: Install GNOME SDK | |
| run: | | |
| sudo flatpak install -y flathub org.gnome.Platform//49 org.gnome.Sdk//49 | |
| - name: Build Flatpak | |
| run: | | |
| flatpak-builder --repo=repo --force-clean build-dir io.github.N3kosempai.klia-store.yml | |
| flatpak build-bundle repo Klia-Store-${{ needs.check-release.outputs.version }}.flatpak io.github.N3kosempai.klia-store | |
| - name: Upload Flatpak artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: flatpak-package | |
| path: Klia-Store-*.flatpak | |
| create-release: | |
| needs: [check-release, build-flatpak] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # - name: Download .deb artifact | |
| # uses: actions/download-artifact@v4 | |
| # with: | |
| # name: deb-package | |
| - name: Download Flatpak artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: flatpak-package | |
| - name: Extract release notes from metainfo | |
| id: extract_notes | |
| run: | | |
| VERSION="${{ needs.check-release.outputs.version }}" | |
| # Extract the description for the current version from metainfo.xml | |
| NOTES=$(python3 << 'EOF' | |
| import xml.etree.ElementTree as ET | |
| import sys | |
| try: | |
| tree = ET.parse('io.github.N3kosempai.klia-store.metainfo.xml') | |
| root = tree.getroot() | |
| version = "${{ needs.check-release.outputs.version }}" | |
| # Find the release with matching version | |
| for release in root.findall('.//release'): | |
| if release.get('version') == version: | |
| desc = release.find('description') | |
| if desc is not None: | |
| # Extract text content from description | |
| lines = [] | |
| for elem in desc.iter(): | |
| if elem.text and elem.text.strip(): | |
| lines.append(elem.text.strip()) | |
| if elem.tail and elem.tail.strip(): | |
| lines.append(elem.tail.strip()) | |
| print('\n'.join(lines)) | |
| break | |
| except Exception as e: | |
| print(f"Error: {e}", file=sys.stderr) | |
| EOF | |
| ) | |
| # If extraction fails, use commit message as fallback | |
| if [ -z "$NOTES" ]; then | |
| NOTES="${{ github.event.head_commit.message }}" | |
| fi | |
| # Save to output (handle multiline) | |
| echo "notes<<EOF" >> $GITHUB_OUTPUT | |
| echo "$NOTES" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.check-release.outputs.version }} | |
| name: Klia Store ${{ needs.check-release.outputs.version }} | |
| draft: false | |
| prerelease: false | |
| body: | | |
| ## Klia Store ${{ needs.check-release.outputs.version }} | |
| ### What's New | |
| ${{ steps.extract_notes.outputs.notes }} | |
| ### Installation | |
| **Flatpak:** | |
| ```bash | |
| flatpak install Klia-Store-${{ needs.check-release.outputs.version }}.flatpak | |
| flatpak run io.github.N3kosempai.klia-store | |
| ``` | |
| files: | | |
| Klia-Store-*.flatpak |