Merge pull request #794 from tyeth/git-describe-fork-fix

fix(CI): make git version work on forks
This commit is contained in:
Tyeth Gundry 2025-08-18 20:33:03 +01:00 committed by GitHub
commit e06ebab53a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --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)
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
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags) if git describe --dirty --tags >/dev/null 2>&1; then
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
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags) if git describe --dirty --tags >/dev/null 2>&1; then
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
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags) if git describe --dirty --tags >/dev/null 2>&1; then
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
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags) if git describe --dirty --tags >/dev/null 2>&1; then
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
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags) if git describe --dirty --tags >/dev/null 2>&1; then
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
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags) if git describe --dirty --tags >/dev/null 2>&1; then
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
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags) if git describe --dirty --tags >/dev/null 2>&1; then
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