fix: build dashboard in ci #3
Workflow file for this run
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 Release | |
| on: | |
| # This will trigger when a tag like v1.0.0 is pushed | |
| # will create a release | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| # Manual trigger for creating an artifact (button in the UI) | |
| workflow_dispatch: | |
| permissions: | |
| packages: write | |
| contents: write | |
| jobs: | |
| build-dashboard: | |
| name: Build Dashboard | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Dashboard | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: PocketRelay/Dashboard | |
| ref: master | |
| path: dashboard | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: dashboard/package-lock.json | |
| - name: Install dashboard dependencies | |
| working-directory: dashboard | |
| run: npm ci | |
| - name: Build dashboard | |
| working-directory: dashboard | |
| run: npm run build | |
| - name: Upload dashboard artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dashboard-build | |
| path: dashboard/build/ | |
| build-linux: | |
| name: Build Linux targets | |
| runs-on: ubuntu-latest | |
| needs: [build-dashboard] | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-musl | |
| os_name: linux-musl | |
| arch: x86_64 | |
| filename: pocket-relay-x86_64-linux-musl | |
| - target: x86_64-unknown-linux-gnu | |
| os_name: linux-gnu | |
| arch: x86_64 | |
| filename: pocket-relay-x86_64-linux-gnu | |
| - target: aarch64-unknown-linux-musl | |
| os_name: linux-musl | |
| arch: aarch64 | |
| filename: pocket-relay-aarch64-linux-musl | |
| - target: aarch64-unknown-linux-gnu | |
| os_name: linux-gnu | |
| arch: aarch64 | |
| filename: pocket-relay-aarch64-linux-gnu | |
| steps: | |
| # Checkout the repo for building | |
| - uses: actions/checkout@v4 | |
| # Download the dashboard build artifact | |
| - name: Download dashboard artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dashboard-build | |
| merge-multiple: true | |
| path: src/resources/public | |
| # Setup rust for building the service | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| targets: ${{ matrix.target }} | |
| override: true | |
| # Cache Rust dependencies and build artifacts | |
| - name: Cache Rust dependencies | |
| id: cache-rust | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ matrix.target }}-cargo- | |
| # Install cross for cross compiling | |
| - name: Install cross | |
| if: steps.cache-rust.outputs.cache-hit != 'true' | |
| run: cargo install cross | |
| # Cross compile the binary | |
| - name: Build with ${{ matrix.target }} | |
| run: cross build --release --target ${{ matrix.target }} -p pocket-relay | |
| # Copy built binary to output directory | |
| - name: Copy binary to output | |
| run: cp target/${{ matrix.target }}/release/pocket-relay ${{ matrix.filename }} | |
| shell: bash | |
| # Upload the built artifact | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.filename }} | |
| path: ${{ matrix.filename }} | |
| build-windows: | |
| name: Build Windows targets | |
| runs-on: windows-latest | |
| needs: [build-dashboard] | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-pc-windows-gnu | |
| os_name: windows-gnu | |
| arch: x86_64 | |
| filename: pocket-relay-x86_64-windows-gnu.exe | |
| - target: x86_64-pc-windows-msvc | |
| os_name: windows-msvc | |
| arch: x86_64 | |
| filename: pocket-relay-x86_64-windows-msvc.exe | |
| steps: | |
| # Checkout the repo for building | |
| - uses: actions/checkout@v4 | |
| # Download the dashboard build artifact | |
| - name: Download dashboard artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dashboard-build | |
| merge-multiple: true | |
| path: src/resources/public | |
| # Setup rust for building the service | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| # Cache Rust dependencies and build artifacts | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ matrix.target }}-cargo- | |
| # Cross compile the binary | |
| - name: Build | |
| run: cargo build --release --target ${{ matrix.target }} -p pocket-relay | |
| # Copy built binary to output directory | |
| - name: Rename and move output binary | |
| run: cp target/${{ matrix.target }}/release/pocket-relay.exe ${{ matrix.filename }} | |
| shell: bash | |
| # Prepare signing certificate | |
| - name: Decode and save certificate | |
| run: echo "${{ secrets.SIGNING_CERT_BASE64 }}" | base64 -d > cert.pfx | |
| shell: bash | |
| # Sign binary | |
| - name: Sign binary | |
| run: | | |
| $signtool = Get-ChildItem 'C:\Program Files (x86)\Windows Kits\10\bin' -Recurse -Filter signtool.exe | | |
| Where-Object { $_.FullName -like '*x64*' } | | |
| Sort-Object FullName -Descending | | |
| Select-Object -ExpandProperty FullName -First 1 | |
| & "$signtool" sign /tr http://timestamp.digicert.com /td sha256 /fd SHA256 /f cert.pfx /p "${{ secrets.SIGNING_CERT_PASSWORD }}" ${{ matrix.filename }} | |
| # Upload the built artifact | |
| - name: Upload binary artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.filename }} | |
| path: ${{ matrix.filename }} | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| needs: [build-linux, build-windows] | |
| steps: | |
| # Checkout the repo | |
| - uses: actions/checkout@v4 | |
| # Download all the compiled artifacts from previous | |
| # steps | |
| - name: Download all build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| # Only download the executables not the dashboard | |
| pattern: pocket-relay-* | |
| merge-multiple: true | |
| # Create the github release if we pushed up a new tag | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| if: github.event_name == 'push' | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: ${{ github.ref_name }} | |
| draft: true | |
| files: dist/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |