fix(CI): make git version work on forks

This commit is contained in:
tyeth 2025-08-18 19:35:08 +01:00
parent 5e79a3725b
commit bc97ca02ad

View file

@ -55,9 +55,20 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Get WipperSnapper version - name: Get WipperSnapper version
run: | run: |
git fetch --prune --unshallow --tags git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
git describe --dirty --tags git fetch --prune --unshallow --all --tags
WS_VERSION="unknown"
if git describe --dirty --tags >/dev/null 2>&1; then
WS_VERSION=$(git describe --dirty --tags)
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags) echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
else
# Fallback for forks: 1.0.0-{owner}-{short-sha}
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
SHORT_SHA=$(git rev-parse --short HEAD)
WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
fi
echo "WS_VERSION: $WS_VERSION"
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
repository: adafruit/ci-arduino repository: adafruit/ci-arduino
@ -272,9 +283,17 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Get WipperSnapper version - name: Get WipperSnapper version
run: | run: |
git fetch --prune --unshallow --tags git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
git describe --dirty --tags git fetch --prune --unshallow --all --tags
if git describe --dirty --tags >/dev/null 2>&1; then
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags) echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
else
# Fallback for forks: 1.0.0-{owner}-{short-sha}
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
SHORT_SHA=$(git rev-parse --short HEAD)
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
fi
echo "WS_VERSION: $WS_VERSION"
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
repository: adafruit/ci-arduino repository: adafruit/ci-arduino
@ -388,9 +407,17 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Get WipperSnapper version - name: Get WipperSnapper version
run: | run: |
git fetch --prune --unshallow --tags git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
git describe --dirty --tags git fetch --prune --unshallow --all --tags
if git describe --dirty --tags >/dev/null 2>&1; then
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags) echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
else
# Fallback for forks: 1.0.0-{owner}-{short-sha}
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
SHORT_SHA=$(git rev-parse --short HEAD)
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
fi
echo "WS_VERSION: $WS_VERSION"
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
repository: adafruit/ci-arduino repository: adafruit/ci-arduino
@ -526,9 +553,17 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Get WipperSnapper version - name: Get WipperSnapper version
run: | run: |
git fetch --prune --unshallow --tags git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
git describe --dirty --tags git fetch --prune --unshallow --all --tags
if git describe --dirty --tags >/dev/null 2>&1; then
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags) echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
else
# Fallback for forks: 1.0.0-{owner}-{short-sha}
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
SHORT_SHA=$(git rev-parse --short HEAD)
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
fi
echo "WS_VERSION: $WS_VERSION"
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
repository: adafruit/ci-arduino repository: adafruit/ci-arduino
@ -608,9 +643,17 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Get WipperSnapper version - name: Get WipperSnapper version
run: | run: |
git fetch --prune --unshallow --tags git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
git describe --dirty --tags git fetch --prune --unshallow --all --tags
if git describe --dirty --tags >/dev/null 2>&1; then
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags) echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
else
# Fallback for forks: 1.0.0-{owner}-{short-sha}
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
SHORT_SHA=$(git rev-parse --short HEAD)
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
fi
echo "WS_VERSION: $WS_VERSION"
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
repository: adafruit/ci-arduino repository: adafruit/ci-arduino
@ -687,9 +730,17 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Get WipperSnapper version - name: Get WipperSnapper version
run: | run: |
git fetch --prune --unshallow --tags git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
git describe --dirty --tags git fetch --prune --unshallow --all --tags
if git describe --dirty --tags >/dev/null 2>&1; then
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags) echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
else
# Fallback for forks: 1.0.0-{owner}-{short-sha}
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
SHORT_SHA=$(git rev-parse --short HEAD)
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
fi
echo "WS_VERSION: $WS_VERSION"
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
repository: adafruit/ci-arduino repository: adafruit/ci-arduino
@ -784,9 +835,17 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Get WipperSnapper version - name: Get WipperSnapper version
run: | run: |
git fetch --prune --unshallow --tags git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
git describe --dirty --tags git fetch --prune --unshallow --all --tags
if git describe --dirty --tags >/dev/null 2>&1; then
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags) echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
else
# Fallback for forks: 1.0.0-{owner}-{short-sha}
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
SHORT_SHA=$(git rev-parse --short HEAD)
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
fi
echo "WS_VERSION: $WS_VERSION"
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
repository: adafruit/ci-arduino repository: adafruit/ci-arduino
@ -888,9 +947,17 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Get WipperSnapper version - name: Get WipperSnapper version
run: | run: |
git fetch --prune --unshallow --tags git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
git describe --dirty --tags git fetch --prune --unshallow --all --tags
if git describe --dirty --tags >/dev/null 2>&1; then
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags) echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
else
# Fallback for forks: 1.0.0-{owner}-{short-sha}
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
SHORT_SHA=$(git rev-parse --short HEAD)
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
fi
echo "WS_VERSION: $WS_VERSION"
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
repository: adafruit/ci-arduino repository: adafruit/ci-arduino