Skip to content

Commit d275cee

Browse files
committed
ci(release): create
1 parent 488d40f commit d275cee

1 file changed

Lines changed: 47 additions & 31 deletions

File tree

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,67 @@
1-
name: Create Release PR
1+
name: Create release PR
22

33
on:
44
workflow_dispatch:
55
inputs:
6-
release-type:
7-
description: "Release type"
6+
version:
87
required: true
98
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
1125
preid:
12-
description: "Prerelease identifier"
1326
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
1534

1635
jobs:
17-
create-release-pr:
18-
name: Create Release PR
19-
if: github.ref == 'refs/heads/main'
36+
create-release:
2037
runs-on: ubuntu-latest
2138
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-
2939
- name: Checkout
3040
uses: actions/checkout@v4
41+
42+
- name: Setup Node.js
43+
uses: actions/setup-node@v4
3144
with:
32-
token: ${{ steps.app-token.outputs.token }}
33-
fetch-depth: 0
45+
node-version: 22
3446

35-
- name: Update Config with Manual Inputs
36-
shell: bash
47+
- name: Calculate new version
48+
id: version
3749
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"
4053
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
4456
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
4761
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

Comments
 (0)