diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33e5498..45231b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,11 @@ name: CI on: - push: - branches: [main] - pull_request: - branches: [main] + workflow_dispatch: + # push: + # branches: [main] + # pull_request: + # branches: [main] jobs: backend: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 16b5953..b4b3a89 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,127 +6,45 @@ on: - 'v*' permissions: - contents: write + contents: read + packages: write jobs: - build: - name: Build ${{ matrix.name }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - name: Linux (x86_64) - target: x86_64-unknown-linux-gnu - os: ubuntu-latest - archive: tar.gz - asset_name: ironpad-linux-x86_64 - - name: macOS (x86_64) - target: x86_64-apple-darwin - os: macos-latest - archive: tar.gz - asset_name: ironpad-macos-x86_64 - - name: Windows (x86_64) - target: x86_64-pc-windows-msvc - os: windows-latest - archive: zip - asset_name: ironpad-windows-x86_64 - + docker: + name: Build and Push Docker Image + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.target }} - - - name: Install system dependencies (Linux) - if: runner.os == 'Linux' - run: sudo apt-get update && sudo apt-get install -y cmake libdbus-1-dev pkg-config - - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - - - name: Build frontend - working-directory: frontend - run: | - npm ci - npm run build - - - name: Copy frontend to static + - name: Set image name shell: bash - run: | - mkdir -p backend/static - cp -r frontend/dist/* backend/static/ + run: echo "IMAGE_NAME=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/ironpad" >> "$GITHUB_ENV" - - name: Build backend (release) - working-directory: backend - run: cargo build --release --target ${{ matrix.target }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: Package (Unix) - if: matrix.archive == 'tar.gz' - shell: bash - run: | - RELEASE_DIR="${{ matrix.asset_name }}-${{ github.ref_name }}" - mkdir -p "$RELEASE_DIR" - cp "backend/target/${{ matrix.target }}/release/ironpad" "$RELEASE_DIR/" - cp -r backend/static "$RELEASE_DIR/static" - cp README.md LICENSE "$RELEASE_DIR/" - tar czf "$RELEASE_DIR.tar.gz" "$RELEASE_DIR" - echo "ASSET=$RELEASE_DIR.tar.gz" >> $GITHUB_ENV - - - name: Package (Windows) - if: matrix.archive == 'zip' - shell: bash - run: | - RELEASE_DIR="${{ matrix.asset_name }}-${{ github.ref_name }}" - mkdir -p "$RELEASE_DIR" - cp "backend/target/${{ matrix.target }}/release/ironpad.exe" "$RELEASE_DIR/" - cp -r backend/static "$RELEASE_DIR/static" - cp README.md LICENSE "$RELEASE_DIR/" - 7z a "$RELEASE_DIR.zip" "$RELEASE_DIR" - echo "ASSET=$RELEASE_DIR.zip" >> $GITHUB_ENV - - - name: Upload artifact - uses: actions/upload-artifact@v4 + - name: Log in to GHCR + uses: docker/login-action@v3 with: - name: ${{ matrix.asset_name }} - path: ${{ env.ASSET }} + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - release: - name: Create Release - needs: build - runs-on: ubuntu-latest - steps: - - name: Download all artifacts - uses: actions/download-artifact@v4 + - name: Docker metadata + id: meta + uses: docker/metadata-action@v5 with: - path: artifacts + images: ${{ env.IMAGE_NAME }} + tags: | + type=ref,event=tag + type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }} - - name: Create GitHub Release - uses: softprops/action-gh-release@v2 + - name: Build and push image + uses: docker/build-push-action@v6 with: - name: Ironpad ${{ github.ref_name }} - body: | - ## Downloads - - | Platform | File | - |----------|------| - | Windows (x86_64) | `ironpad-windows-x86_64-${{ github.ref_name }}.zip` | - | macOS (x86_64) | `ironpad-macos-x86_64-${{ github.ref_name }}.tar.gz` | - | Linux (x86_64) | `ironpad-linux-x86_64-${{ github.ref_name }}.tar.gz` | - - **Linux:** Extract the tar.gz and run `./ironpad`. Works on any distro -- it's a standalone binary with no dependencies. - - **macOS:** Extract and run. You may need to allow it in System Settings > Privacy & Security on first launch. - - **Windows:** Extract the zip and run `ironpad.exe`. - - --- - files: artifacts/**/* - generate_release_notes: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}