|
| 1 | +name: Build and Release ALG App Store |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main", "devel", "qt6" ] |
| 6 | + paths: |
| 7 | + - '**.cpp' |
| 8 | + - '**.h' |
| 9 | + - 'CMakeLists.txt' |
| 10 | + - '.github/workflows/**' |
| 11 | + pull_request: |
| 12 | + branches: [ "main", "devel", "qt6" ] |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + version: ${{ steps.get_version.outputs.version }} |
| 20 | + should_release: ${{ steps.check_release.outputs.should_release }} |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + fetch-depth: 2 # Need history to check changed files |
| 27 | + |
| 28 | + - name: Extract version from CMakeLists.txt |
| 29 | + id: get_version |
| 30 | + run: | |
| 31 | + VERSION=$(grep -oP 'project\(alg-app-store VERSION \K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt) |
| 32 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 33 | + echo "Detected version: $VERSION" |
| 34 | + |
| 35 | + - name: Check if this should trigger a release |
| 36 | + id: check_release |
| 37 | + run: | |
| 38 | + # Only release on main branch when CMakeLists.txt was modified |
| 39 | + if [[ "${{ github.ref }}" == "refs/heads/main" && "${{ github.event_name }}" == "push" ]]; then |
| 40 | + # Check if CMakeLists.txt was changed in this push |
| 41 | + if git diff --name-only HEAD~1 HEAD | grep -q "CMakeLists.txt"; then |
| 42 | + echo "should_release=true" >> $GITHUB_OUTPUT |
| 43 | + echo "Release triggered: CMakeLists.txt changed on main branch" |
| 44 | + else |
| 45 | + echo "should_release=false" >> $GITHUB_OUTPUT |
| 46 | + echo "No release: CMakeLists.txt not changed" |
| 47 | + fi |
| 48 | + else |
| 49 | + echo "should_release=false" >> $GITHUB_OUTPUT |
| 50 | + echo "No release: not on main branch or not a push event" |
| 51 | + fi |
| 52 | + |
| 53 | + - name: Install dependencies |
| 54 | + run: | |
| 55 | + sudo apt-get update |
| 56 | + sudo apt-get install -y \ |
| 57 | + build-essential \ |
| 58 | + cmake \ |
| 59 | + qt6-base-dev \ |
| 60 | + qt6-tools-dev \ |
| 61 | + qt6-tools-dev-tools \ |
| 62 | + libalpm-dev \ |
| 63 | + libarchive-dev \ |
| 64 | + libcurl4-openssl-dev \ |
| 65 | + pkg-config |
| 66 | + |
| 67 | + - name: Configure CMake |
| 68 | + run: | |
| 69 | + mkdir -p build |
| 70 | + cd build |
| 71 | + cmake .. |
| 72 | + |
| 73 | + - name: Build |
| 74 | + run: | |
| 75 | + cd build |
| 76 | + make -j$(nproc) |
| 77 | + |
| 78 | + - name: Check build artifacts |
| 79 | + run: | |
| 80 | + ls -lh build/alg-app-store |
| 81 | + file build/alg-app-store |
| 82 | + |
| 83 | + - name: Upload build artifact |
| 84 | + uses: actions/upload-artifact@v4 |
| 85 | + with: |
| 86 | + name: alg-app-store-${{ github.ref_name }}-${{ steps.get_version.outputs.version }} |
| 87 | + path: build/alg-app-store |
| 88 | + retention-days: 30 |
| 89 | + |
| 90 | + release: |
| 91 | + needs: build |
| 92 | + runs-on: ubuntu-latest |
| 93 | + if: needs.build.outputs.should_release == 'true' |
| 94 | + permissions: |
| 95 | + contents: write |
| 96 | + |
| 97 | + steps: |
| 98 | + - name: Checkout code |
| 99 | + uses: actions/checkout@v4 |
| 100 | + |
| 101 | + - name: Download build artifact |
| 102 | + uses: actions/download-artifact@v4 |
| 103 | + with: |
| 104 | + name: alg-app-store-${{ github.ref_name }}-${{ needs.build.outputs.version }} |
| 105 | + path: ./release |
| 106 | + |
| 107 | + - name: Prepare release assets |
| 108 | + run: | |
| 109 | + chmod +x ./release/alg-app-store |
| 110 | + tar -czvf alg-app-store-${{ needs.build.outputs.version }}-linux-x86_64.tar.gz -C ./release alg-app-store |
| 111 | + |
| 112 | + - name: Create GitHub Release |
| 113 | + uses: softprops/action-gh-release@v1 |
| 114 | + with: |
| 115 | + tag_name: v${{ needs.build.outputs.version }} |
| 116 | + name: ALG App Store v${{ needs.build.outputs.version }} |
| 117 | + body: | |
| 118 | + ## ALG App Store v${{ needs.build.outputs.version }} |
| 119 | + |
| 120 | + A modern package manager GUI for Arch Linux. |
| 121 | + |
| 122 | + ### Installation |
| 123 | + ```bash |
| 124 | + tar -xzvf alg-app-store-${{ needs.build.outputs.version }}-linux-x86_64.tar.gz |
| 125 | + sudo mv alg-app-store /usr/local/bin/ |
| 126 | + ``` |
| 127 | + |
| 128 | + ### Requirements |
| 129 | + - Qt6 (Core, Gui, Widgets, Network, Concurrent) |
| 130 | + - libalpm (pacman library) |
| 131 | + - yay or paru (for AUR support) |
| 132 | + files: | |
| 133 | + alg-app-store-${{ needs.build.outputs.version }}-linux-x86_64.tar.gz |
| 134 | + draft: false |
| 135 | + prerelease: false |
| 136 | + env: |
| 137 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments