From 468a286fee591478a1aaabbb59db16ec9b4727de Mon Sep 17 00:00:00 2001 From: lichenblankie Date: Sat, 11 Apr 2026 03:40:09 +0000 Subject: [PATCH] squashed a bunch of workflow build bugs --- .forgejo/workflows/build.yml | 84 ++++++++++++++++++++++++------------ .github/workflows/build.yml | 75 -------------------------------- Dockerfile | 6 +++ 3 files changed, 63 insertions(+), 102 deletions(-) delete mode 100644 .github/workflows/build.yml diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index c7c6fa3..574f745 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -6,14 +6,14 @@ on: jobs: build: - runs-on: docker + runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4 + uses: https://code.forgejo.org/actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v5 + uses: https://code.forgejo.org/actions/setup-python@v5 with: python-version: '3.11' @@ -26,32 +26,62 @@ jobs: run: | pyinstaller --onefile --console --name TinyWeb app.py - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: TinyWeb-linux-x64 - path: dist/TinyWeb - if-no-files-found: error + - name: Prepare artifact + run: | + cp dist/TinyWeb TinyWeb-linux-x64 + chmod +x TinyWeb-linux-x64 + ls -la TinyWeb-linux-x64 - release: - needs: build - runs-on: docker - if: startsWith(github.ref, 'refs/tags/v') + - name: Get Release ID + if: startsWith(github.ref, 'refs/tags/v') + id: release + run: | + TAG="${{ github.ref_name }}" + REPO="${{ github.repository }}" + TOKEN="${{ secrets.FORGEJO_TOKEN }}" + RELEASE_JSON=$(curl -s "https://git.derickphan.com/api/v1/repos/$REPO/releases/tags/$TAG" \ + -H "Authorization: token $TOKEN") + echo "$RELEASE_JSON" + RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id') + echo "release_id=$RELEASE_ID" >> $FORGEJO_OUTPUT - steps: - - name: Download artifact - uses: actions/download-artifact@v4 - with: - name: TinyWeb-linux-x64 + - name: Upload to Release + if: startsWith(github.ref, 'refs/tags/v') + run: | + FILE=TinyWeb-linux-x64 + RELEASE_ID="${{ steps.release.outputs.release_id }}" + REPO="${{ github.repository }}" + TOKEN="${{ secrets.FORGEJO_TOKEN }}" + curl -X POST "https://git.derickphan.com/api/v1/repos/$REPO/releases/$RELEASE_ID/assets" \ + -H "Authorization: token $TOKEN" \ + -F "attachment=@$FILE" - - name: Make executable - run: chmod +x TinyWeb-linux-x64 + - name: Login to Registry + run: | + echo "${{ secrets.REGISTRY_TOKEN }}" | docker login registry.derickphan.com -u _ --password-stdin - - name: Create Release - uses: actions/forgejo-release@v2 - with: - direction: upload - release-dir: . - override: true - prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') }} + - name: Build and push Docker image + run: | + TAG="${{ github.ref_name }}" + if [ -z "$TAG" ]; then + TAG="latest" + fi + # Configure Docker daemon with DNS + mkdir -p ~/.docker + cat > ~/.docker/daemon.json << 'EOF' + { + "dns": ["8.8.8.8", "1.1.1.1"], + "builder": { + "features": { + "buildkit": true + } + } + } + EOF + # Restart docker to pick up new config + pkill dockerd || true + sleep 2 + # Build with buildkit + DOCKER_BUILDKIT=1 docker build --network=host -t registry.derickphan.com/tinyweb:$TAG . + docker push registry.derickphan.com/tinyweb:$TAG diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index d79edb3..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Build - -on: - push: - tags: - - 'v*.*.*' - workflow_dispatch: - -jobs: - build: - strategy: - fail-fast: false - matrix: - include: - - os: windows-latest - artifact: TinyWeb-windows-x64.exe - - os: macos-latest - artifact: TinyWeb-macos-arm64 - - os: ubuntu-latest - artifact: TinyWeb-linux-x64 - - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - pip install -r requirements.txt - pip install pyinstaller - - - name: Build with PyInstaller - run: | - pyinstaller --onefile --console --name TinyWeb app.py - - - name: Get artifact path - id: artifact - run: | - if [[ "${{ matrix.os }}" == "windows-latest" ]]; then - echo "path=dist/TinyWeb.exe" >> $GITHUB_OUTPUT - else - echo "path=dist/TinyWeb" >> $GITHUB_OUTPUT - fi - - - name: Create ZIP - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.artifact }} - path: ${{ steps.artifact.outputs.path }} - if-no-files-found: error - - release: - needs: build - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/v') - - steps: - - name: Download all artifacts - uses: actions/download-artifact@v4 - with: - path: artifacts - - - name: Create Release - uses: softprops/action-gh-release@v1 - with: - files: artifacts/** - generate_release_notes: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile b/Dockerfile index 9895f65..713df67 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,12 @@ FROM python:3.12-slim WORKDIR /app +# Install build tools for packages like hnswlib +RUN apt-get update && apt-get install -y --no-install-recommends \ + g++ \ + gcc \ + && rm -rf /var/lib/apt/lists/* + COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt