|
1 | | -name: Create Release PR |
| 1 | +name: Create release PR |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_dispatch: |
5 | 5 | inputs: |
6 | | - release-type: |
7 | | - description: "Release type" |
| 6 | + version: |
8 | 7 | required: true |
9 | 8 | type: choice |
10 | | - options: [latest, next] |
| 9 | + description: Which version should be published? |
| 10 | + options: |
| 11 | + - patch |
| 12 | + - minor |
| 13 | + - major |
| 14 | + - prepatch |
| 15 | + - preminor |
| 16 | + - premajor |
| 17 | + - prerelease |
| 18 | + tag: |
| 19 | + required: true |
| 20 | + type: choice |
| 21 | + description: Which npm tag should this be published to? |
| 22 | + options: |
| 23 | + - latest |
| 24 | + - next |
11 | 25 | preid: |
12 | | - description: "Prerelease identifier" |
13 | 26 | type: choice |
14 | | - options: ["", alpha, beta, rc, next] |
| 27 | + description: Which prerelease identifier should be used? This is only needed when version is "prepatch", "preminor", "premajor", or "prerelease". |
| 28 | + options: |
| 29 | + - "" |
| 30 | + - alpha |
| 31 | + - beta |
| 32 | + - rc |
| 33 | + - next |
15 | 34 |
|
16 | 35 | jobs: |
17 | | - create-release-pr: |
18 | | - name: Create Release PR |
19 | | - if: github.ref == 'refs/heads/main' |
| 36 | + create-release: |
20 | 37 | runs-on: ubuntu-latest |
21 | 38 | steps: |
22 | | - - name: Generate Token |
23 | | - uses: actions/create-github-app-token@v1 |
24 | | - id: app-token |
25 | | - with: |
26 | | - app-id: ${{ secrets.BOT_APP_ID }} |
27 | | - private-key: ${{ secrets.BOT_PRIVATE_KEY }} |
28 | | - |
29 | 39 | - name: Checkout |
30 | 40 | uses: actions/checkout@v4 |
| 41 | + |
| 42 | + - name: Setup Node.js |
| 43 | + uses: actions/setup-node@v4 |
31 | 44 | with: |
32 | | - token: ${{ steps.app-token.outputs.token }} |
33 | | - fetch-depth: 0 |
| 45 | + node-version: 22 |
34 | 46 |
|
35 | | - - name: Update Config with Manual Inputs |
36 | | - shell: bash |
| 47 | + - name: Calculate new version |
| 48 | + id: version |
37 | 49 | run: | |
38 | | - IS_PRERELEASE=${{ github.event.inputs.release-type == 'next' }} |
39 | | - PREID="${{ github.event.inputs.preid }}" |
| 50 | + # Read current version from manifest |
| 51 | + CURRENT_VERSION=$(jq -r '."."' .release-please-manifest.json) |
| 52 | + echo "Current version: $CURRENT_VERSION" |
40 | 53 |
|
41 | | - jq --arg pre "$IS_PRERELEASE" --arg id "$PREID" \ |
42 | | - '.packages["."].prerelease = ($pre == "true") | .packages["."]["prerelease-type"] = $id | .packages["."]["always-link-local"] = false | .["always-update"] = true' \ |
43 | | - release-please-config.json > tmp.json && mv tmp.json release-please-config.json |
| 54 | + # Install semver for version calculation |
| 55 | + npm install -g semver |
44 | 56 |
|
45 | | - echo "Updated release-please-config.json:" |
46 | | - cat release-please-config.json |
| 57 | + # Calculate new version based on input |
| 58 | + NEW_VERSION=$(semver -i ${{ inputs.version }} $CURRENT_VERSION) |
| 59 | + echo "New version: $NEW_VERSION" |
| 60 | + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT |
47 | 61 |
|
48 | | - - name: Create Release PR |
49 | | - uses: googleapis/release-please-action@v4 |
50 | | - with: |
51 | | - token: ${{ steps.app-token.outputs.token }} |
| 62 | + - name: Create release commit |
| 63 | + run: | |
| 64 | + git config user.name "ambitiondev-release-bot[bot]" |
| 65 | + git config user.email "ambitiondev-release-bot[bot]@users.noreply.github.com" |
| 66 | + git commit --allow-empty -m "chore: release ${{ steps.version.outputs.new_version }}" -m "Release-As: ${{ steps.version.outputs.new_version }}" |
| 67 | + git push |
0 commit comments