Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Ignore build artifacts
target/
build_deb_temp/
outputs/

# Ignore .NET build artifacts
frontend/FilePiWeb/bin/
frontend/FilePiWeb/obj/
temp-publish/

# Ignore logs
logs/
*.log

# Ignore git
.git/
.gitignore

# Ignore IDE files
.vscode/
.idea/
*.swp
*.swo

# Ignore macOS files
.DS_Store
243 changes: 243 additions & 0 deletions .github/workflows/on-push-build-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
name: Build Rust Server with Blazor Frontend

on:
push:
branches:
- main_rs
- try/*
pull_request:
branches:
- main_rs
workflow_dispatch:

jobs:
setup:
name: Setup Build Variables
runs-on: ubuntu-latest
outputs:
build-name: ${{ steps.set-artifact-props.outputs.build-name }}
version: ${{ steps.set-artifact-props.outputs.version }}
deb-version: ${{ steps.set-artifact-props.outputs.deb-version }}

steps:
- name: Set artifact name and development version
id: set-artifact-props
run: |
# Get branch name
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
BRANCH_NAME="${GITHUB_HEAD_REF}"
else
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
fi

# Clean branch name for artifact naming
CLEAN_NAME="$(echo "$BRANCH_NAME" | sed -E 's/^(b|feat\/|try\/)//g' | sed -e 's/ /_/g' | sed -e 's/\//_/g')"
echo "Clean branch name is: $CLEAN_NAME"

RUN_NUMBER=${{ github.run_number }}
VERSION="${CLEAN_NAME}_${RUN_NUMBER}"

# Create a Debian-compatible version (must start with a digit)
DEB_VERSION="1.0.0+${CLEAN_NAME}.${RUN_NUMBER}"

echo "build-name=$VERSION" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "deb-version=$DEB_VERSION" >> $GITHUB_OUTPUT

echo "Using artifact name: filepi-${VERSION}"
echo "Using version: $VERSION"
echo "Using Debian version: $DEB_VERSION"

build-blazor:
name: Build Blazor Frontend
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Set up .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'

- name: Install LibMan CLI
run: dotnet tool install -g Microsoft.Web.LibraryManager.Cli

- name: Build Blazor WebAssembly Frontend
env:
SYNCFUSION_LICENSE_KEY: ${{ secrets.SYNCFUSION_LICENSE_KEY }}
run: |
echo "Building Blazor WebAssembly frontend..."
./build.sh --type blazor

- name: Upload webdeploy artifact
uses: actions/upload-artifact@v4
with:
name: webdeploy
path: webdeploy/
retention-days: 1

build-rust:
name: Build Rust (${{ matrix.arch }})
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
include:
- arch: amd64
rust_target: x86_64-unknown-linux-gnu
- arch: arm64
rust_target: aarch64-unknown-linux-gnu

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
target: ${{ matrix.rust_target }}

- name: Install cross-compilation dependencies
if: matrix.arch == 'arm64'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu

- name: Build Rust binary
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
run: |
echo "Building Rust backend for ${{ matrix.rust_target }}..."
cargo build --release --target ${{ matrix.rust_target }}

# Copy binary to root with standard name
cp target/${{ matrix.rust_target }}/release/filepi ./filepi

echo "Rust binary built successfully"
ls -la filepi

Comment thread
coderabbitai[bot] marked this conversation as resolved.
- name: Upload Rust binary artifact
uses: actions/upload-artifact@v4
with:
name: filepi-binary-${{ matrix.arch }}
path: filepi
retention-days: 1

package:
name: Create Packages (${{ matrix.arch }})
needs: [setup, build-blazor, build-rust]
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Download webdeploy
uses: actions/download-artifact@v6
with:
name: webdeploy
path: webdeploy

- name: Download Rust binary
uses: actions/download-artifact@v6
with:
name: filepi-binary-${{ matrix.arch }}
path: .

- name: Make binary executable
run: chmod +x filepi

- name: Verify artifacts
run: |
echo "Verifying filepi binary..."
ls -la filepi

echo "Verifying webdeploy directory..."
if [ ! -d "webdeploy" ] || [ ! -f "webdeploy/index.html" ]; then
echo "ERROR: webdeploy directory is missing or incomplete"
exit 1
fi

echo "✅ All artifacts verified"
find webdeploy -type f | head -10

- name: Create binary tarball
run: |
BINARY_NAME="filepi-${{ needs.setup.outputs.build-name }}-linux-${{ matrix.arch }}"

# Create a temporary directory structure
mkdir -p ${BINARY_NAME}
cp filepi ${BINARY_NAME}/
cp -r webdeploy ${BINARY_NAME}/

# Create tarball
tar -czvf ${BINARY_NAME}.tar.gz ${BINARY_NAME}

echo "Tarball created: ${BINARY_NAME}.tar.gz"
tar -tzvf ${BINARY_NAME}.tar.gz | head -10

- name: Build Debian package
run: |
echo "Building Debian package..."
chmod +x build-deb.sh
./build-deb.sh "${{ needs.setup.outputs.deb-version }}" "${{ matrix.arch }}"

# Rename the deb file to include architecture
mv outputs/filepi_*.deb filepi_${{ needs.setup.outputs.build-name }}_${{ matrix.arch }}.deb

echo "Debian package created:"
ls -la filepi_${{ needs.setup.outputs.build-name }}_${{ matrix.arch }}.deb
Comment on lines +186 to +196

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Strengthen the Debian package rename operation.

The mv command on line 191 uses a glob pattern that could match multiple files or fail if the expected file doesn't exist. This could cause silent failures or unexpected behavior.

Apply this diff to make the rename more robust:

         echo "Building Debian package..."
         chmod +x build-deb.sh
         ./build-deb.sh "${{ needs.setup.outputs.deb-version }}" "${{ matrix.arch }}"
 
-        # Rename the deb file to include architecture
-        mv outputs/filepi_*.deb filepi_${{ needs.setup.outputs.build-name }}_${{ matrix.arch }}.deb
+        # Rename the deb file to include build name
+        DEB_FILE=$(find outputs -name "filepi_*.deb" -type f)
+        if [ -z "$DEB_FILE" ]; then
+          echo "ERROR: No .deb file found in outputs/"
+          exit 1
+        fi
+        mv "$DEB_FILE" filepi_${{ needs.setup.outputs.build-name }}_${{ matrix.arch }}.deb
 
         echo "Debian package created:"
         ls -la filepi_${{ needs.setup.outputs.build-name }}_${{ matrix.arch }}.deb
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Build Debian package
run: |
echo "Building Debian package..."
chmod +x build-deb.sh
./build-deb.sh "${{ needs.setup.outputs.deb-version }}" "${{ matrix.arch }}"
# Rename the deb file to include architecture
mv outputs/filepi_*.deb filepi_${{ needs.setup.outputs.build-name }}_${{ matrix.arch }}.deb
echo "Debian package created:"
ls -la filepi_${{ needs.setup.outputs.build-name }}_${{ matrix.arch }}.deb
- name: Build Debian package
run: |
echo "Building Debian package..."
chmod +x build-deb.sh
./build-deb.sh "${{ needs.setup.outputs.deb-version }}" "${{ matrix.arch }}"
# Rename the deb file to include build name
DEB_FILE=$(find outputs -name "filepi_*.deb" -type f)
if [ -z "$DEB_FILE" ]; then
echo "ERROR: No .deb file found in outputs/"
exit 1
fi
mv "$DEB_FILE" filepi_${{ needs.setup.outputs.build-name }}_${{ matrix.arch }}.deb
echo "Debian package created:"
ls -la filepi_${{ needs.setup.outputs.build-name }}_${{ matrix.arch }}.deb
🤖 Prompt for AI Agents
In .github/workflows/on-push-build-all.yml around lines 184–194, the mv that
renames the generated .deb uses a glob that can match zero or multiple files;
replace it with a robust check: expand the glob into an array, validate there is
exactly one match, print a clear error and exit non‑zero if none or multiple
matches, then perform the mv using that single filename to the target filepi_${{
needs.setup.outputs.build-name }}_${{ matrix.arch }}.deb; keep the working
directory explicit and fail the step on error.


- name: Upload binary tarball
uses: actions/upload-artifact@v4
with:
name: filepi-${{ needs.setup.outputs.build-name }}-linux-${{ matrix.arch }}
path: filepi-${{ needs.setup.outputs.build-name }}-linux-${{ matrix.arch }}.tar.gz

- name: Upload Debian package
uses: actions/upload-artifact@v4
with:
name: filepi_debian_${{ needs.setup.outputs.build-name }}_${{ matrix.arch }}
path: filepi_${{ needs.setup.outputs.build-name }}_${{ matrix.arch }}.deb

summary:
needs: package
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v6
with:
path: all-artifacts
pattern: 'filepi*'
merge-multiple: true

- name: List artifacts
run: |
echo "## 🎉 Build Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "The following artifacts have been created:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📦 Rust Binaries (with Blazor WebAssembly UI):" >> $GITHUB_STEP_SUMMARY
for file in all-artifacts/*.tar.gz; do
if [ -f "$file" ]; then
filename=$(basename "$file")
size=$(ls -lh "$file" | awk '{print $5}')
echo "- $filename ($size)" >> $GITHUB_STEP_SUMMARY
fi
done
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📦 Debian Packages:" >> $GITHUB_STEP_SUMMARY
for file in all-artifacts/*.deb; do
if [ -f "$file" ]; then
filename=$(basename "$file")
size=$(ls -lh "$file" | awk '{print $5}')
echo "- $filename ($size)" >> $GITHUB_STEP_SUMMARY
fi
done
Loading