mirror of
https://github.com/m1k1o/neko.git
synced 2026-11-03 08:21:50 -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*'
|
- 'v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
check-latest:
|
||||||
|
name: Check if Latest Version
|
||||||
|
uses: ./.github/workflows/check_latest.yml
|
||||||
|
|
||||||
build-base:
|
build-base:
|
||||||
name: Base Image
|
name: Base Image
|
||||||
|
needs: check-latest
|
||||||
uses: ./.github/workflows/image_base.yml
|
uses: ./.github/workflows/image_base.yml
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
|
latest: ${{ needs.check-latest.outputs.is_latest == 'true' }}
|
||||||
|
latest_major: ${{ needs.check-latest.outputs.is_latest_major == 'true' }}
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
build-app:
|
build-app:
|
||||||
name: App Image
|
name: App Image
|
||||||
uses: ./.github/workflows/image_app.yml
|
uses: ./.github/workflows/image_app.yml
|
||||||
needs: build-base
|
needs: [build-base, check-latest]
|
||||||
strategy:
|
strategy:
|
||||||
# Will build all images even if some fail.
|
# Will build all images even if some fail.
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@@ -53,4 +60,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: ${{ matrix.name }}
|
name: ${{ matrix.name }}
|
||||||
platforms: ${{ matrix.platforms }}
|
platforms: ${{ matrix.platforms }}
|
||||||
|
latest: ${{ needs.check-latest.outputs.is_latest == 'true' }}
|
||||||
|
latest_major: ${{ needs.check-latest.outputs.is_latest_major == 'true' }}
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|||||||
@@ -6,19 +6,26 @@ on:
|
|||||||
- 'v*'
|
- 'v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
check-latest:
|
||||||
|
name: Check if Latest Version
|
||||||
|
uses: ./.github/workflows/check_latest.yml
|
||||||
|
|
||||||
build-base:
|
build-base:
|
||||||
name: Base Image
|
name: Base Image
|
||||||
|
needs: check-latest
|
||||||
uses: ./.github/workflows/image_base.yml
|
uses: ./.github/workflows/image_base.yml
|
||||||
with:
|
with:
|
||||||
flavor: intel
|
flavor: intel
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
dockerfile: Dockerfile.intel
|
dockerfile: Dockerfile.intel
|
||||||
|
latest: ${{ needs.check-latest.outputs.is_latest == 'true' }}
|
||||||
|
latest_major: ${{ needs.check-latest.outputs.is_latest_major == 'true' }}
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
build-app:
|
build-app:
|
||||||
name: App Image
|
name: App Image
|
||||||
uses: ./.github/workflows/image_app.yml
|
uses: ./.github/workflows/image_app.yml
|
||||||
needs: build-base
|
needs: [build-base, check-latest]
|
||||||
strategy:
|
strategy:
|
||||||
# Will build all images even if some fail.
|
# Will build all images even if some fail.
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@@ -43,4 +50,6 @@ jobs:
|
|||||||
flavor: intel
|
flavor: intel
|
||||||
platforms: ${{ matrix.platforms }}
|
platforms: ${{ matrix.platforms }}
|
||||||
dockerfile: ${{ matrix.dockerfile }}
|
dockerfile: ${{ matrix.dockerfile }}
|
||||||
|
latest: ${{ needs.check-latest.outputs.is_latest == 'true' }}
|
||||||
|
latest_major: ${{ needs.check-latest.outputs.is_latest_major == 'true' }}
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|||||||
@@ -6,19 +6,26 @@ on:
|
|||||||
- 'v*'
|
- 'v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
check-latest:
|
||||||
|
name: Check if Latest Version
|
||||||
|
uses: ./.github/workflows/check_latest.yml
|
||||||
|
|
||||||
build-base:
|
build-base:
|
||||||
name: Base Image
|
name: Base Image
|
||||||
|
needs: check-latest
|
||||||
uses: ./.github/workflows/image_base.yml
|
uses: ./.github/workflows/image_base.yml
|
||||||
with:
|
with:
|
||||||
flavor: nvidia
|
flavor: nvidia
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
dockerfile: Dockerfile.nvidia
|
dockerfile: Dockerfile.nvidia
|
||||||
|
latest: ${{ needs.check-latest.outputs.is_latest == 'true' }}
|
||||||
|
latest_major: ${{ needs.check-latest.outputs.is_latest_major == 'true' }}
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
build-app:
|
build-app:
|
||||||
name: App Image
|
name: App Image
|
||||||
uses: ./.github/workflows/image_app.yml
|
uses: ./.github/workflows/image_app.yml
|
||||||
needs: build-base
|
needs: [build-base, check-latest]
|
||||||
strategy:
|
strategy:
|
||||||
# Will build all images even if some fail.
|
# Will build all images even if some fail.
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@@ -39,4 +46,6 @@ jobs:
|
|||||||
flavor: nvidia
|
flavor: nvidia
|
||||||
platforms: ${{ matrix.platforms }}
|
platforms: ${{ matrix.platforms }}
|
||||||
dockerfile: ${{ matrix.dockerfile }}
|
dockerfile: ${{ matrix.dockerfile }}
|
||||||
|
latest: ${{ needs.check-latest.outputs.is_latest == 'true' }}
|
||||||
|
latest_major: ${{ needs.check-latest.outputs.is_latest_major == 'true' }}
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|||||||
@@ -22,6 +22,16 @@ on:
|
|||||||
type: string
|
type: string
|
||||||
default: "Dockerfile"
|
default: "Dockerfile"
|
||||||
description: "The Dockerfile to use for building the image."
|
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:
|
env:
|
||||||
FLAVOR_PREFIX: ${{ inputs.flavor && format('{0}-', inputs.flavor) || '' }}
|
FLAVOR_PREFIX: ${{ inputs.flavor && format('{0}-', inputs.flavor) || '' }}
|
||||||
@@ -47,11 +57,13 @@ jobs:
|
|||||||
id: meta
|
id: meta
|
||||||
with:
|
with:
|
||||||
images: ghcr.io/${{ github.repository }}/${{ env.FLAVOR_PREFIX }}${{ inputs.name }}
|
images: ghcr.io/${{ github.repository }}/${{ env.FLAVOR_PREFIX }}${{ inputs.name }}
|
||||||
|
flavor: |
|
||||||
|
latest=${{ inputs.latest && 'auto' || 'false' }}
|
||||||
tags: |
|
tags: |
|
||||||
type=edge,branch=master
|
type=edge,branch=master
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}},enable=${{ inputs.latest_major }}
|
||||||
type=sha,format=long
|
type=sha,format=long
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
|
|||||||
@@ -18,6 +18,16 @@ on:
|
|||||||
type: string
|
type: string
|
||||||
default: "Dockerfile"
|
default: "Dockerfile"
|
||||||
description: "The Dockerfile to use for building the image."
|
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:
|
env:
|
||||||
FLAVOR_PREFIX: ${{ inputs.flavor && format('{0}-', inputs.flavor) || '' }}
|
FLAVOR_PREFIX: ${{ inputs.flavor && format('{0}-', inputs.flavor) || '' }}
|
||||||
@@ -54,11 +64,13 @@ jobs:
|
|||||||
id: meta
|
id: meta
|
||||||
with:
|
with:
|
||||||
images: ghcr.io/${{ github.repository }}/${{ env.FLAVOR_PREFIX }}base
|
images: ghcr.io/${{ github.repository }}/${{ env.FLAVOR_PREFIX }}base
|
||||||
|
flavor: |
|
||||||
|
latest=${{ inputs.latest && 'auto' || 'false' }}
|
||||||
tags: |
|
tags: |
|
||||||
type=edge,branch=master
|
type=edge,branch=master
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}},enable=${{ inputs.latest_major }}
|
||||||
type=sha,format=long
|
type=sha,format=long
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
|
|||||||
Reference in New Issue
Block a user