Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/auto-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Auto Version Packages
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generated by AI


on:
workflow_dispatch:
inputs:
version_type:
description: 'Version type (patch, minor, major)'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major

permissions:
contents: write # Required to create tags and push them

jobs:
auto-version:
name: "Auto Version Changed Packages"
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout code
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
fetch-depth: 0 # Fetch all history for tags
token: ${{ secrets.GITHUB_TOKEN }}
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the default GITHUB_TOKEN may not have sufficient permissions to push tags to protected branches or bypass branch protection rules. Consider using a personal access token or GitHub App token with appropriate permissions if the repository has branch protection enabled.

Suggested change
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point, what are our branch protection rules for this repo? likely will fail due to requiring a PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also dunno 🤣
Maybe @lei-wego has some idea? But I see from our other(like payments web component) github workflow we only use GITHUB_TOKEN

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

payments web component actually used to use something called deploy keys, with a custom branch rule to allow deploy keys to bypass.

I've since made changes to the payments web component workflow files but haven't had a chance to test the new flow yet.


- name: Configure git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Run auto_version script
run: |
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow assumes the auto_version script exists and is executable, but there's no error handling if the script doesn't exist or fails. Consider adding error checking or using set -e to ensure the workflow fails appropriately if the script encounters issues.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

@aaron-wego aaron-wego Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think should be okay since the file is also committed in the repo so it will always be present? 🤔

chmod +x ./auto_version

# Determine version type from input or default to patch for automatic triggers
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
version_type="${{ github.event.inputs.version_type }}"
else
version_type="patch"
fi

echo "Using version type: $version_type"

# Pass the appropriate flag to auto_version script
case "$version_type" in
"major")
./auto_version --major
;;
"minor")
./auto_version --minor
;;
"patch")
./auto_version --patch
;;
*)
echo "Invalid version type: $version_type"
exit 1
;;
esac

- name: Verify tags were created
run: |
echo "Latest tags created:"
git tag --sort=-version:refname | head -10