Skip to content

Commit

Permalink
automation: splitting the determining and publishing of the Git Tag
Browse files Browse the repository at this point in the history
This is needed as a part of hashicorp/pandora#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 hashicorp/terraform-provider-azurerm#24602)
  • Loading branch information
tombuildsstuff committed Jan 23, 2024
1 parent 09759c4 commit aaa0602
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/automation-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 23 additions & 0 deletions scripts/publish-git-tag.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit aaa0602

Please sign in to comment.