Release New Version #40
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: Release New Version | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_type: | |
| description: 'Version bump type' | |
| required: true | |
| default: 'patch' | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| concurrency: | |
| group: repo-commits | |
| cancel-in-progress: false | |
| env: | |
| DO_NOT_TRACK: 1 | |
| TURBO_TELEMETRY_DISABLED: 1 | |
| jobs: | |
| bump: | |
| name: Bump versions | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| new_version: ${{ steps.bump.outputs.new_version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: pnpm | |
| - name: Configure Git | |
| run: | | |
| git config user.name "Frank Chiarulli Jr." | |
| git config user.email "frank@frankchiarulli.com" | |
| - name: Bump versions | |
| id: bump | |
| run: | | |
| bump_version() { | |
| local dir=$1 | |
| local version=$2 | |
| node -e " | |
| const fs = require('fs'); | |
| const pkg = JSON.parse(fs.readFileSync('$dir/package.json', 'utf8')); | |
| pkg.version = '$version'; | |
| fs.writeFileSync('$dir/package.json', JSON.stringify(pkg, null, 2) + '\n'); | |
| " | |
| } | |
| # Get current version and compute new version | |
| OLD_VERSION=$(node -e "console.log(require('./packages/vite-plugin/package.json').version)") | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$OLD_VERSION" | |
| case "${{ inputs.version_type }}" in | |
| major) NEW_VERSION="$((MAJOR + 1)).0.0" ;; | |
| minor) NEW_VERSION="${MAJOR}.$((MINOR + 1)).0" ;; | |
| patch) NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))" ;; | |
| esac | |
| # Bump all packages | |
| bump_version packages/shiftapi "$NEW_VERSION" | |
| bump_version packages/vite-plugin "$NEW_VERSION" | |
| bump_version packages/next "$NEW_VERSION" | |
| bump_version packages/create-shiftapi "$NEW_VERSION" | |
| echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| - name: Install to update lockfile | |
| run: pnpm install | |
| - name: Commit and tag | |
| run: | | |
| git add packages/shiftapi/package.json packages/vite-plugin/package.json packages/next/package.json packages/create-shiftapi/package.json pnpm-lock.yaml | |
| git commit -m "chore: bump package versions to ${{ steps.bump.outputs.new_version }}" | |
| git tag "v${{ steps.bump.outputs.new_version }}" | |
| git push --no-verify | |
| git push --no-verify origin "v${{ steps.bump.outputs.new_version }}" | |
| publish-core: | |
| name: Publish shiftapi | |
| needs: bump | |
| runs-on: ubuntu-latest | |
| environment: npm | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: v${{ needs.bump.outputs.new_version }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: pnpm | |
| registry-url: https://registry.npmjs.org | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Install Dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build | |
| run: pnpm --filter shiftapi build | |
| - name: Test | |
| run: pnpm --filter shiftapi test | |
| - name: Publish | |
| working-directory: packages/shiftapi | |
| run: | | |
| pnpm pack | |
| tarball=$(ls *.tgz) | |
| npm publish "$tarball" --provenance --access public | |
| publish: | |
| name: Publish ${{ matrix.package }} | |
| needs: [bump, publish-core] | |
| runs-on: ubuntu-latest | |
| environment: npm | |
| permissions: | |
| contents: read | |
| id-token: write | |
| strategy: | |
| matrix: | |
| include: | |
| - package: "@shiftapi/vite-plugin" | |
| directory: packages/vite-plugin | |
| has_tests: false | |
| - package: "@shiftapi/next" | |
| directory: packages/next | |
| has_tests: false | |
| - package: create-shiftapi | |
| directory: packages/create-shiftapi | |
| has_tests: true | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: v${{ needs.bump.outputs.new_version }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: pnpm | |
| registry-url: https://registry.npmjs.org | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Install Dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build | |
| run: pnpm --filter ${{ matrix.package }}... build | |
| - name: Test | |
| if: matrix.has_tests | |
| run: pnpm --filter ${{ matrix.package }} test | |
| - name: Publish | |
| working-directory: ${{ matrix.directory }} | |
| run: | | |
| pnpm pack | |
| tarball=$(ls *.tgz) | |
| npm publish "$tarball" --provenance --access public |