mirror of
https://github.com/PRVTPRO/Amnezia-Web-Panel.git
synced 2026-09-18 01:44:10 +02:00
206 lines
5.6 KiB
YAML
206 lines
5.6 KiB
YAML
name: Build Binaries
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
env:
|
|
IMAGE_NAME: amnezia-panel
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install pyinstaller
|
|
pip install -r requirements.txt
|
|
|
|
- name: Build Linux
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
pyinstaller --name Amnezia-Web-Panel-Linux \
|
|
--add-data "static:static" \
|
|
--add-data "templates:templates" \
|
|
--add-data "translations:translations" \
|
|
--hidden-import uvicorn \
|
|
--hidden-import fastapi \
|
|
--clean \
|
|
-y \
|
|
-F app.py
|
|
|
|
- name: Build Windows
|
|
if: runner.os == 'Windows'
|
|
run: |
|
|
pyinstaller --name Amnezia-Web-Panel-Windows `
|
|
--add-data "static;static" `
|
|
--add-data "templates;templates" `
|
|
--add-data "translations;translations" `
|
|
--hidden-import uvicorn `
|
|
--hidden-import fastapi `
|
|
--clean `
|
|
-y `
|
|
-F app.py
|
|
|
|
- name: Build macOS
|
|
if: runner.os == 'macOS'
|
|
run: |
|
|
pyinstaller --name Amnezia-Web-Panel-macOS \
|
|
--add-data "static:static" \
|
|
--add-data "templates:templates" \
|
|
--add-data "translations:translations" \
|
|
--hidden-import uvicorn \
|
|
--hidden-import fastapi \
|
|
--clean \
|
|
-y \
|
|
-F app.py
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: binaries-${{ runner.os }}
|
|
path: dist/*
|
|
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- variant: default
|
|
dockerfile: Dockerfile
|
|
suffix: ''
|
|
# The panel runs on both x86_64 and ARM64 servers.
|
|
platforms: linux/amd64,linux/arm64
|
|
- variant: warp
|
|
dockerfile: Dockerfile.warp
|
|
suffix: '-warp'
|
|
# cloudflare-warp is installed via apt, which is slow under QEMU.
|
|
# linux/arm64 can be added here — the Cloudflare repo ships it.
|
|
platforms: linux/amd64
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Resolve image name
|
|
id: image
|
|
run: |
|
|
owner=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
|
|
echo "name=ghcr.io/${owner}/${IMAGE_NAME}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ steps.image.outputs.name }}
|
|
flavor: |
|
|
latest=false
|
|
${{ matrix.suffix != '' && format('suffix={0},onlatest=true', matrix.suffix) || '' }}
|
|
tags: |
|
|
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
|
|
type=ref,event=branch
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=semver,pattern={{major}}
|
|
type=sha,format=short
|
|
labels: |
|
|
org.opencontainers.image.title=Amnezia Web Panel${{ matrix.suffix }}
|
|
org.opencontainers.image.description=Web panel for managing Amnezia VPN servers
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ${{ matrix.dockerfile }}
|
|
platforms: ${{ matrix.platforms }}
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha,scope=${{ matrix.variant }}
|
|
cache-to: type=gha,mode=max,scope=${{ matrix.variant }}
|
|
|
|
- name: Job summary
|
|
run: |
|
|
{
|
|
echo "### Docker: ${{ matrix.variant }} (${{ matrix.dockerfile }})"
|
|
echo
|
|
echo "Platforms: \`${{ matrix.platforms }}\`"
|
|
echo
|
|
echo '```'
|
|
echo "${{ steps.meta.outputs.tags }}"
|
|
echo '```'
|
|
} >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
release:
|
|
needs: build
|
|
|
|
# Docker Buildx also uploads *.dockerbuild artifacts by default. Keep the
|
|
# release job scoped to the three binary artifacts produced by `build`.
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v5
|
|
with:
|
|
pattern: binaries-*
|
|
path: artifacts
|
|
merge-multiple: true
|
|
|
|
- name: Prepare release assets
|
|
run: |
|
|
test -f artifacts/Amnezia-Web-Panel-Linux
|
|
test -f artifacts/Amnezia-Web-Panel-macOS
|
|
test -f artifacts/Amnezia-Web-Panel-Windows.exe
|
|
chmod +x artifacts/Amnezia-Web-Panel-Linux artifacts/Amnezia-Web-Panel-macOS
|
|
ls -lh artifacts
|
|
|
|
- name: Publish Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
generate_release_notes: true
|
|
fail_on_unmatched_files: true
|
|
files: |
|
|
artifacts/Amnezia-Web-Panel-Linux
|
|
artifacts/Amnezia-Web-Panel-macOS
|
|
artifacts/Amnezia-Web-Panel-Windows.exe
|
|
|