Motion Presets - Bump Version and Publish #6
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: Motion Presets - Bump Version and Publish | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_strategy: | |
| type: choice | |
| description: Version strategy | |
| options: | |
| - prerelease | |
| - premajor | |
| - preminor | |
| - prepatch | |
| - major | |
| - minor | |
| - patch | |
| dry_run: | |
| description: 'Dry run (preview only)' | |
| required: false | |
| default: false | |
| type: boolean | |
| permissions: | |
| id-token: write # REQUIRED for npm Trusted Publishing | |
| contents: write | |
| pull-requests: write | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 0 # full history for yarn version | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create and checkout release branch | |
| if: ${{ github.event.inputs.dry_run == 'false' }} | |
| run: | | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git config user.name "github-actions[bot]" | |
| git checkout -b release | |
| git push -u origin release | |
| - name: Setup Node with trusted publishing | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org | |
| - name: Set up Yarn | |
| run: | | |
| corepack enable | |
| corepack prepare yarn@4.10.3 --activate | |
| yarn set version 4.10.3 | |
| - name: Install dependencies | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: NPQ_PKG_MGR=yarn npx npq install | |
| - name: Build motion-presets package | |
| run: | | |
| yarn workspace @wix/motion build | |
| yarn workspace @wix/motion-presets build | |
| - name: Test motion-presets package | |
| run: yarn workspace @wix/motion-presets test | |
| # ---- BUMP VERSION ---- | |
| - name: Bump version | |
| if: ${{ github.event.inputs.dry_run == 'false' }} | |
| working-directory: packages/motion-presets | |
| run: yarn version ${{ github.event.inputs.version_strategy }} | |
| - name: Get new version | |
| if: ${{ github.event.inputs.dry_run == 'false' }} | |
| id: get_version | |
| working-directory: packages/motion-presets | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Commit and push version bump | |
| if: ${{ github.event.inputs.dry_run == 'false' }} | |
| run: | | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git config user.name "github-actions[bot]" | |
| git add . | |
| git commit -m "chore: bump @wix/motion-presets to ${{ steps.get_version.outputs.version }}" | |
| git tag "motion-presets@${{ steps.get_version.outputs.version }}" | |
| git push --follow-tags origin release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # ---- CREATE PULL REQUEST ---- | |
| - name: Create Pull Request | |
| if: ${{ github.event.inputs.dry_run == 'false' }} | |
| id: create_pr | |
| uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const { data: pr } = await github.rest.pulls.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title: `chore: bump @wix/motion-presets to ${{ steps.get_version.outputs.version }}`, | |
| head: 'release', | |
| base: 'master', | |
| body: 'Automated version bump and release PR', | |
| maintainer_can_modify: true | |
| }); | |
| return pr.number; | |
| # ---- PUBLISH WITH TRUSTED PUBLISHING ---- | |
| - name: npm publish @wix/motion-presets RC (trusted) | |
| if: ${{ github.event.inputs.dry_run == 'false' && (github.event.inputs.version_strategy == 'prerelease' || github.event.inputs.version_strategy == 'premajor' || github.event.inputs.version_strategy == 'preminor' || github.event.inputs.version_strategy == 'prepatch') }} | |
| run: | | |
| cd packages/motion-presets | |
| npm publish --tag next --provenance --access=public | |
| - name: npm publish @wix/motion-presets Stable (trusted) | |
| if: ${{ github.event.inputs.dry_run == 'false' && (github.event.inputs.version_strategy == 'major' || github.event.inputs.version_strategy == 'minor' || github.event.inputs.version_strategy == 'patch') }} | |
| run: | | |
| cd packages/motion-presets | |
| npm publish --tag latest --provenance --access=public |