mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-01 04:47:03 +08:00
ci: gate v3 release on version value changes (#7052)
Co-authored-by: DDSRem <1448139087@qq.com>
This commit is contained in:
42
.github/workflows/build-v3.yml
vendored
42
.github/workflows/build-v3.yml
vendored
@@ -12,7 +12,49 @@ permissions:
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
release-gate:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
publish: ${{ steps.detect.outputs.publish }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Detect version change
|
||||
id: detect
|
||||
env:
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
BEFORE_SHA: ${{ github.event.before }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ "$EVENT_NAME" = workflow_dispatch ]; then
|
||||
echo "publish=true" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
versions() {
|
||||
sed -nE "s/^(APP_VERSION|FRONTEND_VERSION)[[:space:]]*=[[:space:]]*'([^']+)'[[:space:]]*$/\1=\2/p" | sort
|
||||
}
|
||||
previous=$(git show "$BEFORE_SHA:version.py" | versions)
|
||||
current=$(versions < version.py)
|
||||
for value in APP_VERSION FRONTEND_VERSION; do
|
||||
if ! printf '%s\n' "$previous" | grep -q "^${value}=" ||
|
||||
! printf '%s\n' "$current" | grep -q "^${value}="; then
|
||||
echo "版本声明缺失: $value" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
if [ "$previous" = "$current" ]; then
|
||||
echo "publish=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "publish=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
Docker-build:
|
||||
needs: release-gate
|
||||
if: needs.release-gate.outputs.publish == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
name: Build Docker Image
|
||||
steps:
|
||||
|
||||
Reference in New Issue
Block a user