squashed a bunch of workflow build bugs
This commit is contained in:
parent
7655748e8e
commit
468a286fee
3 changed files with 63 additions and 102 deletions
|
|
@ -6,14 +6,14 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: docker
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: https://code.forgejo.org/actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v5
|
uses: https://code.forgejo.org/actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.11'
|
||||||
|
|
||||||
|
|
@ -26,32 +26,62 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
pyinstaller --onefile --console --name TinyWeb app.py
|
pyinstaller --onefile --console --name TinyWeb app.py
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Prepare artifact
|
||||||
uses: actions/upload-artifact@v4
|
run: |
|
||||||
with:
|
cp dist/TinyWeb TinyWeb-linux-x64
|
||||||
name: TinyWeb-linux-x64
|
chmod +x TinyWeb-linux-x64
|
||||||
path: dist/TinyWeb
|
ls -la TinyWeb-linux-x64
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
release:
|
- name: Get Release ID
|
||||||
needs: build
|
|
||||||
runs-on: docker
|
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
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: Upload to Release
|
||||||
- name: Download artifact
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
uses: actions/download-artifact@v4
|
run: |
|
||||||
with:
|
FILE=TinyWeb-linux-x64
|
||||||
name: 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
|
- name: Login to Registry
|
||||||
run: chmod +x TinyWeb-linux-x64
|
run: |
|
||||||
|
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login registry.derickphan.com -u _ --password-stdin
|
||||||
|
|
||||||
- name: Create Release
|
- name: Build and push Docker image
|
||||||
uses: actions/forgejo-release@v2
|
run: |
|
||||||
with:
|
TAG="${{ github.ref_name }}"
|
||||||
direction: upload
|
if [ -z "$TAG" ]; then
|
||||||
release-dir: .
|
TAG="latest"
|
||||||
override: true
|
fi
|
||||||
prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') }}
|
# 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
|
||||||
|
|
||||||
|
|
|
||||||
75
.github/workflows/build.yml
vendored
75
.github/workflows/build.yml
vendored
|
|
@ -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 }}
|
|
||||||
|
|
@ -2,6 +2,12 @@ FROM python:3.12-slim
|
||||||
|
|
||||||
WORKDIR /app
|
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 .
|
COPY requirements.txt .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue