mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-04 08:27:46 +08:00
153 lines
4.1 KiB
YAML
153 lines
4.1 KiB
YAML
name: Build and Publish Docker Image
|
|
|
|
on:
|
|
push:
|
|
tags: ['v*']
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
GHCR_IMAGE: fawney19/aether
|
|
DOCKERHUB_IMAGE: fawney19/aether
|
|
|
|
jobs:
|
|
frontend:
|
|
name: Build frontend
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
cache-dependency-path: frontend/package-lock.json
|
|
|
|
- name: Install & build
|
|
working-directory: frontend
|
|
run: |
|
|
npm ci
|
|
npm run build
|
|
|
|
- name: Upload frontend artifact
|
|
uses: actions/upload-artifact@v5
|
|
with:
|
|
name: frontend-dist
|
|
path: frontend/dist/
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
build:
|
|
name: Build ${{ matrix.name }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: true
|
|
matrix:
|
|
include:
|
|
- name: linux-amd64
|
|
target: x86_64-unknown-linux-musl
|
|
arch: amd64
|
|
- name: linux-arm64
|
|
target: aarch64-unknown-linux-musl
|
|
arch: arm64
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
- name: Rust cache
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
shared-key: release-${{ matrix.target }}
|
|
workspaces: . -> target
|
|
|
|
- name: Install cross
|
|
uses: taiki-e/install-action@cross
|
|
|
|
- name: Build
|
|
env:
|
|
AETHER_VERSION: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || '' }}
|
|
CARGO_TERM_COLOR: always
|
|
run: cross build --release --locked -p aether-gateway --target ${{ matrix.target }}
|
|
|
|
- name: Upload binary artifact
|
|
uses: actions/upload-artifact@v5
|
|
with:
|
|
name: aether-gateway-${{ matrix.arch }}
|
|
path: target/${{ matrix.target }}/release/aether-gateway
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
docker:
|
|
name: Docker multi-arch
|
|
needs: [frontend, build]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v5
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Prepare dist layout
|
|
run: |
|
|
mkdir -p dist
|
|
cp artifacts/aether-gateway-amd64/aether-gateway dist/aether-gateway-amd64
|
|
cp artifacts/aether-gateway-arm64/aether-gateway dist/aether-gateway-arm64
|
|
chmod +x dist/aether-gateway-amd64 dist/aether-gateway-arm64
|
|
cp -r artifacts/frontend-dist dist/frontend
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
${{ env.REGISTRY }}/${{ env.GHCR_IMAGE }}
|
|
docker.io/${{ env.DOCKERHUB_IMAGE }}
|
|
tags: |
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=raw,value=pre,enable=${{ contains(github.ref, '-') }}
|
|
type=raw,value=fix,enable=${{ contains(github.ref, '-fix') }}
|
|
type=sha,prefix=
|
|
flavor: |
|
|
latest=auto
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile.app
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
platforms: linux/amd64,linux/arm64
|