From aaa06026307f8dc28db0f2609cbbc09f41825202 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Tue, 23 Jan 2024 12:49:13 +0100 Subject: [PATCH] automation: splitting the determining and publishing of the Git Tag This is needed as a part of https://github.com/hashicorp/pandora/issues/3601 since we're going to be publishing multiple Go Modules at different paths - but the version number of each of them is going to be the same. As such this PR splits the determining and publishing of the Git Tag - such that the existing update tooling continues to work with minor changes (tracked in https://github.com/hashicorp/terraform-provider-azurerm/pull/24602) --- .github/workflows/automation-release.yaml | 15 ++++++++---- ...ublish-git-tag.sh => determine-git-tag.sh} | 14 +---------- scripts/publish-git-tag.sh | 23 +++++++++++++++++++ 3 files changed, 34 insertions(+), 18 deletions(-) rename scripts/{determine-and-publish-git-tag.sh => determine-git-tag.sh} (81%) create mode 100755 scripts/publish-git-tag.sh diff --git a/.github/workflows/automation-release.yaml b/.github/workflows/automation-release.yaml index 487ebebc1dc..8078c0f4477 100644 --- a/.github/workflows/automation-release.yaml +++ b/.github/workflows/automation-release.yaml @@ -14,7 +14,7 @@ jobs: permissions: contents: write outputs: - latest_tag: ${{ steps.results.outputs.latest_tag }} + latest_tag: ${{ steps.results.version-number.latest_tag }} should_update_azurerm: ${{ steps.results.outputs.should_update_azurerm }} steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 @@ -24,15 +24,20 @@ jobs: make tools make test - - name: "determine and publish the Git Tag" + - id: version-number + name: "Determining the Version Number.." + latestTag=$(./scripts/determine-git-tag.sh) + echo "latest_tag=$latestTag" >> "$GITHUB_OUTPUT" + shell: bash + + - name: "Publish the Git Tag" run: | - ./scripts/determine-and-publish-git-tag.sh + ./scripts/publish-git-tag.sh ${{ steps.results.version-number.latest_tag }} + shell: bash - id: results name: "collecting outputs" run: | - latestTag=$(git describe --tags $(git rev-list --tags --max-count=1)) - echo "latest_tag=$latestTag" >> "$GITHUB_OUTPUT" echo "should_update_azurerm=${{ github.event.pull_request.merged == true && contains( github.event.pull_request.labels.*.name, 'update-azurerm-after-release') }}" >> "$GITHUB_OUTPUT" shell: bash diff --git a/scripts/determine-and-publish-git-tag.sh b/scripts/determine-git-tag.sh similarity index 81% rename from scripts/determine-and-publish-git-tag.sh rename to scripts/determine-git-tag.sh index 4d7db54a961..51cd054a2cb 100755 --- a/scripts/determine-and-publish-git-tag.sh +++ b/scripts/determine-git-tag.sh @@ -23,20 +23,8 @@ function determineGitTag { date '+v0.%Y%m%d.1%H%M%S' } -function publish { - local version=$1 - - echo "Tagging as '$version'.." - git tag "$version" - - echo "Pushing Tags.." - git push --tags -} - function main { - local gitTag - gitTag=$(determineGitTag) - publish "$gitTag" + determineGitTag } main diff --git a/scripts/publish-git-tag.sh b/scripts/publish-git-tag.sh new file mode 100755 index 00000000000..6f2a1be3b90 --- /dev/null +++ b/scripts/publish-git-tag.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +set -e + +function publish { + local version=$1 + + echo "Tagging as '$version'.." + git tag "$version" + + echo "Pushing Tags.." + git push --tags +} + +function main { + local version=$1 + + publish "$version" +} + +main "$1"