|
| 1 | +name: Interact Validate - Bump Version and Publish |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + source_branch: |
| 7 | + description: 'Source branch for deploy preview (leave empty for regular release from master)' |
| 8 | + required: false |
| 9 | + default: '' |
| 10 | + type: string |
| 11 | + version_strategy: |
| 12 | + type: choice |
| 13 | + description: Version strategy |
| 14 | + options: |
| 15 | + - prerelease |
| 16 | + - premajor |
| 17 | + - preminor |
| 18 | + - prepatch |
| 19 | + - major |
| 20 | + - minor |
| 21 | + - patch |
| 22 | + dry_run: |
| 23 | + description: 'Dry run (preview only)' |
| 24 | + required: false |
| 25 | + default: false |
| 26 | + type: boolean |
| 27 | + |
| 28 | +permissions: |
| 29 | + id-token: write # REQUIRED for npm Trusted Publishing |
| 30 | + contents: write |
| 31 | + pull-requests: write |
| 32 | + |
| 33 | +env: |
| 34 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 35 | + |
| 36 | +jobs: |
| 37 | + publish: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Checkout repository |
| 42 | + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 43 | + with: |
| 44 | + fetch-depth: 0 # full history for yarn version |
| 45 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + ref: ${{ github.event.inputs.source_branch || github.ref }} |
| 47 | + |
| 48 | + - name: Create and checkout release branch |
| 49 | + if: ${{ github.event.inputs.dry_run == 'false' }} |
| 50 | + id: release_branch |
| 51 | + run: | |
| 52 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 53 | + git config user.name "github-actions[bot]" |
| 54 | + if [ -n "${{ github.event.inputs.source_branch }}" ]; then |
| 55 | + BRANCH_NAME="release-dp" |
| 56 | + else |
| 57 | + BRANCH_NAME="release" |
| 58 | + fi |
| 59 | + echo "name=$BRANCH_NAME" >> $GITHUB_OUTPUT |
| 60 | + git checkout -b "$BRANCH_NAME" |
| 61 | + git push -u origin "$BRANCH_NAME" |
| 62 | +
|
| 63 | + - name: Setup Node with trusted publishing |
| 64 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 65 | + with: |
| 66 | + node-version: 24 |
| 67 | + registry-url: https://registry.npmjs.org |
| 68 | + |
| 69 | + - name: Set up Yarn |
| 70 | + run: | |
| 71 | + corepack enable |
| 72 | + corepack prepare yarn@4.10.3 --activate |
| 73 | + yarn set version 4.10.3 |
| 74 | +
|
| 75 | + - name: Install dependencies |
| 76 | + env: |
| 77 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + run: NPQ_PKG_MGR=yarn npx npq install |
| 79 | + |
| 80 | + - name: Build motion package |
| 81 | + run: yarn workspace @wix/motion build |
| 82 | + |
| 83 | + - name: Build interact package |
| 84 | + run: yarn workspace @wix/interact build |
| 85 | + |
| 86 | + - name: Build interact-validate package |
| 87 | + run: yarn workspace @wix/interact-validate build |
| 88 | + |
| 89 | + - name: Test interact-validate package |
| 90 | + run: yarn workspace @wix/interact-validate test |
| 91 | + |
| 92 | + # ---- UPDATE INTERACT DEPENDENCY FOR DEPLOY PREVIEW ---- |
| 93 | + |
| 94 | + - name: Update @wix/interact dependency to deploy preview version |
| 95 | + if: ${{ github.event.inputs.source_branch != '' }} |
| 96 | + working-directory: packages/interact-validate |
| 97 | + run: | |
| 98 | + INTERACT_DP_VERSION=$(npm view @wix/interact@dp version) |
| 99 | + echo "Using @wix/interact deploy preview version: $INTERACT_DP_VERSION" |
| 100 | + node -e " |
| 101 | + const fs = require('fs'); |
| 102 | + const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); |
| 103 | + pkg.devDependencies['@wix/interact'] = '${INTERACT_DP_VERSION}'; |
| 104 | + fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); |
| 105 | + " |
| 106 | +
|
| 107 | + # ---- BUMP VERSION ---- |
| 108 | + |
| 109 | + - name: Set deploy preview version |
| 110 | + if: ${{ github.event.inputs.dry_run == 'false' && github.event.inputs.source_branch != '' }} |
| 111 | + working-directory: packages/interact-validate |
| 112 | + run: | |
| 113 | + CURRENT_VERSION=$(node -p "require('./package.json').version") |
| 114 | + BASE_VERSION=$(echo "$CURRENT_VERSION" | sed 's/-.*//') |
| 115 | + TIMESTAMP=$(date +%Y%m%d%H%M%S) |
| 116 | + DP_VERSION="${BASE_VERSION}-dp.${TIMESTAMP}" |
| 117 | + yarn version "$DP_VERSION" |
| 118 | +
|
| 119 | + - name: Bump version |
| 120 | + if: ${{ github.event.inputs.dry_run == 'false' && github.event.inputs.source_branch == '' }} |
| 121 | + working-directory: packages/interact-validate |
| 122 | + run: yarn version ${{ github.event.inputs.version_strategy }} |
| 123 | + |
| 124 | + - name: Get new version |
| 125 | + if: ${{ github.event.inputs.dry_run == 'false' }} |
| 126 | + id: get_version |
| 127 | + working-directory: packages/interact-validate |
| 128 | + run: | |
| 129 | + VERSION=$(node -p "require('./package.json').version") |
| 130 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 131 | +
|
| 132 | + - name: Commit and push version bump |
| 133 | + if: ${{ github.event.inputs.dry_run == 'false' }} |
| 134 | + run: | |
| 135 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 136 | + git config user.name "github-actions[bot]" |
| 137 | + git add . |
| 138 | + git commit -m "chore: bump @wix/interact-validate to ${{ steps.get_version.outputs.version }}" |
| 139 | + TAG="interact-validate@${{ steps.get_version.outputs.version }}" |
| 140 | + git tag -a "$TAG" -m "chore: release @wix/interact-validate ${{ steps.get_version.outputs.version }}" |
| 141 | + git push origin ${{ steps.release_branch.outputs.name }} |
| 142 | + git push origin "$TAG" |
| 143 | + env: |
| 144 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 145 | + |
| 146 | + # ---- CREATE PULL REQUEST ---- |
| 147 | + |
| 148 | + - name: Create Pull Request |
| 149 | + if: ${{ github.event.inputs.dry_run == 'false' }} |
| 150 | + id: create_pr |
| 151 | + uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7 |
| 152 | + with: |
| 153 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 154 | + script: | |
| 155 | + const { data: pr } = await github.rest.pulls.create({ |
| 156 | + owner: context.repo.owner, |
| 157 | + repo: context.repo.repo, |
| 158 | + title: `chore: bump @wix/interact-validate to ${{ steps.get_version.outputs.version }}`, |
| 159 | + head: '${{ steps.release_branch.outputs.name }}', |
| 160 | + base: '${{ github.event.inputs.source_branch || 'master' }}', |
| 161 | + body: 'Automated version bump and release PR', |
| 162 | + maintainer_can_modify: true |
| 163 | + }); |
| 164 | +
|
| 165 | + return pr.number; |
| 166 | +
|
| 167 | + # ---- PUBLISH WITH TRUSTED PUBLISHING ---- |
| 168 | + |
| 169 | + - name: npm publish @wix/interact-validate deploy preview (trusted) |
| 170 | + if: ${{ github.event.inputs.dry_run == 'false' && github.event.inputs.source_branch != '' }} |
| 171 | + run: | |
| 172 | + cd packages/interact-validate |
| 173 | + npm publish --tag dp --provenance --access=public |
| 174 | +
|
| 175 | + - name: npm publish @wix/interact-validate RC (trusted) |
| 176 | + if: ${{ github.event.inputs.dry_run == 'false' && github.event.inputs.source_branch == '' && (github.event.inputs.version_strategy == 'prerelease' || github.event.inputs.version_strategy == 'premajor' || github.event.inputs.version_strategy == 'preminor' || github.event.inputs.version_strategy == 'prepatch') }} |
| 177 | + run: | |
| 178 | + cd packages/interact-validate |
| 179 | + npm publish --tag next --provenance --access=public |
| 180 | +
|
| 181 | + - name: npm publish @wix/interact-validate Stable (trusted) |
| 182 | + if: ${{ github.event.inputs.dry_run == 'false' && github.event.inputs.source_branch == '' && (github.event.inputs.version_strategy == 'major' || github.event.inputs.version_strategy == 'minor' || github.event.inputs.version_strategy == 'patch') }} |
| 183 | + run: | |
| 184 | + cd packages/interact-validate |
| 185 | + npm publish --tag latest --provenance --access=public |
0 commit comments