|
1 | | -name: release packages |
| 1 | +name: Publish Package |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - main |
| 7 | + issue_comment: |
| 8 | + types: |
| 9 | + - created |
| 10 | + |
| 11 | +permissions: |
| 12 | + id-token: write |
| 13 | + contents: write |
7 | 14 |
|
8 | 15 | concurrency: ${{ github.workflow }}-${{ github.ref }} |
9 | 16 |
|
10 | 17 | 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') |
13 | 20 | 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')) |
14 | 38 | steps: |
15 | 39 | - name: Checkout Repo |
16 | 40 | uses: actions/checkout@v4 |
17 | 41 | with: |
| 42 | + ref: ${{ needs.get-branch.outputs.branch || github.ref }} |
18 | 43 | token: ${{ secrets.ACTION_TOKEN }} |
19 | 44 | 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' |
24 | 70 | uses: NaverPayDev/changeset-actions/publish@main |
25 | 71 | with: |
26 | 72 | github_token: ${{ secrets.ACTION_TOKEN }} |
27 | | - npm_token: ${{ secrets.NPM_TOKEN }} |
28 | 73 | git_username: npayfebot |
29 | 74 | git_email: npay.fe.bot@navercorp.com |
30 | 75 | 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" |
33 | 78 | create_github_release_tag: true |
34 | 79 | formatting_script: pnpm run markdownlint:fix |
35 | 80 | env: |
36 | 81 | 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