Skip to content

Commit bc97ca0

Browse files
committed
fix(CI): make git version work on forks
1 parent 5e79a37 commit bc97ca0

File tree

1 file changed

+91
-24
lines changed

1 file changed

+91
-24
lines changed

.github/workflows/build-clang-doxy.yml

Lines changed: 91 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,20 @@ jobs:
5555
- uses: actions/checkout@v4
5656
- name: Get WipperSnapper version
5757
run: |
58-
git fetch --prune --unshallow --tags
59-
git describe --dirty --tags
60-
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
58+
git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
59+
git fetch --prune --unshallow --all --tags
60+
WS_VERSION="unknown"
61+
if git describe --dirty --tags >/dev/null 2>&1; then
62+
WS_VERSION=$(git describe --dirty --tags)
63+
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
64+
else
65+
# Fallback for forks: 1.0.0-{owner}-{short-sha}
66+
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
67+
SHORT_SHA=$(git rev-parse --short HEAD)
68+
WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
69+
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
70+
fi
71+
echo "WS_VERSION: $WS_VERSION"
6172
- uses: actions/checkout@v4
6273
with:
6374
repository: adafruit/ci-arduino
@@ -272,9 +283,17 @@ jobs:
272283
- uses: actions/checkout@v4
273284
- name: Get WipperSnapper version
274285
run: |
275-
git fetch --prune --unshallow --tags
276-
git describe --dirty --tags
277-
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
286+
git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
287+
git fetch --prune --unshallow --all --tags
288+
if git describe --dirty --tags >/dev/null 2>&1; then
289+
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
290+
else
291+
# Fallback for forks: 1.0.0-{owner}-{short-sha}
292+
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
293+
SHORT_SHA=$(git rev-parse --short HEAD)
294+
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
295+
fi
296+
echo "WS_VERSION: $WS_VERSION"
278297
- uses: actions/checkout@v4
279298
with:
280299
repository: adafruit/ci-arduino
@@ -388,9 +407,17 @@ jobs:
388407
- uses: actions/checkout@v4
389408
- name: Get WipperSnapper version
390409
run: |
391-
git fetch --prune --unshallow --tags
392-
git describe --dirty --tags
393-
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
410+
git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
411+
git fetch --prune --unshallow --all --tags
412+
if git describe --dirty --tags >/dev/null 2>&1; then
413+
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
414+
else
415+
# Fallback for forks: 1.0.0-{owner}-{short-sha}
416+
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
417+
SHORT_SHA=$(git rev-parse --short HEAD)
418+
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
419+
fi
420+
echo "WS_VERSION: $WS_VERSION"
394421
- uses: actions/checkout@v4
395422
with:
396423
repository: adafruit/ci-arduino
@@ -526,9 +553,17 @@ jobs:
526553
- uses: actions/checkout@v4
527554
- name: Get WipperSnapper version
528555
run: |
529-
git fetch --prune --unshallow --tags
530-
git describe --dirty --tags
531-
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
556+
git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
557+
git fetch --prune --unshallow --all --tags
558+
if git describe --dirty --tags >/dev/null 2>&1; then
559+
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
560+
else
561+
# Fallback for forks: 1.0.0-{owner}-{short-sha}
562+
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
563+
SHORT_SHA=$(git rev-parse --short HEAD)
564+
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
565+
fi
566+
echo "WS_VERSION: $WS_VERSION"
532567
- uses: actions/checkout@v4
533568
with:
534569
repository: adafruit/ci-arduino
@@ -608,9 +643,17 @@ jobs:
608643
- uses: actions/checkout@v4
609644
- name: Get WipperSnapper version
610645
run: |
611-
git fetch --prune --unshallow --tags
612-
git describe --dirty --tags
613-
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
646+
git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
647+
git fetch --prune --unshallow --all --tags
648+
if git describe --dirty --tags >/dev/null 2>&1; then
649+
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
650+
else
651+
# Fallback for forks: 1.0.0-{owner}-{short-sha}
652+
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
653+
SHORT_SHA=$(git rev-parse --short HEAD)
654+
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
655+
fi
656+
echo "WS_VERSION: $WS_VERSION"
614657
- uses: actions/checkout@v4
615658
with:
616659
repository: adafruit/ci-arduino
@@ -687,9 +730,17 @@ jobs:
687730
- uses: actions/checkout@v4
688731
- name: Get WipperSnapper version
689732
run: |
690-
git fetch --prune --unshallow --tags
691-
git describe --dirty --tags
692-
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
733+
git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
734+
git fetch --prune --unshallow --all --tags
735+
if git describe --dirty --tags >/dev/null 2>&1; then
736+
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
737+
else
738+
# Fallback for forks: 1.0.0-{owner}-{short-sha}
739+
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
740+
SHORT_SHA=$(git rev-parse --short HEAD)
741+
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
742+
fi
743+
echo "WS_VERSION: $WS_VERSION"
693744
- uses: actions/checkout@v4
694745
with:
695746
repository: adafruit/ci-arduino
@@ -784,9 +835,17 @@ jobs:
784835
- uses: actions/checkout@v4
785836
- name: Get WipperSnapper version
786837
run: |
787-
git fetch --prune --unshallow --tags
788-
git describe --dirty --tags
789-
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
838+
git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
839+
git fetch --prune --unshallow --all --tags
840+
if git describe --dirty --tags >/dev/null 2>&1; then
841+
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
842+
else
843+
# Fallback for forks: 1.0.0-{owner}-{short-sha}
844+
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
845+
SHORT_SHA=$(git rev-parse --short HEAD)
846+
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
847+
fi
848+
echo "WS_VERSION: $WS_VERSION"
790849
- uses: actions/checkout@v4
791850
with:
792851
repository: adafruit/ci-arduino
@@ -888,9 +947,17 @@ jobs:
888947
- uses: actions/checkout@v4
889948
- name: Get WipperSnapper version
890949
run: |
891-
git fetch --prune --unshallow --tags
892-
git describe --dirty --tags
893-
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
950+
git remote add adafruit https://github.com/adafruit/Adafruit_Wippersnapper_Arduino.git || true
951+
git fetch --prune --unshallow --all --tags
952+
if git describe --dirty --tags >/dev/null 2>&1; then
953+
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
954+
else
955+
# Fallback for forks: 1.0.0-{owner}-{short-sha}
956+
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
957+
SHORT_SHA=$(git rev-parse --short HEAD)
958+
echo >>$GITHUB_ENV WS_VERSION="1.0.0-${REPO_OWNER}-${SHORT_SHA}"
959+
fi
960+
echo "WS_VERSION: $WS_VERSION"
894961
- uses: actions/checkout@v4
895962
with:
896963
repository: adafruit/ci-arduino

0 commit comments

Comments
 (0)