test new build system
This commit is contained in:
parent
1c9a893865
commit
ec43b0290c
3 changed files with 139 additions and 87 deletions
52
.github/workflows/build-pr.yml
vendored
Normal file
52
.github/workflows/build-pr.yml
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
name: Build PR (docker amd64)
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths-ignore:
|
||||||
|
- "**.md"
|
||||||
|
- ".github/ISSUE_TEMPLATE/**"
|
||||||
|
|
||||||
|
env:
|
||||||
|
PNPM_VERSION: 10
|
||||||
|
NODE_VERSION: 20
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-pr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: ${{ env.PNPM_VERSION }}
|
||||||
|
|
||||||
|
- name: Install Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
cache: pnpm
|
||||||
|
cache-dependency-path: "ui/pnpm-lock.yaml"
|
||||||
|
|
||||||
|
- name: Install frontend dependencies & Build
|
||||||
|
working-directory: ui
|
||||||
|
run: |
|
||||||
|
pnpm install --production --prefer-offline --frozen-lockfile
|
||||||
|
pnpm run generate
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build commit to check (amd64 only)
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: false
|
||||||
|
cache-from: type=gha,scope=${{ github.workflow }}
|
||||||
|
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
|
||||||
|
provenance: false
|
||||||
|
|
||||||
171
.github/workflows/main.yml
vendored
171
.github/workflows/main.yml
vendored
|
|
@ -1,40 +1,22 @@
|
||||||
name: build
|
name: Build Docker (native multi-arch)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
logLevel:
|
|
||||||
description: "Log level"
|
|
||||||
required: true
|
|
||||||
default: "warning"
|
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- info
|
|
||||||
- warning
|
|
||||||
- debug
|
|
||||||
build:
|
build:
|
||||||
description: "Build"
|
description: "Build and publish native multi-arch image"
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
type: boolean
|
type: boolean
|
||||||
|
default: true
|
||||||
update_readme:
|
update_readme:
|
||||||
description: "Update Readme"
|
description: "Also sync DockerHub README"
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
type: boolean
|
type: boolean
|
||||||
|
default: false
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- dev
|
- dev
|
||||||
- master
|
- master
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
paths-ignore:
|
|
||||||
- "**.md"
|
|
||||||
- ".github/**"
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- "master"
|
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- "**.md"
|
- "**.md"
|
||||||
- ".github/ISSUE_TEMPLATE/**"
|
- ".github/ISSUE_TEMPLATE/**"
|
||||||
|
|
@ -46,55 +28,21 @@ env:
|
||||||
NODE_VERSION: 20
|
NODE_VERSION: 20
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-pr:
|
docker-build-arch:
|
||||||
runs-on: ubuntu-latest
|
name: Build image (${{ matrix.arch }})
|
||||||
if: github.event_name == 'pull_request'
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
strategy:
|
||||||
- name: Checkout
|
matrix:
|
||||||
uses: actions/checkout@v4
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
- name: Install pnpm
|
arch: amd64
|
||||||
uses: pnpm/action-setup@v4
|
- os: ubuntu-24.04-arm64
|
||||||
with:
|
arch: arm64
|
||||||
version: ${{ env.PNPM_VERSION }}
|
|
||||||
|
|
||||||
- name: Install Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
|
||||||
cache: pnpm
|
|
||||||
cache-dependency-path: "ui/pnpm-lock.yaml"
|
|
||||||
|
|
||||||
- name: Install frontend dependencies & Build
|
|
||||||
working-directory: ui
|
|
||||||
run: |
|
|
||||||
pnpm install --production --prefer-offline --frozen-lockfile
|
|
||||||
pnpm run generate
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Build commit to check.
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64
|
|
||||||
push: false
|
|
||||||
cache-from: type=gha, scope=${{ github.workflow }}
|
|
||||||
cache-to: type=gha, mode=max, scope=${{ github.workflow }}
|
|
||||||
|
|
||||||
push-build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.build == 'true')
|
|
||||||
permissions:
|
permissions:
|
||||||
packages: write
|
packages: write
|
||||||
contents: write
|
contents: write
|
||||||
env:
|
env:
|
||||||
PLATFORMS: ${{ startsWith(github.ref, 'refs/tags/v') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
|
ARCH: ${{ matrix.arch }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
@ -133,9 +81,7 @@ jobs:
|
||||||
DATE=$(date -u +"%Y%m%d")
|
DATE=$(date -u +"%Y%m%d")
|
||||||
BRANCH=$(echo "${GITHUB_REF#refs/heads/}" | sed 's/\//-/g')
|
BRANCH=$(echo "${GITHUB_REF#refs/heads/}" | sed 's/\//-/g')
|
||||||
|
|
||||||
echo "Current version: ${VERSION}, Branch: ${BRANCH}, SHA: ${SHA}, Date: ${DATE}"
|
echo "APP_VERSION=${VERSION}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
echo "APP_VERSION=${VERSION}" >> $"$GITHUB_ENV"
|
|
||||||
echo "APP_SHA=${SHA}" >> "$GITHUB_ENV"
|
echo "APP_SHA=${SHA}" >> "$GITHUB_ENV"
|
||||||
echo "APP_DATE=${DATE}" >> "$GITHUB_ENV"
|
echo "APP_DATE=${DATE}" >> "$GITHUB_ENV"
|
||||||
echo "APP_BRANCH=${BRANCH}" >> "$GITHUB_ENV"
|
echo "APP_BRANCH=${BRANCH}" >> "$GITHUB_ENV"
|
||||||
|
|
@ -147,25 +93,20 @@ jobs:
|
||||||
-e "s/^APP_BRANCH = \".*\"/APP_BRANCH = \"${BRANCH}\"/" \
|
-e "s/^APP_BRANCH = \".*\"/APP_BRANCH = \"${BRANCH}\"/" \
|
||||||
app/library/version.py
|
app/library/version.py
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Docker meta (arch-suffixed)
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Docker meta
|
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
${{ env.DOCKERHUB_SLUG }}
|
${{ env.DOCKERHUB_SLUG }}
|
||||||
${{ env.GHCR_SLUG }}
|
${{ env.GHCR_SLUG }}
|
||||||
tags: |
|
|
||||||
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=tag
|
|
||||||
flavor: |
|
flavor: |
|
||||||
latest=false
|
latest=false
|
||||||
|
suffix=-${{ env.ARCH }}
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=tag
|
||||||
|
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
|
|
@ -180,16 +121,71 @@ jobs:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and push (native per-arch)
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: ${{ env.PLATFORMS }}
|
platforms: linux/${{ env.ARCH }}
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha, scope=${{ github.workflow }}
|
cache-from: |
|
||||||
cache-to: type=gha, mode=max, scope=${{ github.workflow }}
|
type=gha,scope=${{ github.workflow }}
|
||||||
|
type=registry,ref=ghcr.io/arabcoders/ytptube:buildcache
|
||||||
|
cache-to: |
|
||||||
|
type=gha,mode=max,scope=${{ github.workflow }}
|
||||||
|
type=registry,ref=ghcr.io/arabcoders/ytptube:buildcache,mode=max
|
||||||
|
provenance: false
|
||||||
|
|
||||||
|
docker-publish-manifest:
|
||||||
|
name: Publish multi-arch manifest
|
||||||
|
needs: [docker-build-arch]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
contents: read
|
||||||
|
steps:
|
||||||
|
- name: Docker meta (final tags)
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
${{ env.DOCKERHUB_SLUG }}
|
||||||
|
${{ env.GHCR_SLUG }}
|
||||||
|
flavor: |
|
||||||
|
latest=false
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=tag
|
||||||
|
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||||
|
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Create and push manifest list
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
IFS=$'\n'
|
||||||
|
for tag in $(echo "${{ steps.meta.outputs.tags }}"); do
|
||||||
|
echo "Creating manifest for ${tag}"
|
||||||
|
docker buildx imagetools create \
|
||||||
|
--tag "$tag" \
|
||||||
|
"${tag}-amd64" \
|
||||||
|
"${tag}-arm64"
|
||||||
|
done
|
||||||
|
|
||||||
- name: Overwrite GitHub release notes
|
- name: Overwrite GitHub release notes
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
|
@ -213,7 +209,7 @@ jobs:
|
||||||
const { data: comparison } = await github.rest.repos.compareCommits({
|
const { data: comparison } = await github.rest.repos.compareCommits({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
base: latestRelease.data[1]?.tag_name || '', // fallback to second latest tag
|
base: latestRelease.data[1]?.tag_name || '',
|
||||||
head: tag,
|
head: tag,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -238,6 +234,7 @@ jobs:
|
||||||
});
|
});
|
||||||
|
|
||||||
dockerhub-sync-readme:
|
dockerhub-sync-readme:
|
||||||
|
name: DockerHub README sync
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
|
||||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -25,6 +25,7 @@
|
||||||
"bilibili",
|
"bilibili",
|
||||||
"brainicism",
|
"brainicism",
|
||||||
"brotlicffi",
|
"brotlicffi",
|
||||||
|
"buildcache",
|
||||||
"choco",
|
"choco",
|
||||||
"consoletitle",
|
"consoletitle",
|
||||||
"continuedl",
|
"continuedl",
|
||||||
|
|
@ -52,10 +53,12 @@
|
||||||
"fribidi",
|
"fribidi",
|
||||||
"getpid",
|
"getpid",
|
||||||
"gibibytes",
|
"gibibytes",
|
||||||
|
"gitpython",
|
||||||
"gpac",
|
"gpac",
|
||||||
"hiddenimports",
|
"hiddenimports",
|
||||||
"hookspath",
|
"hookspath",
|
||||||
"httpx",
|
"httpx",
|
||||||
|
"imagetools",
|
||||||
"kibibytes",
|
"kibibytes",
|
||||||
"levelno",
|
"levelno",
|
||||||
"libcurl",
|
"libcurl",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue