chore: version packages #5135
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Hygiene | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, edited] | |
| branches: | |
| - main | |
| jobs: | |
| lint-pr: | |
| name: Lint PR Title and Changesets | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| steps: | |
| - name: Validate PR title format | |
| shell: bash | |
| run: | | |
| if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| echo "Skipping PR title validation on main." | |
| exit 0 | |
| fi | |
| if [[ "${{ github.event.pull_request.title }}" =~ ^(chore|fix|feat|mig)(\([a-zA-Z0-9_-]+\))?!?:\ [a-z] ]]; then | |
| echo "PR title format is valid." | |
| else | |
| echo "PR title must:" | |
| echo '- Start with one of: "chore", "fix", "feat", "mig"' | |
| echo "- ... optionally followed by a scope in parentheses - alphanumeric, dashes, and underscores only" | |
| echo "- ... optionally followed by an exclamation mark (!) to indicate a breaking change" | |
| echo "- ... followed by a colon and a space" | |
| echo "- ... followed by a space" | |
| echo "- ... followed by a short description of the change _starting with a lowercase letter_" | |
| echo | |
| echo 'Example: "feat: added user avatars to the dashboard"' | |
| echo 'Example: "chore(deps): updated dependency xyz to v2"' | |
| echo 'Example: "fix(auth)!: changed password hashing algorithm"' | |
| echo | |
| echo "Got: '${{ github.event.pull_request.title }}'" | |
| exit 1 | |
| fi | |
| - name: Check for significant changes | |
| id: check | |
| run: | | |
| if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| echo "Skipping changesets-lint job on main." | |
| exit 0 | |
| fi | |
| if [[ "${{ github.event.pull_request.title }}" =~ ^(chore|mig)(\([a-zA-Z0-9_-]+\))?: ]]; then | |
| echo "Skipping changesets-lint job for chore/mig PR." | |
| exit 0 | |
| fi | |
| echo "lint=true" >> $GITHUB_OUTPUT | |
| - name: Checkout | |
| if: ${{ steps.check.outputs.lint == 'true' }} | |
| uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v5.0.0 | |
| # Check out both the base and head refs so changeset status can compare | |
| # against the base branch | |
| - name: Checkout base ref | |
| if: ${{ steps.check.outputs.lint == 'true' }} | |
| run: git fetch origin ${{ github.base_ref }} && git checkout ${{ github.base_ref }} | |
| - name: Checkout head ref | |
| if: ${{ steps.check.outputs.lint == 'true' }} | |
| run: git fetch origin ${{ github.head_ref }} && git checkout ${{ github.head_ref }} | |
| - name: Setup Mise | |
| if: ${{ steps.check.outputs.lint == 'true' }} | |
| uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1 | |
| with: | |
| install: true | |
| cache: true | |
| env: false | |
| - name: Prepare GitHub Actions environment | |
| if: ${{ steps.check.outputs.lint == 'true' }} | |
| run: mise run github | |
| - name: Cache PNPM | |
| if: ${{ steps.check.outputs.lint == 'true' }} | |
| uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 | |
| with: | |
| key: ${{ env.GH_CACHE_PNPM_KEY }} | |
| restore-keys: | | |
| ${{ env.GH_CACHE_PNPM_KEY }} | |
| ${{ env.GH_CACHE_PNPM_KEY_PARTIAL }} | |
| path: | | |
| ${{ env.PNPM_STORE_PATH }} | |
| - name: Install dependencies | |
| if: ${{ steps.check.outputs.lint == 'true' }} | |
| run: pnpm install --frozen-lockfile | |
| - name: Lint changesets | |
| if: ${{ steps.check.outputs.lint == 'true' }} | |
| shell: bash | |
| run: | | |
| set -e | |
| mkdir -p scratch | |
| pnpm changeset status --output scratch/changeset-status.json | |
| cat scratch/changeset-status.json | |
| echo "" | |
| echo "" | |
| # Check if changesets array exists and has length > 0 | |
| if ! jq -e '.changesets | length > 0' scratch/changeset-status.json > /dev/null; then | |
| echo "❌ Changeset validation failed!" | |
| echo "" | |
| echo "It looks like you've made significant changes but haven't added a changeset." | |
| echo "Changesets help us track what's changed and generate release notes." | |
| echo "" | |
| echo "To fix this, run one of this command locally:" | |
| echo " pnpm changeset" | |
| echo "" | |
| echo "Then commit the generated .changeset/*.md file with your changes." | |
| exit 1 | |
| fi | |
| echo "✅ Changeset validation passed!" | |
| - name: Prune PNPM store | |
| if: ${{ steps.check.outputs.lint == 'true' }} | |
| run: pnpm store prune |