Use GitHub API to fetch latest release/version (#1870)

* Use GitHub API to fetch latest release/version

* Make it easier to copy and paste into other repos

* add some auth

* used auth version everywhere
This commit is contained in:
Mike Henry
2026-03-10 14:52:07 -07:00
committed by GitHub
parent 031e13ccd1
commit d69baa614b
4 changed files with 12 additions and 18 deletions

View File

@@ -40,9 +40,9 @@ jobs:
id: latest-version
working-directory: openfe_repo
run: |
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
# slice off the v, ie v0.7.2 -> 0.7.2
VERSION=${LATEST_TAG:1}
REPO="${{ github.repository }}"
VERSION=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/$REPO/releases/latest" | jq -r '.tag_name | ltrimstr("v")')
echo $VERSION
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT

View File

@@ -78,11 +78,9 @@ jobs:
- name: Get Latest Version
id: latest-version
run: |
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
echo $LATEST_TAG
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_OUTPUT
# slice off the v, ie v0.7.2 -> 0.7.2
VERSION=${LATEST_TAG:1}
REPO="${{ github.repository }}"
VERSION=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/$REPO/releases/latest" | jq -r '.tag_name | ltrimstr("v")')
echo $VERSION
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT

View File

@@ -22,14 +22,10 @@ jobs:
# This saves me some time since we only need the latest tag
- name: Get latest tag
id: latest-version
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
LATEST_TAG=$(curl -s -H "Authorization: token $GH_TOKEN" \
https://api.github.com/repos/$REPO/tags \
| jq -r '.[0].name')
VERSION=${LATEST_TAG:1}
REPO="${{ github.repository }}"
VERSION=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/$REPO/releases/latest" | jq -r '.tag_name | ltrimstr("v")')
echo $VERSION
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT

View File

@@ -25,9 +25,9 @@ jobs:
- name: Get Latest Version
id: latest-version
run: |
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
# slice off the v, ie v0.7.2 -> 0.7.2
VERSION=${LATEST_TAG:1}
REPO="${{ github.repository }}"
VERSION=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/$REPO/releases/latest" | jq -r '.tag_name | ltrimstr("v")')
echo $VERSION
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT