mirror of
https://github.com/m1k1o/neko.git
synced 2026-11-03 00:11:48 -06:00
Add latest version check and update logic for GHCR workflows (#637)
* feat: add latest version check and update logic for GHCR workflows. * feat: implement latest version checks in GHCR workflows and update related logic.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
name: Check if Latest Version
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
outputs:
|
||||
is_latest:
|
||||
description: "True if the pushed tag is the highest semver release tag overall."
|
||||
value: ${{ jobs.check.outputs.is_latest }}
|
||||
is_latest_major:
|
||||
description: "True if the pushed tag is the highest release tag within its major version."
|
||||
value: ${{ jobs.check.outputs.is_latest_major }}
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check if Latest Version
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
is_latest: ${{ steps.check.outputs.is_latest }}
|
||||
is_latest_major: ${{ steps.check.outputs.is_latest_major }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check if this is the latest semver tag
|
||||
id: check
|
||||
run: |
|
||||
LATEST=$(git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1)
|
||||
if [[ "$LATEST" == "$GITHUB_REF_NAME" ]]; then
|
||||
echo "is_latest=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "is_latest=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
PUSHED_MAJOR=$(echo "$GITHUB_REF_NAME" | grep -oE '^v[0-9]+')
|
||||
LATEST_FOR_MAJOR=$(git tag --sort=-version:refname | grep -E "^${PUSHED_MAJOR}\.[0-9]+\.[0-9]+$" | head -1)
|
||||
if [[ "$LATEST_FOR_MAJOR" == "$GITHUB_REF_NAME" ]]; then
|
||||
echo "is_latest_major=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "is_latest_major=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
@@ -6,17 +6,24 @@ on:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
check-latest:
|
||||
name: Check if Latest Version
|
||||
uses: ./.github/workflows/check_latest.yml
|
||||
|
||||
build-base:
|
||||
name: Base Image
|
||||
needs: check-latest
|
||||
uses: ./.github/workflows/image_base.yml
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
latest: ${{ needs.check-latest.outputs.is_latest == 'true' }}
|
||||
latest_major: ${{ needs.check-latest.outputs.is_latest_major == 'true' }}
|
||||
secrets: inherit
|
||||
|
||||
build-app:
|
||||
name: App Image
|
||||
uses: ./.github/workflows/image_app.yml
|
||||
needs: build-base
|
||||
needs: [build-base, check-latest]
|
||||
strategy:
|
||||
# Will build all images even if some fail.
|
||||
fail-fast: false
|
||||
@@ -54,4 +61,6 @@ jobs:
|
||||
with:
|
||||
name: ${{ matrix.name }}
|
||||
platforms: ${{ matrix.platforms }}
|
||||
latest: ${{ needs.check-latest.outputs.is_latest == 'true' }}
|
||||
latest_major: ${{ needs.check-latest.outputs.is_latest_major == 'true' }}
|
||||
secrets: inherit
|
||||
|
||||
@@ -6,19 +6,26 @@ on:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
check-latest:
|
||||
name: Check if Latest Version
|
||||
uses: ./.github/workflows/check_latest.yml
|
||||
|
||||
build-base:
|
||||
name: Base Image
|
||||
needs: check-latest
|
||||
uses: ./.github/workflows/image_base.yml
|
||||
with:
|
||||
flavor: intel
|
||||
platforms: linux/amd64
|
||||
dockerfile: Dockerfile.intel
|
||||
latest: ${{ needs.check-latest.outputs.is_latest == 'true' }}
|
||||
latest_major: ${{ needs.check-latest.outputs.is_latest_major == 'true' }}
|
||||
secrets: inherit
|
||||
|
||||
build-app:
|
||||
name: App Image
|
||||
uses: ./.github/workflows/image_app.yml
|
||||
needs: build-base
|
||||
needs: [build-base, check-latest]
|
||||
strategy:
|
||||
# Will build all images even if some fail.
|
||||
fail-fast: false
|
||||
@@ -44,4 +51,6 @@ jobs:
|
||||
flavor: intel
|
||||
platforms: ${{ matrix.platforms }}
|
||||
dockerfile: ${{ matrix.dockerfile }}
|
||||
latest: ${{ needs.check-latest.outputs.is_latest == 'true' }}
|
||||
latest_major: ${{ needs.check-latest.outputs.is_latest_major == 'true' }}
|
||||
secrets: inherit
|
||||
|
||||
@@ -6,19 +6,26 @@ on:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
check-latest:
|
||||
name: Check if Latest Version
|
||||
uses: ./.github/workflows/check_latest.yml
|
||||
|
||||
build-base:
|
||||
name: Base Image
|
||||
needs: check-latest
|
||||
uses: ./.github/workflows/image_base.yml
|
||||
with:
|
||||
flavor: nvidia
|
||||
platforms: linux/amd64
|
||||
dockerfile: Dockerfile.nvidia
|
||||
latest: ${{ needs.check-latest.outputs.is_latest == 'true' }}
|
||||
latest_major: ${{ needs.check-latest.outputs.is_latest_major == 'true' }}
|
||||
secrets: inherit
|
||||
|
||||
build-app:
|
||||
name: App Image
|
||||
uses: ./.github/workflows/image_app.yml
|
||||
needs: build-base
|
||||
needs: [build-base, check-latest]
|
||||
strategy:
|
||||
# Will build all images even if some fail.
|
||||
fail-fast: false
|
||||
@@ -39,4 +46,6 @@ jobs:
|
||||
flavor: nvidia
|
||||
platforms: ${{ matrix.platforms }}
|
||||
dockerfile: ${{ matrix.dockerfile }}
|
||||
latest: ${{ needs.check-latest.outputs.is_latest == 'true' }}
|
||||
latest_major: ${{ needs.check-latest.outputs.is_latest_major == 'true' }}
|
||||
secrets: inherit
|
||||
|
||||
@@ -22,6 +22,16 @@ on:
|
||||
type: string
|
||||
default: "Dockerfile"
|
||||
description: "The Dockerfile to use for building the image."
|
||||
latest:
|
||||
required: false
|
||||
type: boolean
|
||||
default: true
|
||||
description: "Whether to update the latest tag (set to false for maintenance branches)."
|
||||
latest_major:
|
||||
required: false
|
||||
type: boolean
|
||||
default: true
|
||||
description: "Whether to update the major tag (set to false if a newer patch exists in this major)."
|
||||
|
||||
env:
|
||||
FLAVOR_PREFIX: ${{ inputs.flavor && format('{0}-', inputs.flavor) || '' }}
|
||||
@@ -47,11 +57,13 @@ jobs:
|
||||
id: meta
|
||||
with:
|
||||
images: ghcr.io/${{ github.repository }}/${{ env.FLAVOR_PREFIX }}${{ inputs.name }}
|
||||
flavor: |
|
||||
latest=${{ inputs.latest && 'auto' || 'false' }}
|
||||
tags: |
|
||||
type=edge,branch=master
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=semver,pattern={{major}},enable=${{ inputs.latest_major }}
|
||||
type=sha,format=long
|
||||
|
||||
- name: Log in to the Container registry
|
||||
|
||||
@@ -18,6 +18,16 @@ on:
|
||||
type: string
|
||||
default: "Dockerfile"
|
||||
description: "The Dockerfile to use for building the image."
|
||||
latest:
|
||||
required: false
|
||||
type: boolean
|
||||
default: true
|
||||
description: "Whether to update the latest tag (set to false for maintenance branches)."
|
||||
latest_major:
|
||||
required: false
|
||||
type: boolean
|
||||
default: true
|
||||
description: "Whether to update the major tag (set to false if a newer patch exists in this major)."
|
||||
|
||||
env:
|
||||
FLAVOR_PREFIX: ${{ inputs.flavor && format('{0}-', inputs.flavor) || '' }}
|
||||
@@ -54,11 +64,13 @@ jobs:
|
||||
id: meta
|
||||
with:
|
||||
images: ghcr.io/${{ github.repository }}/${{ env.FLAVOR_PREFIX }}base
|
||||
flavor: |
|
||||
latest=${{ inputs.latest && 'auto' || 'false' }}
|
||||
tags: |
|
||||
type=edge,branch=master
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=semver,pattern={{major}},enable=${{ inputs.latest_major }}
|
||||
type=sha,format=long
|
||||
|
||||
- name: Log in to the Container registry
|
||||
|
||||
Reference in New Issue
Block a user