Files
WOL-LY/.gitea/workflows/release.yaml

117 lines
3.7 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)
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
WORKDIR /app
COPY requirements.txt .
COPY app ./app
ENV PIP_ROOT_USER_ACTION=ignore
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' > Dockerfile.arm
docker buildx build --platform linux/arm64/v8 -t arm-builder --load -f Dockerfile.arm .
mkdir -p app/dist
container_id=$(docker create --platform linux/arm64/v8 arm-builder)
docker cp $container_id:/app/app/dist/wolServer app/dist/wolServer
docker rm $container_id
fi
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: executable-${{ matrix.arch }}
path: app/dist/wolServer
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/wolServer app/dist/wolServer-x86_64 || true
mv app/dist/executable-arm64/wolServer app/dist/wolServer-arm || true
- 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