From 0cfe5562639153a82e7b59a46e437c37cccd72b8 Mon Sep 17 00:00:00 2001 From: Thomas Finnie Date: Tue, 6 Aug 2024 08:24:20 +0100 Subject: [PATCH] Fix obtaining the repo from git when tagged Fetch git tags manually. Becasue of actions/checkout#1467 --- .github/workflows/book.yml | 14 ++++++++++++- .github/workflows/distribute_package.yml | 26 ++++++++++++++++++++++-- .github/workflows/test_package.yml | 12 +++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml index 2440f8c..d1b4b92 100644 --- a/.github/workflows/book.yml +++ b/.github/workflows/book.yml @@ -14,7 +14,19 @@ jobs: build-book: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + # Fetch tag manually because fetch-tags option for checkout@v4 does not work + - name: Fetch tag annotations + run: | + # Fetch tag manually because fetch-tags option for checkout@v4 does not work + git fetch --force --tags --depth 1 + - id: read_tag + name: Set VERSION env variable + if: ${{ startsWith(github.ref, 'refs/tags') }} + run: | + # Set tag from GitHub: using git describe for tags inside the run script + # seems not working + echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - uses: actions/cache@v3 with: diff --git a/.github/workflows/distribute_package.yml b/.github/workflows/distribute_package.yml index 7473704..f2d0756 100644 --- a/.github/workflows/distribute_package.yml +++ b/.github/workflows/distribute_package.yml @@ -61,7 +61,18 @@ jobs: with: # We need quite a deep fetch so that we get the versioning right fetch-depth: 500 - fetch-tags: true + # Fetch tag manually because fetch-tags option for checkout@v4 does not work + - name: Fetch tag annotations + run: | + # Fetch tag manually because fetch-tags option for checkout@v4 does not work + git fetch --force --tags --depth 1 + - id: read_tag + name: Set VERSION env variable + if: ${{ startsWith(github.ref, 'refs/tags') }} + run: | + # Set tag from GitHub: using git describe for tags inside the run script + # seems not working + echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Install dependencies run: | @@ -109,7 +120,18 @@ jobs: with: # We need quite a deep fetch so that we get the versioning right fetch-depth: 500 - fetch-tags: true + # Fetch tag manually because fetch-tags option for checkout@v4 does not work + - name: Fetch tag annotations + run: | + # Fetch tag manually because fetch-tags option for checkout@v4 does not work + git fetch --force --tags --depth 1 + - id: read_tag + name: Set VERSION env variable + if: ${{ startsWith(github.ref, 'refs/tags') }} + run: | + # Set tag from GitHub: using git describe for tags inside the run script + # seems not working + echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV # setuptools_scm workaround for https://github.com/pypa/setuptools_scm/issues/455 - name: Disable local version identifier on develop CI diff --git a/.github/workflows/test_package.yml b/.github/workflows/test_package.yml index 500f891..317d723 100644 --- a/.github/workflows/test_package.yml +++ b/.github/workflows/test_package.yml @@ -23,6 +23,18 @@ jobs: steps: - uses: actions/checkout@v4 + # Fetch tag manually because fetch-tags option for checkout@v4 does not work + - name: Fetch tag annotations + run: | + # Fetch tag manually because fetch-tags option for checkout@v4 does not work + git fetch --force --tags --depth 1 + - id: read_tag + name: Set VERSION env variable + if: ${{ startsWith(github.ref, 'refs/tags') }} + run: | + # Set tag from GitHub: using git describe for tags inside the run script + # seems not working + echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - uses: actions/cache@v4 if: startsWith(runner.os, 'Linux')