From 3d85ff4182823c2745aca0f3ebfe6cacf0609891 Mon Sep 17 00:00:00 2001 From: Adam Chalkley Date: Thu, 1 Feb 2024 05:39:44 -0600 Subject: [PATCH] Replace choffmeister/git-describe-semver GH action Replace the (currently) problematic GitHub Action used in the scheduled monthly image build workflow with a custom job (`git_describe_semver`) that explicitly uses the v0.3.11 version of the Docker container to generate the release asset release version. That version is captured as the job's `version` output which is referenced by the `build_all_images_using_makefile` job in the scheduled-monthly workflow. That job is set as dependent on the `git_describe_semver` job so that they only run after the asset release version is computed. Since the value is computed once at the start of the workflow, I've updated the `actions/checkout` step for the `build_all_images_using_makefile` job to use the default checkout option(s) instead of pulling the full repo history each time. This should (somewhat) optimize that step in the build process. refs GH-1299 refs GH-1276 --- .github/workflows/scheduled-monthly.yml | 69 +++++++++++++++++++------ 1 file changed, 54 insertions(+), 15 deletions(-) diff --git a/.github/workflows/scheduled-monthly.yml b/.github/workflows/scheduled-monthly.yml index 61dea22c..6a19f488 100644 --- a/.github/workflows/scheduled-monthly.yml +++ b/.github/workflows/scheduled-monthly.yml @@ -20,17 +20,20 @@ on: workflow_dispatch: jobs: - build_all_images_using_makefile: - name: Build all images using Makefile + git_describe_semver: + name: Generate semantic release version using git-describe-semver runs-on: ubuntu-latest # Default: 360 minutes - timeout-minutes: 45 + timeout-minutes: 5 + # https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs + outputs: + version: ${{ steps.git-describe-semver.outputs.version }} steps: - name: Print Docker version run: docker --version - - name: Clone full repo history + - name: Clone repo with full history uses: actions/checkout@v4 with: # Needed in order to retrieve tags for use with semver calculations @@ -47,23 +50,59 @@ jobs: # run: git config --global --add safe.directory "$GITHUB_WORKSPACE" run: git config --global --add safe.directory "${PWD}" + # https://github.com/choffmeister/git-describe-semver/pkgs/container/git-describe-semver + # https://github.com/choffmeister/git-describe-semver/blob/v0.3.11/action.yaml + # https://github.com/choffmeister/git-describe-semver/blob/v0.4.0/action.yaml + # https://github.com/choffmeister/git-describe-semver/issues/8 + - name: Record semantic version using git-describe-semver + uses: docker://ghcr.io/choffmeister/git-describe-semver:0.3.11 + id: git-describe-semver + with: + args: >- + --fallback="v0.0.0" + --drop-prefix=false + --prerelease-prefix="dev" + --prerelease-suffix="" + --prerelease-timestamped="false" + --format="version=" + $GITHUB_OUTPUT + + - name: Print semantic version generated by git-describe-semver + run: | + echo "${{ steps.git-describe-semver.outputs.version }}" + + build_all_images_using_makefile: + name: Build all images using Makefile + needs: git_describe_semver + runs-on: ubuntu-latest + # Default: 360 minutes + timeout-minutes: 45 + + steps: + - name: Print Docker version + run: docker --version + + - name: Clone repo with default settings + uses: actions/checkout@v4 + + # Mark the current working directory as a safe directory in git to + # resolve "dubious ownership" complaints. + # + # https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables + # https://confluence.atlassian.com/bbkb/git-command-returns-fatal-error-about-the-repository-being-owned-by-someone-else-1167744132.html + # https://github.com/actions/runner-images/issues/6775 + # https://github.com/actions/checkout/issues/766 + - name: Mark the current working directory as a safe directory in git + # run: git config --global --add safe.directory "$GITHUB_WORKSPACE" + run: git config --global --add safe.directory "${PWD}" + # bsdmainutils provides "column" which is used by the Makefile - name: Install Ubuntu packages run: sudo apt-get update && sudo apt-get install -y --no-install-recommends make gcc bsdmainutils - - name: Generate semantic version for project - id: use-git-describe-semver - uses: choffmeister/git-describe-semver@v0.3.11 - with: - fallback: v0.0.0 - drop-prefix: false - prerelease-prefix: dev - prerelease-suffix: "" - prerelease-timestamped: false - - name: Build images using project Makefile run: | - export REPO_VERSION=${{ steps.use-git-describe-semver.outputs.version }} + export REPO_VERSION=${{ needs.git_describe_semver.outputs.version }} make build - name: List generated Docker images