|
| 1 | +name: 'Open Release PR' |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + release_type: |
| 7 | + description: 'Release type' |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + options: |
| 11 | + - major |
| 12 | + - minor |
| 13 | + - patch |
| 14 | + default: minor |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: write |
| 18 | + pull-requests: write |
| 19 | + |
| 20 | +jobs: |
| 21 | + open-release-pr: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + # Fetch full history so tools that read tags/changelog (if any) work |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: Setup Node.js |
| 32 | + uses: actions/setup-node@v4 |
| 33 | + with: |
| 34 | + node-version: 20 |
| 35 | + |
| 36 | + - name: 💾 Cache dependencies |
| 37 | + id: cache |
| 38 | + uses: actions/cache@v4 |
| 39 | + with: |
| 40 | + path: '**/node_modules' |
| 41 | + key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} |
| 42 | + |
| 43 | + - name: 📦 Install dependencies if cache miss |
| 44 | + if: steps.cache.outputs.cache-hit != 'true' |
| 45 | + run: yarn install --immutable |
| 46 | + |
| 47 | + - name: Run release |
| 48 | + id: release |
| 49 | + run: | |
| 50 | + yarn version ${{ inputs.release_type }} |
| 51 | + VERSION=$(node -p "require('./package.json').version") |
| 52 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 53 | +
|
| 54 | + - name: Run tests on release changes |
| 55 | + run: yarn verify |
| 56 | + |
| 57 | + - name: Create PR with release changes |
| 58 | + id: cpr |
| 59 | + uses: peter-evans/create-pull-request@v7 |
| 60 | + with: |
| 61 | + # branch name is unique per run |
| 62 | + branch: "release/v${{ steps.release.outputs.version }}-${{ github.run_id }}" |
| 63 | + commit-message: "chore(release): v${{ steps.release.outputs.version }}" |
| 64 | + title: "(chore) Release v${{ steps.release.outputs.version }}" |
| 65 | + body: | |
| 66 | + This PR was created automatically via **workflow_dispatch**. |
| 67 | +
|
| 68 | + **Command ran** |
| 69 | + ``` |
| 70 | + yarn version ${{ inputs.release_type }} |
| 71 | + ``` |
| 72 | +
|
| 73 | + Please review the changes (version bumps, changelog, etc.) and merge. :) |
| 74 | + labels: | |
| 75 | + release |
| 76 | + automated-pr |
| 77 | + delete-branch: true |
| 78 | + author: "OpenMRS Bot <infrastructure@openmrs.org>" |
| 79 | + committer: "OpenMRS Bot <infrastructure@openmrs.org>" |
| 80 | + token: ${{ secrets.OMRS_BOT_GH_TOKEN || secrets.GITHUB_TOKEN }} |
0 commit comments