improve build process include linux/arm64
This commit is contained in:
parent
cb735cbb97
commit
2ea407b64a
3 changed files with 118 additions and 43 deletions
|
|
@ -1,3 +1,13 @@
|
||||||
.git
|
**/.idea
|
||||||
.venv
|
**/.git
|
||||||
cd
|
**/.venv
|
||||||
|
.github/
|
||||||
|
.vscode/
|
||||||
|
.devcontainer/
|
||||||
|
ui/.nuxt
|
||||||
|
ui/.output
|
||||||
|
ui/node_modules
|
||||||
|
ui/dist
|
||||||
|
**/.env
|
||||||
|
./var/*
|
||||||
|
!./var/.gitignore
|
||||||
|
|
|
||||||
143
.github/workflows/main.yml
vendored
143
.github/workflows/main.yml
vendored
|
|
@ -12,9 +12,26 @@ on:
|
||||||
- info
|
- info
|
||||||
- warning
|
- warning
|
||||||
- debug
|
- debug
|
||||||
|
build:
|
||||||
|
description: "Build"
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
|
update_readme:
|
||||||
|
description: "Update Readme"
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
|
create_release:
|
||||||
|
description: "Create Release (requires build)"
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
|
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- "*"
|
- dev
|
||||||
|
- master
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- "**.md"
|
- "**.md"
|
||||||
- ".github/**"
|
- ".github/**"
|
||||||
|
|
@ -28,7 +45,7 @@ on:
|
||||||
env:
|
env:
|
||||||
DOCKERHUB_SLUG: arabcoders/ytptube
|
DOCKERHUB_SLUG: arabcoders/ytptube
|
||||||
GHCR_SLUG: ghcr.io/arabcoders/ytptube
|
GHCR_SLUG: ghcr.io/arabcoders/ytptube
|
||||||
PLATFORMS: linux/amd64
|
PLATFORMS: linux/amd64,linux/arm64
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-pr:
|
build-pr:
|
||||||
|
|
@ -38,6 +55,18 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install frontend dependencies
|
||||||
|
uses: bahmutov/npm-install@v1
|
||||||
|
with:
|
||||||
|
working-directory: ui
|
||||||
|
install-command: yarn --production --prefer-offline --frozen-lockfile
|
||||||
|
|
||||||
|
- name: Build frontend
|
||||||
|
uses: bahmutov/npm-install@v1
|
||||||
|
with:
|
||||||
|
working-directory: ui
|
||||||
|
install-command: yarn run generate
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
|
@ -48,12 +77,14 @@ jobs:
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: ${{ env.PLATFORMS }}
|
platforms: linux/amd64
|
||||||
push: false
|
push: false
|
||||||
|
cache-from: type=gha, scope=pr_${{ github.workflow }}
|
||||||
|
cache-to: type=gha, scope=pr_${{ github.workflow }}
|
||||||
|
|
||||||
push-build:
|
push-build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.event_name == 'push'
|
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
|
||||||
|
|
@ -61,6 +92,18 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install frontend dependencies
|
||||||
|
uses: bahmutov/npm-install@v1
|
||||||
|
with:
|
||||||
|
working-directory: ui
|
||||||
|
install-command: yarn --production --prefer-offline --frozen-lockfile
|
||||||
|
|
||||||
|
- name: Build frontend
|
||||||
|
uses: bahmutov/npm-install@v1
|
||||||
|
with:
|
||||||
|
working-directory: ui
|
||||||
|
install-command: yarn run generate
|
||||||
|
|
||||||
- name: Update Version File
|
- name: Update Version File
|
||||||
uses: ArabCoders/write-version-to-file@master
|
uses: ArabCoders/write-version-to-file@master
|
||||||
with:
|
with:
|
||||||
|
|
@ -123,9 +166,8 @@ jobs:
|
||||||
regex: 'APP_VERSION\s=\s\"(.+)\"'
|
regex: 'APP_VERSION\s=\s\"(.+)\"'
|
||||||
|
|
||||||
dockerhub-sync-readme:
|
dockerhub-sync-readme:
|
||||||
needs: push-build
|
|
||||||
if: endsWith(github.ref, github.event.repository.default_branch)
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
if: (github.event_name == 'push' && endsWith(github.ref, github.event.repository.default_branch)) || (github.event_name == 'workflow_dispatch' && github.event.inputs.update_readme == 'true')
|
||||||
steps:
|
steps:
|
||||||
- name: Sync README
|
- name: Sync README
|
||||||
uses: docker://lsiodev/readme-sync:latest
|
uses: docker://lsiodev/readme-sync:latest
|
||||||
|
|
@ -140,57 +182,80 @@ jobs:
|
||||||
args: /opt/docker-readme-sync/sync
|
args: /opt/docker-readme-sync/sync
|
||||||
|
|
||||||
create_release:
|
create_release:
|
||||||
needs: push-build
|
needs: publish_docker_images
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: endsWith(github.ref, github.event.repository.default_branch) && success()
|
if: (endsWith(github.ref, github.event.repository.default_branch) && success()) || (github.event_name == 'workflow_dispatch' && github.event.inputs.create_release == 'true')
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # so we can do git log for the full history
|
fetch-depth: 0 # so we can see all tags + full history
|
||||||
|
|
||||||
- name: Get commits between old and new
|
- name: Determine current branch
|
||||||
id: commits
|
id: branch
|
||||||
run: |
|
run: |
|
||||||
PREVIOUS_SHA="${{ github.event.before }}"
|
# github.ref_name should be "master", "main", or your branch name
|
||||||
CURRENT_SHA="${{ github.event.after }}"
|
echo "BRANCH_NAME=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
echo "Previous SHA: $PREVIOUS_SHA"
|
- name: Fetch the two latest tags for this branch
|
||||||
echo "Current SHA: $CURRENT_SHA"
|
id: last_two_tags
|
||||||
|
run: |
|
||||||
|
git fetch --tags
|
||||||
|
|
||||||
# If "before" is empty or all zeros, log all commits
|
BRANCH_NAME="${{ steps.branch.outputs.BRANCH_NAME }}"
|
||||||
if [ -z "$PREVIOUS_SHA" ] || [ "$PREVIOUS_SHA" = "0000000000000000000000000000000000000000" ]; then
|
echo "Current branch: $BRANCH_NAME"
|
||||||
LOG=$(git log --pretty=format:"- %h %s by %an")
|
|
||||||
else
|
# List tags matching "branchname-*" and sort by *creation date* descending
|
||||||
LOG=$(git log "$PREVIOUS_SHA".."$CURRENT_SHA" --pretty=format:"- %h %s by %an")
|
# Then pick the top 2
|
||||||
|
LATEST_TAGS=$(git tag --list "${BRANCH_NAME}-*" --sort=-creatordate | head -n 2)
|
||||||
|
TAG_COUNT=$(echo "$LATEST_TAGS" | wc -l)
|
||||||
|
|
||||||
|
echo "Found tags:"
|
||||||
|
echo "$LATEST_TAGS"
|
||||||
|
|
||||||
|
if [ "$TAG_COUNT" -lt 2 ]; then
|
||||||
|
echo "Not enough tags found (need at least 2) to compare commits."
|
||||||
|
echo "NOT_ENOUGH_TAGS=true" >> "$GITHUB_OUTPUT"
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# The first line is the newest tag
|
||||||
|
TAG_NEWEST=$(echo "$LATEST_TAGS" | sed -n '1p')
|
||||||
|
# The second line is the previous newest
|
||||||
|
TAG_PREVIOUS=$(echo "$LATEST_TAGS" | sed -n '2p')
|
||||||
|
|
||||||
|
echo "Newest tag: $TAG_NEWEST"
|
||||||
|
echo "Previous tag: $TAG_PREVIOUS"
|
||||||
|
|
||||||
|
# Expose them as outputs for next step
|
||||||
|
echo "NOT_ENOUGH_TAGS=false" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "TAG_NEWEST=$TAG_NEWEST" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "TAG_PREVIOUS=$TAG_PREVIOUS" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Generate commit log for newest tag
|
||||||
|
id: commits
|
||||||
|
if: steps.last_two_tags.outputs.NOT_ENOUGH_TAGS != 'true'
|
||||||
|
run: |
|
||||||
|
TAG_NEWEST="${{ steps.last_two_tags.outputs.TAG_NEWEST }}"
|
||||||
|
TAG_PREVIOUS="${{ steps.last_two_tags.outputs.TAG_PREVIOUS }}"
|
||||||
|
|
||||||
|
echo "Comparing commits between: $TAG_PREVIOUS..$TAG_NEWEST"
|
||||||
|
LOG=$(git log "$TAG_PREVIOUS".."$TAG_NEWEST" --pretty=format:"- %h %s by %an")
|
||||||
|
|
||||||
echo "LOG<<EOF" >> "$GITHUB_ENV"
|
echo "LOG<<EOF" >> "$GITHUB_ENV"
|
||||||
echo "$LOG" >> "$GITHUB_ENV"
|
echo "$LOG" >> "$GITHUB_ENV"
|
||||||
echo "EOF" >> "$GITHUB_ENV"
|
echo "EOF" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Fetch the most recent tag
|
- name: Create / Update GitHub Release for the newest tag
|
||||||
id: last_tag
|
if: steps.last_two_tags.outputs.NOT_ENOUGH_TAGS != 'true'
|
||||||
run: |
|
|
||||||
# Make sure we have all tags
|
|
||||||
git fetch --tags
|
|
||||||
|
|
||||||
# Get the latest tag by commit date (most recent)
|
|
||||||
# If there are no tags at all, set a fallback
|
|
||||||
LAST_TAG=$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1) 2>/dev/null || echo "no-tags-found")
|
|
||||||
|
|
||||||
echo "Latest tag found: $LAST_TAG"
|
|
||||||
echo "LAST_TAG=$LAST_TAG" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Create or update GitHub Release using last tag
|
|
||||||
uses: softprops/action-gh-release@master
|
uses: softprops/action-gh-release@master
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.last_tag.outputs.LAST_TAG }}
|
tag_name: ${{ steps.last_two_tags.outputs.TAG_NEWEST }}
|
||||||
name: "${{ steps.last_tag.outputs.LAST_TAG }}"
|
name: "${{ steps.last_two_tags.outputs.TAG_NEWEST }}"
|
||||||
body: ${{ env.LOG }}
|
body: ${{ env.LOG }}
|
||||||
|
append_body: true
|
||||||
|
generate_release_notes: true
|
||||||
|
make_latest: true
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
generate_release_notes: true
|
|
||||||
append_body: true
|
|
||||||
make_latest: true
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ FROM node:lts-alpine AS node_builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY ui ./
|
COPY ui ./
|
||||||
RUN yarn install --production --prefer-offline --frozen-lockfile && yarn run generate
|
RUN if [ ! -d /app/exported ]; then yarn install --production --prefer-offline --frozen-lockfile && yarn run generate; else echo "Skipping UI build, already built."; fi
|
||||||
|
|
||||||
FROM python:3.11-alpine AS python_builder
|
FROM python:3.11-alpine AS python_builder
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue