Skip to content

Commit

Permalink
chore: use 'feat' for minor version provider upgrades
Browse files Browse the repository at this point in the history
Use 'fix' for patch version provider upgrades, for proper semantic
versioning and consistency.
  • Loading branch information
xiehan committed Nov 30, 2023
1 parent f074096 commit 06715ca
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 10 deletions.
25 changes: 21 additions & 4 deletions src/provider-upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class ProviderUpgrade {
"${{ steps.check_version.outputs.new_version == 'available' }}";
const currentVersion = "${{ steps.current_version.outputs.value }}";
const newVersion = "${{ steps.new_version.outputs.value }}";
const semanticType = "${{ steps.release.outputs.type }}";

workflow.addJobs({
upgrade: {
Expand All @@ -46,7 +47,7 @@ export class ProviderUpgrade {
steps: [
{
name: "Checkout",
uses: "actions/checkout@v2",
uses: "actions/checkout@v4",
},
{ run: "yarn install" },
{
Expand All @@ -73,19 +74,35 @@ export class ProviderUpgrade {
id: "new_version",
run: `echo "value=$(jq -r '. | to_entries[] | .value' src/version.json)" >> $GITHUB_OUTPUT`,
},
{
name: "Determine if this is a minor or patch release",
if: newerVersionAvailable,
id: "release",
env: {
CURRENT_VERSION: currentVersion,
NEW_VERSION: newVersion,
},
run: [
`CURRENT_VERSION_MINOR=$(cut -d "." -f 1 <<< "$CURRENT_VERSION")`,
`NEW_VERSION_MINOR=$(cut -d "." -f 1 <<< "$NEW_VERSION")`,
`[[ "$CURRENT_VERSION_MINOR" != "$NEW_VERSION_MINOR" ]] && IS_MINOR_RELEASE=true || IS_MINOR_RELEASE=false`,
`[[ "$IS_MINOR_RELEASE" == "true" ]] && SEMANTIC_TYPE=feat || SEMANTIC_TYPE=fix`,
`echo "is_minor=$IS_MINOR_RELEASE" >> $GITHUB_OUTPUT`,
`echo "type=$SEMANTIC_TYPE" >> $GITHUB_OUTPUT`,
].join("\n"),
},
// generate docs
{ run: "yarn compile", if: newerVersionAvailable },
{ run: "yarn docgen", if: newerVersionAvailable },

// submit a PR
{
name: "Create Pull Request",
if: newerVersionAvailable,
uses: "peter-evans/create-pull-request@v3",
with: {
"commit-message": `fix: upgrade provider from \`${currentVersion}\` to version \`${newVersion}\``,
branch: "auto/provider-upgrade",
title: `fix: upgrade provider from \`${currentVersion}\` to version \`${newVersion}\``,
"commit-message": `${semanticType}: upgrade provider from \`${currentVersion}\` to version \`${newVersion}\``,
title: `${semanticType}: upgrade provider from \`${currentVersion}\` to version \`${newVersion}\``,
body: `This PR upgrades the underlying Terraform provider to version ${newVersion}`,
labels: "automerge",
token: "${{ secrets.GH_TOKEN }}",
Expand Down
51 changes: 45 additions & 6 deletions test/__snapshots__/index.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 06715ca

Please sign in to comment.