build(deps): bump express from 5.1.0 to 5.2.1 #14
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: Template Version Management | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - 'tsconfig.json' | ||
| - 'biome.json' | ||
| - 'vitest.config.ts' | ||
| - '.editorconfig' | ||
| - '.gitignore' | ||
| - '.yarnrc.yml' | ||
| - 'package.json' | ||
| - '.github/workflows/**' | ||
| - '.husky/**' | ||
| - 'commitlint.config.js' | ||
| - 'src/tools/example*' | ||
| - 'src/utils/validation*' | ||
| - '.github/template-sync-config.yml' | ||
| workflow_dispatch: | ||
| inputs: | ||
| version_type: | ||
| description: 'Version bump type' | ||
| required: true | ||
| default: 'patch' | ||
| type: choice | ||
| options: | ||
| - patch | ||
| - minor | ||
| - major | ||
| change_description: | ||
| description: 'Description of changes' | ||
| required: true | ||
| breaking_changes: | ||
| description: 'Breaking changes (if any)' | ||
| required: false | ||
| migration_notes: | ||
| description: 'Migration notes (if any)' | ||
| required: false | ||
| jobs: | ||
| update-version: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| new_version: ${{ steps.version.outputs.new_version }} | ||
| version_changed: ${{ steps.version.outputs.version_changed }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '18' | ||
| - name: Install semver | ||
| run: npm install semver | ||
| - name: Update template version | ||
| id: version | ||
| env: | ||
| VERSION_TYPE: ${{ github.event.inputs.version_type || 'patch' }} | ||
| CHANGE_DESCRIPTION: ${{ github.event.inputs.change_description || 'Template updates' }} | ||
| BREAKING_CHANGES: ${{ github.event.inputs.breaking_changes || '' }} | ||
| MIGRATION_NOTES: ${{ github.event.inputs.migration_notes || '' }} | ||
| run: | | ||
| cat > update-version.js << 'EOF' | ||
| const fs = require('fs'); | ||
| const semver = require('semver'); | ||
| // Read current version | ||
| const versionFile = '.template-version'; | ||
| let versionData = { version: '1.0.0', changes: [] }; | ||
| if (fs.existsSync(versionFile)) { | ||
| versionData = JSON.parse(fs.readFileSync(versionFile, 'utf8')); | ||
| } | ||
| // Calculate new version | ||
| const currentVersion = versionData.version; | ||
| const versionType = process.env.VERSION_TYPE; | ||
| const newVersion = semver.inc(currentVersion, versionType); | ||
| // Update version data | ||
| const updatedData = { | ||
| version: newVersion, | ||
| last_updated: new Date().toISOString(), | ||
| changes: [process.env.CHANGE_DESCRIPTION], | ||
| breaking_changes: process.env.BREAKING_CHANGES ? [process.env.BREAKING_CHANGES] : [], | ||
| migration_notes: process.env.MIGRATION_NOTES ? [process.env.MIGRATION_NOTES] : [], | ||
| previous_versions: [ | ||
| ...(versionData.previous_versions || []), | ||
| { | ||
| version: currentVersion, | ||
| date: versionData.last_updated, | ||
| changes: versionData.changes | ||
| } | ||
| ].slice(-5) // Keep last 5 versions | ||
| }; | ||
| // Write updated version | ||
| fs.writeFileSync(versionFile, JSON.stringify(updatedData, null, 2)); | ||
| // Update template sync config | ||
| const syncConfig = fs.readFileSync('.github/template-sync-config.yml', 'utf8'); | ||
| const updatedSyncConfig = syncConfig.replace( | ||
| /template_version: "[^"]*"/, | ||
| `template_version: "${newVersion}"` | ||
| ); | ||
| fs.writeFileSync('.github/template-sync-config.yml', updatedSyncConfig); | ||
| // Update template marker | ||
| const markerContent = fs.readFileSync('.template-marker', 'utf8'); | ||
| const updatedMarker = markerContent.replace( | ||
| /template_version: [^\n]*/, | ||
| `template_version: ${newVersion}` | ||
| ); | ||
| fs.writeFileSync('.template-marker', updatedMarker); | ||
| console.log(`Version updated: ${currentVersion} → ${newVersion}`); | ||
| console.log(`new_version=${newVersion}`); | ||
| console.log(`version_changed=${currentVersion !== newVersion}`); | ||
| EOF | ||
| node update-version.js | ||
| NEW_VERSION=$(node -e "console.log(JSON.parse(require('fs').readFileSync('.template-version')).version)") | ||
| echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | ||
| echo "version_changed=true" >> $GITHUB_OUTPUT | ||
| - name: Commit version update | ||
| if: steps.version.outputs.version_changed == 'true' | ||
| run: | | ||
| git config user.name "Template Version Bot" | ||
| git config user.email "[email protected]" | ||
| git add .template-version .github/template-sync-config.yml .template-marker | ||
| git commit -m "chore: bump template version to ${{ steps.version.outputs.new_version }} | ||
| ${{ github.event.inputs.change_description || 'Automated version bump' }}" | ||
| git push | ||
| - name: Create version tag | ||
| if: steps.version.outputs.version_changed == 'true' | ||
| run: | | ||
| git tag -a "template-v${{ steps.version.outputs.new_version }}" -m "Template version ${{ steps.version.outputs.new_version }}" | ||
| git push origin "template-v${{ steps.version.outputs.new_version }}" | ||
| trigger-sync: | ||
| needs: update-version | ||
| if: needs.update-version.outputs.version_changed == 'true' | ||
| uses: ./.github/workflows/template-sync-dispatch.yml | ||
| with: | ||
| target_repos: 'all' | ||
| dry_run: false | ||
| secrets: inherit | ||