Added UI #78
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 jb_updater | |
| on: | |
| push: | |
| branches: [ "**" ] | |
| tags: [ "v*.*.*" ] | |
| pull_request: | |
| workflow_dispatch: { } | |
| permissions: | |
| contents: write | |
| # ========================================================= | |
| # =============== BUILD JOBS ========================== | |
| # ========================================================= | |
| jobs: | |
| linux: | |
| name: Linux x86_64 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: crystal-lang/install-crystal@v1 | |
| with: | |
| crystal: latest | |
| - name: Install Linux dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libxml2-dev libssl-dev libpcre2-dev libgc-dev liblzma-dev libgtk-3-dev | |
| - name: Install shards | |
| working-directory: jb_updater | |
| run: shards install | |
| - name: Run specs | |
| working-directory: jb_updater | |
| run: crystal spec -v | |
| - name: Run Ameba linter | |
| working-directory: jb_updater | |
| run: ./bin/lint | |
| - name: Build binaries (CLI + GUI) | |
| run: | | |
| cd jb_updater | |
| # CLI | |
| crystal build src/main.cr --release -o jb_updater | |
| # GUI | |
| crystal build src/gui/main_gui.cr --release -o jb_updater_gui | |
| cd .. | |
| # Package CLI | |
| tar -czf jb_updater-linux-x86_64.tar.gz -C jb_updater jb_updater | |
| # Package GUI | |
| tar -czf jb_updater-gui-linux-x86_64.tar.gz -C jb_updater jb_updater_gui | |
| # Package bundle: CLI + GUI together | |
| mkdir -p jb_updater-bundle-linux | |
| cp jb_updater/jb_updater jb_updater-bundle-linux/ | |
| cp jb_updater/jb_updater_gui jb_updater-bundle-linux/ | |
| tar -czf jb_updater-bundle-linux-x86_64.tar.gz -C jb_updater-bundle-linux . | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: jb_updater-linux-x86_64 | |
| path: jb_updater-linux-x86_64.tar.gz | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: jb_updater-gui-linux-x86_64 | |
| path: jb_updater-gui-linux-x86_64.tar.gz | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: jb_updater-bundle-linux-x86_64 | |
| path: jb_updater-bundle-linux-x86_64.tar.gz | |
| macos: | |
| name: macOS ${{ matrix.arch }} | |
| strategy: | |
| matrix: | |
| include: | |
| - arch: arm64 | |
| runs_on: macos-latest | |
| - arch: x86_64 | |
| runs_on: macos-13 | |
| runs-on: ${{ matrix.runs_on }} | |
| env: | |
| ARCH: ${{ matrix.arch }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: crystal-lang/install-crystal@v1 | |
| with: | |
| crystal: latest | |
| - name: Install OpenSSL 3 | |
| run: brew install openssl@3 | |
| - name: Install shards | |
| working-directory: jb_updater | |
| run: shards install | |
| - name: Run specs | |
| working-directory: jb_updater | |
| run: crystal spec -v | |
| - name: Run Ameba linter | |
| working-directory: jb_updater | |
| run: ./bin/lint | |
| - name: Build binaries (CLI + GUI) | |
| run: | | |
| cd jb_updater | |
| brew_prefix=$(brew --prefix openssl@3) | |
| unset PKG_CONFIG_PATH | |
| export PKG_CONFIG_PATH="${brew_prefix}/lib/pkgconfig" | |
| echo "Using OpenSSL from ${brew_prefix}" | |
| # CLI | |
| crystal build src/main.cr --release --no-debug \ | |
| --link-flags "-L${brew_prefix}/lib -I${brew_prefix}/include" \ | |
| -o jb_updater | |
| # GUI | |
| crystal build src/gui/main_gui.cr --release --no-debug \ | |
| --link-flags "-L${brew_prefix}/lib -I${brew_prefix}/include" \ | |
| -o jb_updater_gui | |
| cd .. | |
| # Package CLI alone (as before) | |
| tar -czf jb_updater-macos-${ARCH}.tar.gz -C jb_updater jb_updater | |
| # Package raw CLI+GUI binaries together (new) | |
| mkdir -p jb_updater-bundle | |
| cp jb_updater/jb_updater jb_updater-bundle/ | |
| cp jb_updater/jb_updater_gui jb_updater-bundle/ | |
| zip -ry jb_updater-macos-${ARCH}-binaries.zip jb_updater-bundle | |
| # Create a simple .app bundle for GUI (includes CLI inside) | |
| APP_ROOT="JBUpdater.app/Contents" | |
| mkdir -p "$APP_ROOT/MacOS" "$APP_ROOT/Resources" | |
| cp jb_updater/jb_updater_gui "$APP_ROOT/MacOS/jb_updater_gui" | |
| cp jb_updater/jb_updater "$APP_ROOT/MacOS/jb_updater" | |
| cat > "$APP_ROOT/Info.plist" <<'PLIST' | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"><dict> | |
| <key>CFBundleName</key><string>JB Updater</string> | |
| <key>CFBundleIdentifier</key><string>com.example.jb-updater</string> | |
| <key>CFBundleVersion</key><string>1.0</string> | |
| <key>CFBundleExecutable</key><string>jb_updater_gui</string> | |
| <key>LSMinimumSystemVersion</key><string>11.0</string> | |
| <key>NSHighResolutionCapable</key><true/> | |
| </dict></plist> | |
| PLIST | |
| # Package GUI app bundle | |
| zip -ry jb_updater-gui-macos-${ARCH}.zip JBUpdater.app | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: jb_updater-macos-${{ matrix.arch }} | |
| path: jb_updater-macos-${{ matrix.arch }}.tar.gz | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: jb_updater-gui-macos-${{ matrix.arch }} | |
| path: jb_updater-gui-macos-${{ matrix.arch }}.zip | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: jb_updater-macos-${{ matrix.arch }}-binaries | |
| path: jb_updater-macos-${{ matrix.arch }}-binaries.zip | |
| windows: | |
| name: Windows x64 | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: crystal-lang/install-crystal@v1 | |
| with: | |
| crystal: latest | |
| # Ensure MSVC build environment is set up (cl, link, mt, etc.) | |
| - name: Set up MSVC Developer Command Prompt | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| - name: Install shards | |
| working-directory: jb_updater | |
| run: shards install | |
| - name: Run specs | |
| working-directory: jb_updater | |
| run: crystal spec -v | |
| - name: Build binaries (CLI + GUI) | |
| working-directory: jb_updater | |
| run: | | |
| # CLI | |
| crystal build src/main.cr --release -o jb_updater.exe | |
| # GUI (windowed subsystem to hide console) | |
| crystal build src/gui/main_gui.cr --release --link-flags=/SUBSYSTEM:WINDOWS -o jb_updater_gui.exe | |
| - name: Package artifacts | |
| run: | | |
| Compress-Archive -Path jb_updater\jb_updater.exe -DestinationPath jb_updater-windows-x64.zip | |
| Compress-Archive -Path jb_updater\jb_updater_gui.exe -DestinationPath jb_updater-gui-windows-x64.zip | |
| # Bundle: CLI + GUI together | |
| New-Item -ItemType Directory -Force -Path jb_updater-bundle | Out-Null | |
| Copy-Item jb_updater\jb_updater.exe jb_updater-bundle\ | |
| Copy-Item jb_updater\jb_updater_gui.exe jb_updater-bundle\ | |
| Compress-Archive -Path jb_updater-bundle\* -DestinationPath jb_updater-bundle-windows-x64.zip | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: jb_updater-windows-x64 | |
| path: jb_updater-windows-x64.zip | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: jb_updater-gui-windows-x64 | |
| path: jb_updater-gui-windows-x64.zip | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: jb_updater-bundle-windows-x64 | |
| path: jb_updater-bundle-windows-x64.zip | |
| # ========================================================= | |
| # =============== RELEASE JOB ========================= | |
| # ========================================================= | |
| release: | |
| name: Create GitHub Release | |
| needs: [ linux, macos, windows ] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Verify branch or tag | |
| run: | | |
| echo "Triggered by $GITHUB_EVENT_NAME for ref $GITHUB_REF" | |
| if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" && "$GITHUB_REF_NAME" != "master" ]]; then | |
| echo "⚠️ Manual releases are allowed only from master branch." | |
| exit 1 | |
| fi | |
| - name: Download all build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./all-artifacts | |
| - name: Flatten artifacts | |
| run: | | |
| mkdir -p release-assets | |
| find ./all-artifacts -type f -exec mv {} ./release-assets/ \; | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: release-assets/* | |
| generate_release_notes: true |