A main push now skips itself when its commit already carries a v* tag (the tag build covers it - release with git push --follow-tags) or when it only changes wiki/** or *.md. Checked inside the job, so tag builds are never path-filtered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,12 @@ name: Firmware
|
||||
#
|
||||
# Releases go through the Gitea API with plain curl (actions/upload-artifact
|
||||
# is unreliable on this runner - same pattern as parking_solution).
|
||||
#
|
||||
# A main push skips itself (step "Skip?") when (a) the commit already carries a
|
||||
# v* tag - the tag build covers it; release with ONE push so the tag exists
|
||||
# when this runs: git push --follow-tags origin main - or (b) it only
|
||||
# changes docs (wiki/**, *.md). Done in-job rather than with paths-ignore so a
|
||||
# tag build can never be skipped by a path filter. Tag builds always run.
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -33,7 +39,29 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Skip?
|
||||
env:
|
||||
BEFORE: ${{ github.event.before }}
|
||||
run: |
|
||||
SKIP=false
|
||||
if [ "${GITHUB_REF#refs/tags/}" = "${GITHUB_REF}" ] && [ "${GITHUB_EVENT_NAME}" = "push" ]; then
|
||||
# (a) already tagged v* ? (annotated tags list their commit as <tag>^{})
|
||||
if git ls-remote --tags origin 'v*' | grep -q "^${GITHUB_SHA}"; then
|
||||
echo "commit ${GITHUB_SHA:0:7} is tagged - the tag build covers it"; SKIP=true
|
||||
# (b) docs only? Needs the previous head; a new branch / force push just builds.
|
||||
elif [ -n "$BEFORE" ] && [ "$BEFORE" != "0000000000000000000000000000000000000000" ] &&
|
||||
git fetch -q --depth=1 origin "$BEFORE" 2>/dev/null; then
|
||||
CHANGED=$(git diff --name-only "$BEFORE" "$GITHUB_SHA")
|
||||
echo "changed files:"; echo "$CHANGED"
|
||||
if [ -n "$CHANGED" ] && ! echo "$CHANGED" | grep -qvE '^wiki/|\.md$'; then
|
||||
echo "docs-only change - no firmware build"; SKIP=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
echo "SKIP=${SKIP}" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Version
|
||||
if: env.SKIP != 'true'
|
||||
run: |
|
||||
if [ "${GITHUB_REF#refs/tags/}" != "${GITHUB_REF}" ]; then
|
||||
VERSION="${GITHUB_REF_NAME}"
|
||||
@@ -46,6 +74,7 @@ jobs:
|
||||
echo "version: ${VERSION}"
|
||||
|
||||
- name: Cache PlatformIO
|
||||
if: env.SKIP != 'true'
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
@@ -55,6 +84,7 @@ jobs:
|
||||
key: pio-${{ hashFiles('platformio.ini') }}
|
||||
|
||||
- name: Install PlatformIO
|
||||
if: env.SKIP != 'true'
|
||||
run: |
|
||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
@@ -62,6 +92,7 @@ jobs:
|
||||
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Build
|
||||
if: env.SKIP != 'true'
|
||||
run: |
|
||||
export PLATFORMIO_BUILD_FLAGS="-DFW_VERSION=\\\"${VERSION}\\\""
|
||||
pio run
|
||||
@@ -72,7 +103,7 @@ jobs:
|
||||
ls -la dist/
|
||||
|
||||
- name: Sign + manifest (tags only)
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
if: env.SKIP != 'true' && startsWith(github.ref, 'refs/tags/')
|
||||
env:
|
||||
BMW_NISSAN_FIRMWARE_SIGNING_KEY: ${{ secrets.BMW_NISSAN_FIRMWARE_SIGNING_KEY }}
|
||||
run: |
|
||||
@@ -93,6 +124,7 @@ jobs:
|
||||
cat dist/manifest.txt
|
||||
|
||||
- name: Publish release
|
||||
if: env.SKIP != 'true'
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
API: ${{ github.api_url }}
|
||||
|
||||
Reference in New Issue
Block a user