Skip to content

Commit 37b14b7

Browse files
changeset release
1 parent e2bfa09 commit 37b14b7

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

.github/workflows/release.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_type:
7+
description: 'Release type'
8+
required: true
9+
type: choice
10+
options:
11+
- 'pre-release (next)'
12+
- 'stable release'
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: '20'
30+
registry-url: 'https://registry.npmjs.org'
31+
32+
- name: Install dependencies
33+
run: npm ci
34+
35+
- name: Clean
36+
run: npm run clean
37+
38+
- name: Build
39+
run: npm run build
40+
41+
- name: Lint
42+
run: npm run lint
43+
44+
- name: Test
45+
run: npm run test
46+
47+
- name: Configure Git
48+
run: |
49+
git config user.name "github-actions[bot]"
50+
git config user.email "github-actions[bot]@users.noreply.github.com"
51+
52+
- name: Version packages (pre-release)
53+
if: inputs.release_type == 'pre-release (next)'
54+
run: |
55+
npx changeset pre enter next || true
56+
npx changeset version
57+
58+
- name: Version packages (stable)
59+
if: inputs.release_type == 'stable release'
60+
run: |
61+
npx changeset pre exit || true
62+
npx changeset version
63+
64+
- name: Update lock file
65+
run: npm install --package-lock-only
66+
67+
- name: Publish to npm
68+
id: publish
69+
run: |
70+
OUTPUT=$(npx changeset publish 2>&1)
71+
echo "$OUTPUT"
72+
# Extract published packages for PR comment
73+
PUBLISHED=$(echo "$OUTPUT" | grep -E "^@walkeros/|^walkeros" | head -20 || true)
74+
echo "published<<EOF" >> $GITHUB_OUTPUT
75+
echo "$PUBLISHED" >> $GITHUB_OUTPUT
76+
echo "EOF" >> $GITHUB_OUTPUT
77+
env:
78+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
79+
80+
- name: Commit version changes
81+
run: |
82+
git add -A
83+
git commit -m "chore: version packages" || echo "No changes to commit"
84+
git push
85+
86+
- name: Comment on PR
87+
if: steps.publish.outputs.published != ''
88+
env:
89+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
run: |
91+
PR_NUMBER=$(gh pr list --head "${{ github.ref_name }}" --state open --json number --jq '.[0].number' || true)
92+
93+
if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then
94+
if [ "${{ inputs.release_type }}" = "pre-release (next)" ]; then
95+
EMOJI="📦"
96+
TITLE="Pre-release published (next)"
97+
INSTALL_TAG="@next"
98+
else
99+
EMOJI="🚀"
100+
TITLE="Stable release published"
101+
INSTALL_TAG="@latest"
102+
fi
103+
104+
BODY="$EMOJI **$TITLE**
105+
106+
${{ steps.publish.outputs.published }}
107+
108+
Install: \`npm i @walkeros/core$INSTALL_TAG\`"
109+
110+
gh pr comment "$PR_NUMBER" --body "$BODY"
111+
echo "Commented on PR #$PR_NUMBER"
112+
else
113+
echo "No open PR found for branch ${{ github.ref_name }}"
114+
fi

0 commit comments

Comments
 (0)