-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (122 loc) · 5.57 KB
/
release.yml
File metadata and controls
142 lines (122 loc) · 5.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Publish Package
on:
repository_dispatch:
types: [ release-command ]
workflow_dispatch:
inputs:
verUpType:
description: "Version-Up Type"
required: true
type: choice
options:
- "patch"
- "minor"
- "major"
env:
kyBOT-APP_ID: 960836
jobs:
validation:
runs-on: ubuntu-latest
if: ${{ !contains(fromJSON('["patch", "minor", "major"]'), (github.event.client_payload.slash_command.args.unnamed.arg1 || github.event.inputs.verUpType)) }}
steps:
- name: get github app token
id: github-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ env.kyBOT-APP_ID }}
private-key: ${{ secrets.kyBOT_PRIVATE_KEY }}
- name: Failed Report
if: ${{ github.event.inputs.verUpType == '' }}
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
with:
token: ${{ steps.github-token.outputs.token }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
body: |
The /release command requires one of major, minor, or patch.
```
/release major
/release minor
/release patch
```
- name: Exit 2
run: exit 2
publish:
runs-on: ubuntu-latest
if: ${{ ! failure() }}
needs:
validation
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- uses: oven-sh/setup-bun@v2
- name: Get GitHub App Token
id: github-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ env.kyBOT-APP_ID }}
private-key: ${{ secrets.kyBOT_PRIVATE_KEY }}
- name: Cache Dependencies
id: bun_cache
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/bun.lockb') }}
- name: Install Dependencies
if: steps.bun_cache.outputs.cache-hit != 'true'
run: bun install --frozen-lockfile
- name: Get Version-Up Type
id: ver_up_type
run: |
ver_up_type=${{ github.event.client_payload.slash_command.args.unnamed.arg1 || github.event.inputs.veruptype }}
echo "ver_up_type=$ver_up_type" >> $GITHUB_OUTPUT
- name: Publish Package to npmjs
id: publish
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
npm version `npm view @ky-y./utils version` --allow-same-version
version=`npm version ${{ steps.ver_up_type.outputs.VER_UP_TYPE }}`
npm publish --provenance
echo "version=$version" >> $GITHUB_OUTPUT
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Success Report
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
with:
token: ${{ steps.github-token.outputs.token }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
body: |
The release of ${{ steps.publish.outputs.version }} was completed successfully.
failed:
runs-on: ubuntu-latest
if: ${{ always() && contains(needs.*.result, 'failure') }}
needs:
publish
steps:
- name: Get GitHub App Token
id: github-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ env.kyBOT-APP_ID }}
private-key: ${{ secrets.kyBOT_PRIVATE_KEY }}
- name: Get Action URL
id: action-url
run: |
action_url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
echo "action-url=$action_url" >> $GITHUB_OUTPUT
- name: Failed Report
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
with:
token: ${{ steps.github-token.outputs.token }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
body: |
The release failed. Please check the logs.
${{ steps.action-url.outputs.action-url }}