mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
- Release workflow builds macos-amd64/macos-arm64 tarballs on native runners - install.sh detects Darwin, downloads macos-* assets, installs LaunchDaemon - Dedicated _aether service account (dscl), env root:_aether 0640 - Launchd stdout/stderr in /var/log/aether (root-owned dir, service-writable files) - Wrapper script parses env literally without shell expansion - Auto-prune old releases (default keep 3) - README documents macOS launchd commands
301 lines
9.2 KiB
YAML
301 lines
9.2 KiB
YAML
name: Release Aether
|
|
|
|
on:
|
|
push:
|
|
tags: ['v*']
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
concurrency:
|
|
group: release-aether-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
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: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: true
|
|
matrix:
|
|
include:
|
|
- name: linux-amd64
|
|
target: x86_64-unknown-linux-musl
|
|
platform: linux
|
|
arch: amd64
|
|
os: ubuntu-latest
|
|
use_cross: true
|
|
- name: linux-arm64
|
|
target: aarch64-unknown-linux-musl
|
|
platform: linux
|
|
arch: arm64
|
|
os: ubuntu-latest
|
|
use_cross: true
|
|
- name: macos-amd64
|
|
target: x86_64-apple-darwin
|
|
platform: macos
|
|
arch: amd64
|
|
os: macos-15-intel
|
|
use_cross: false
|
|
- name: macos-arm64
|
|
target: aarch64-apple-darwin
|
|
platform: macos
|
|
arch: arm64
|
|
os: macos-15
|
|
use_cross: false
|
|
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
|
|
if: matrix.use_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
|
|
shell: bash
|
|
run: |
|
|
if [[ "${{ matrix.use_cross }}" == "true" ]]; then
|
|
cross build --release --locked -p aether-gateway --target ${{ matrix.target }}
|
|
else
|
|
cargo build --release --locked -p aether-gateway --target ${{ matrix.target }}
|
|
fi
|
|
|
|
- name: Upload binary artifact
|
|
uses: actions/upload-artifact@v5
|
|
with:
|
|
name: aether-gateway-${{ matrix.platform }}-${{ 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-linux-amd64/aether-gateway dist/aether-gateway-amd64
|
|
cp artifacts/aether-gateway-linux-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
|
|
|
|
package:
|
|
name: Release tarballs
|
|
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: Build release packages
|
|
run: |
|
|
set -euo pipefail
|
|
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
|
|
VERSION="${GITHUB_REF_NAME}"
|
|
else
|
|
VERSION="snapshot-${GITHUB_SHA::7}"
|
|
fi
|
|
|
|
mkdir -p package release-assets
|
|
for platform in linux macos; do
|
|
for arch in amd64 arm64; do
|
|
bundle="aether-${VERSION}-${platform}-${arch}"
|
|
root="package/${bundle}"
|
|
mkdir -p \
|
|
"${root}/bin" \
|
|
"${root}/frontend"
|
|
|
|
install -m 0755 "artifacts/aether-gateway-${platform}-${arch}/aether-gateway" "${root}/bin/aether-gateway"
|
|
cp -R artifacts/frontend-dist/. "${root}/frontend/"
|
|
sed "s/^VERSION=\"\${AETHER_VERSION:-}\"/VERSION=\"\${AETHER_VERSION:-${VERSION}}\"/" install.sh > "${root}/install.sh"
|
|
chmod 0755 "${root}/install.sh"
|
|
install -m 0644 docker-compose.yml "${root}/docker-compose.yml"
|
|
install -m 0644 .env.example "${root}/.env.example"
|
|
install -m 0755 generate_keys.sh "${root}/generate_keys.sh"
|
|
install -m 0644 README.md "${root}/README.md"
|
|
install -m 0644 LICENSE "${root}/LICENSE"
|
|
|
|
tar -C package -czf "release-assets/${bundle}.tar.gz" "${bundle}"
|
|
done
|
|
done
|
|
|
|
sed "s/^VERSION=\"\${AETHER_VERSION:-}\"/VERSION=\"\${AETHER_VERSION:-${VERSION}}\"/" install.sh > release-assets/install.sh
|
|
chmod +x release-assets/install.sh
|
|
(cd release-assets && sha256sum *.tar.gz > SHA256SUMS)
|
|
|
|
- name: Upload release package artifact
|
|
uses: actions/upload-artifact@v5
|
|
with:
|
|
name: release-assets
|
|
path: release-assets/*
|
|
if-no-files-found: error
|
|
retention-days: 7
|
|
|
|
github-release:
|
|
name: GitHub Release assets
|
|
needs: [docker, package]
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Classify release tag
|
|
id: release_tag
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
tag="${GITHUB_REF_NAME}"
|
|
if [[ ! "${tag}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z][0-9A-Za-z.-]*)?$ ]]; then
|
|
echo "Unsupported release tag: ${tag}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "${tag}" == *-* ]]; then
|
|
echo "prerelease=true" >> "${GITHUB_OUTPUT}"
|
|
echo "make_latest=false" >> "${GITHUB_OUTPUT}"
|
|
else
|
|
echo "prerelease=false" >> "${GITHUB_OUTPUT}"
|
|
echo "make_latest=true" >> "${GITHUB_OUTPUT}"
|
|
fi
|
|
|
|
- name: Download release package artifact
|
|
uses: actions/download-artifact@v5
|
|
with:
|
|
name: release-assets
|
|
path: release-assets
|
|
|
|
- name: Delete stale draft releases for tag
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
RELEASE_TAG: ${{ github.ref_name }}
|
|
REPOSITORY: ${{ github.repository }}
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
draft_ids="$(gh api "repos/${REPOSITORY}/releases" --paginate --jq '.[] | select(.tag_name == env.RELEASE_TAG and .draft == true) | .id')"
|
|
|
|
if [[ -z "${draft_ids}" ]]; then
|
|
echo "No stale draft releases for ${RELEASE_TAG}"
|
|
exit 0
|
|
fi
|
|
|
|
while IFS= read -r release_id; do
|
|
[[ -z "${release_id}" ]] && continue
|
|
echo "Deleting stale draft release ${release_id} for ${RELEASE_TAG}"
|
|
gh api -X DELETE "repos/${REPOSITORY}/releases/${release_id}"
|
|
done <<< "${draft_ids}"
|
|
|
|
- name: Publish GitHub Release assets
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
generate_release_notes: true
|
|
prerelease: ${{ steps.release_tag.outputs.prerelease }}
|
|
make_latest: ${{ steps.release_tag.outputs.make_latest }}
|
|
files: |
|
|
release-assets/*.tar.gz
|
|
release-assets/SHA256SUMS
|
|
release-assets/install.sh
|