116 lines
3.6 KiB
YAML
116 lines
3.6 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: ["Test with Pytest"]
|
|
types:
|
|
- completed
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
arch: [x86_64, arm64]
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Set up Python (x86_64)
|
|
if: matrix.arch == 'x86_64'
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '3.14'
|
|
|
|
- name: Install QEMU (arm)
|
|
if: matrix.arch == 'arm64'
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: arm64
|
|
|
|
- name: Set up Docker Buildx (arm)
|
|
if: matrix.arch == 'arm64'
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
platforms: linux/arm64
|
|
|
|
- name: Build Executable
|
|
run: |
|
|
if [ "${{ matrix.arch }}" = "x86_64" ]; then
|
|
pip install -r requirements.txt
|
|
cd app
|
|
pyinstaller --onefile --add-data "ui:ui" wolServer.py
|
|
else
|
|
echo 'FROM arm64v8/python:3.13-slim-bullseye AS builder
|
|
WORKDIR /app
|
|
COPY requirements.txt .
|
|
COPY app ./app
|
|
RUN apt-get update && apt-get install -y --no-install-recommends binutils \
|
|
&& pip install -r /app/requirements.txt \
|
|
&& cd /app/app && pyinstaller --onefile --add-data "ui:ui" wolServer.py \
|
|
&& mkdir -p /output && cp /app/app/dist/wolServer /output/ \
|
|
FROM scratch
|
|
COPY --from=builder /output /output' > Dockerfile
|
|
docker buildx build --platform linux/arm64/v8 --output type=local,dest=app/dist .
|
|
fi
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: executable-${{ matrix.arch }}
|
|
path: app/dist
|
|
|
|
release:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Create Dist Directory
|
|
run: mkdir -p app/dist
|
|
|
|
- name: Download Artifacts
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
path: app/dist
|
|
|
|
- name: Rename Artifacts
|
|
run: |
|
|
mv app/dist/executable-x86_64 app/dist/wolServer-x86_64
|
|
mv app/dist/executable-arm64 app/dist/wolServer-arm
|
|
|
|
- name: Generate Tag
|
|
id: tag
|
|
run: echo "TAG=v$(TZ='Europe/Athens' date +'%d%m%Y%H%M%S')" >> $GITEA_ENV
|
|
|
|
- name: Create Release
|
|
uses: akkuman/gitea-release-action@v1
|
|
with:
|
|
tag_name: "${{ env.TAG }}"
|
|
name: "${{ env.TAG }}"
|
|
target_commitish: main
|
|
body: "Automated push release"
|
|
token: ${{ secrets.mytoken }}
|
|
files: |-
|
|
app/dist/wolServer-*
|
|
|
|
cleanup:
|
|
needs: release
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Cleanup Buildx Containers
|
|
run: |
|
|
docker ps -q --filter "name=buildx" | xargs -r docker stop
|
|
docker ps -aq --filter "name=buildx" | xargs -r docker rm
|
|
docker images --filter "reference=moby/buildkit" -q | xargs -r docker rmi
|
|
docker images --filter "reference=arm-builder" -q | xargs -r docker rmi
|
|
docker images --filter "reference=multiarch/qemu-user-static" -q | xargs -r docker rmi
|
|
docker images --filter "reference=tonistiigi/binfmt" -q | xargs -r docker rmi
|
|
docker volume ls --filter "name=buildx" -q | xargs -r docker volume rm
|
|
#docker images --filter "reference=gitea/runner-images" -q | xargs -r docker rmi
|
|
#docker volume ls --filter "name=act" -q | xargs -r docker volume rm
|