Skip to content

Commit 1e9d510

Browse files
committed
feat: enhance release workflow to support canary and RC publishing via issue comments
1 parent 9f01693 commit 1e9d510

1 file changed

Lines changed: 80 additions & 10 deletions

File tree

.github/workflows/release.yaml

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,106 @@
1-
name: release packages
1+
name: Publish Package
22

33
on:
44
push:
55
branches:
66
- main
7+
issue_comment:
8+
types:
9+
- created
10+
11+
permissions:
12+
id-token: write
13+
contents: write
714

815
concurrency: ${{ github.workflow }}-${{ github.ref }}
916

1017
jobs:
11-
release:
12-
name: Release
18+
get-branch:
19+
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && (github.event.comment.body == 'canary-publish' || github.event.comment.body == '/canary-publish' || github.event.comment.body == 'rc-publish' || github.event.comment.body == '/rc-publish')
1320
runs-on: ubuntu-latest
21+
outputs:
22+
branch: ${{ steps.get_branch.outputs.branch }}
23+
steps:
24+
- name: Get PR branch name
25+
id: get_branch
26+
run: |
27+
PR=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" ${{ github.event.issue.pull_request.url }})
28+
branch=$(echo "$PR" | jq -r '.head.ref')
29+
echo "branch=$branch" >> "$GITHUB_OUTPUT"
30+
31+
publish:
32+
runs-on: ubuntu-latest
33+
needs: [get-branch]
34+
if: |
35+
always() &&
36+
(github.event_name == 'push' ||
37+
(github.event_name == 'issue_comment' && needs.get-branch.result == 'success'))
1438
steps:
1539
- name: Checkout Repo
1640
uses: actions/checkout@v4
1741
with:
42+
ref: ${{ needs.get-branch.outputs.branch || github.ref }}
1843
token: ${{ secrets.ACTION_TOKEN }}
1944
fetch-depth: 0
20-
- name: Setup pnpm and install dependencies
21-
uses: ./tooling/github/setup
22-
- name: Create Release Pull Request
23-
id: changesets
45+
46+
- uses: pnpm/action-setup@v4
47+
48+
- name: Use Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: "22"
52+
cache: "pnpm"
53+
54+
- name: Check and upgrade npm
55+
run: |
56+
echo "Current npm version:"
57+
npm --version
58+
npm install -g npm@latest
59+
echo "Upgraded npm version:"
60+
npm --version
61+
62+
- name: Install Dependencies
63+
run: pnpm install --frozen-lockfile
64+
65+
- name: Build package
66+
run: pnpm run build
67+
68+
- name: Publish - Release
69+
if: github.event_name == 'push'
2470
uses: NaverPayDev/changeset-actions/publish@main
2571
with:
2672
github_token: ${{ secrets.ACTION_TOKEN }}
27-
npm_token: ${{ secrets.NPM_TOKEN }}
2873
git_username: npayfebot
2974
git_email: npay.fe.bot@navercorp.com
3075
publish_script: pnpm release
31-
pr_title: '🚀 version changed packages'
32-
commit_message: '📦 bump changed packages version'
76+
pr_title: "🚀 version changed packages"
77+
commit_message: "📦 bump changed packages version"
3378
create_github_release_tag: true
3479
formatting_script: pnpm run markdownlint:fix
3580
env:
3681
GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }}
82+
83+
- name: Publish - Canary
84+
if: github.event_name == 'issue_comment' && (github.event.comment.body == 'canary-publish' || github.event.comment.body == '/canary-publish')
85+
uses: NaverPayDev/changeset-actions/canary-publish@main
86+
with:
87+
github_token: ${{ secrets.ACTION_TOKEN }}
88+
npm_tag: canary
89+
publish_script: pnpm run release:canary
90+
packages_dir: "."
91+
excludes: ".turbo,.github"
92+
version_template: "{VERSION}-canary.{DATE}-{COMMITID7}"
93+
94+
- name: Publish - RC
95+
if: github.event_name == 'issue_comment' && (github.event.comment.body == 'rc-publish' || github.event.comment.body == '/rc-publish')
96+
uses: NaverPayDev/changeset-actions/canary-publish@main
97+
with:
98+
github_token: ${{ secrets.ACTION_TOKEN }}
99+
npm_tag: rc
100+
publish_script: pnpm run release:canary
101+
packages_dir: "."
102+
excludes: ".turbo,.github"
103+
version_template: "{VERSION}-rc.{DATE}-{COMMITID7}"
104+
create_release: true
105+
env:
106+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)