Commit 008d8cfb authored by Martin Atkins's avatar Martin Atkins
Browse files

build: Fetch all tags before deciding which version we're building

The actions/checkout workflow does some heroics to try to fetch exactly
the commit being built and nothing else, even if asked to fetch the
history leading up to that commit. That means we don't end up having
enough information to get an accurate answer from "git describe".

Since we're intentionally relying on the git history here, we'll fetch
all of the tags explicitly after initial checkout. Although that does add
some delay to this step, we're intentionally doing this version
calculation only once as a separate workflow job so that all of the other
jobs can still benefit from this action's quicker checkout behavior.
parent 2a85de20
Showing with 9 additions and 4 deletions
+9 -4
...@@ -44,13 +44,17 @@ jobs: ...@@ -44,13 +44,17 @@ jobs:
product-version: ${{ steps.get-product-version.outputs.product-version }} product-version: ${{ steps.get-product-version.outputs.product-version }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with:
fetch-depth: 0 # Need all commits and tags to find a reasonable version number
- name: Git Describe - name: Git Describe
id: git-describe id: git-describe
run: | run: |
git describe --first-parent # The actions/checkout action tries hard to fetch as little as
# possible, to the extent that even with "depth: 0" it fails to
# produce enough tag metadata for us to "describe" successfully.
# We'll therefore re-fetch the tags here to make sure we will
# select the most accurate version number.
git fetch origin --force --tags
git tag
echo "::set-output name=raw-version::$(git describe --first-parent)" echo "::set-output name=raw-version::$(git describe --first-parent)"
- name: Decide version number - name: Decide version number
id: get-product-version id: get-product-version
...@@ -58,6 +62,7 @@ jobs: ...@@ -58,6 +62,7 @@ jobs:
env: env:
RAW_VERSION: ${{ steps.git-describe.outputs.raw-version }} RAW_VERSION: ${{ steps.git-describe.outputs.raw-version }}
run: | run: |
echo "Version number is ${RAW_VERSION}"
echo "::set-output name=product-version::${RAW_VERSION#v}" echo "::set-output name=product-version::${RAW_VERSION#v}"
- name: Report chosen version number - name: Report chosen version number
run: | run: |
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment