-
Notifications
You must be signed in to change notification settings - Fork 0
213 lines (189 loc) Β· 7.38 KB
/
publish.yml
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: Publish Itthynk Components
on:
push:
tags:
- itthynk-components@*.*.*
pull_request:
types: [closed]
branches:
- publish
paths:
- 'components/**'
permissions:
contents: write
packages: write
pull-requests: write
id-token: write
jobs:
release-version:
name: Release Version
runs-on: ubuntu-latest
environment: publish
env:
RELEASE_NAME: components
RELEASE_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
GIT_USERNAME: ${{ secrets.GIT_USERNAME }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
GLOBAL_GPG_SECRET: ${{ secrets.GLOBAL_GPG_SECRET }}
GLOBAL_GPG_PASSPHRASE: ${{ secrets.GLOBAL_GPG_PASSPHRASE }}
if: github.event_name == 'pull_request' && github.event.pull_request.merged==true
outputs:
release_version: ${{ steps.release_trigger.outputs.release_version }}
pr_log: ${{ steps.release_trigger.outputs.pr_log }}
release_sha: ${{ steps.release_trigger_sha.outputs.release_sha }}
steps:
- uses: actions/[email protected]
- name: setup node
id: release_trigger
uses: mitch1009/[email protected]
with:
git_user_email: ${{env.GIT_USER_EMAIL}}
git_username: ${{env.GIT_USERNAME }}
gpg_private_key: ${{env.GLOBAL_GPG_SECRET}}
gpg_passphrase: ${{env.GLOBAL_GPG_PASSPHRASE}}
git_token: ${{env.GIT_TOKEN}}
bump_script: "rel:patch"
working_directory: "components"
release_branch: publish
version_file_path: "components/package.json"
- name: Release Trigger
id: release_trigger_sha
run: |
SHA=$(git rev-parse --short HEAD)
echo "release_sha=${SHA}" >> $GITHUB_OUTPUT
publish-npm:
needs: release-version
runs-on: ubuntu-latest
environment: publish
name: Publish to npm
if: needs.release-version.outputs.release_version != ''
steps:
- uses: actions/[email protected]
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
scope: '@opherlabs'
- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: 8
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/[email protected]
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Build
working-directory: ./components
run: |
# replace the version in package.json with the release version
node -e "const fs = require('fs'); const packageJson = require('./package.json'); packageJson.version = '${{ needs.release-version.outputs.release_version }}'; fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, 2));"
npm run build
- name: Publish to npm
working-directory: ./components
run: npm publish --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-github:
needs: release-version
runs-on: ubuntu-latest
environment: publish
if: needs.release-version.outputs.release_version != ''
name: Publish to GitHub Packages
steps:
- uses: actions/[email protected]
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: '20'
registry-url: 'https://npm.pkg.github.com'
scope: '@opherlabs'
- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: 8
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/[email protected]
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Build
working-directory: ./components
run: |
# replace the version in package.json with the release version
node -e "const fs = require('fs'); const packageJson = require('./package.json'); packageJson.version = '${{ needs.release-version.outputs.release_version }}'; fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, 2));"
npm run build
- name: Publish to GitHub Packages
working-directory: ./components
run: npm publish --no-git-checks --registry https://npm.pkg.github.com
env:
NODE_AUTH_TOKEN: ${{ secrets.GIT_TOKEN }}
tag-release:
name: Tag Release π
runs-on: ubuntu-latest
environment: publish
needs: [publish-github]
permissions:
contents: write
id-token: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Generate Release Notes
run: |
echo "RELEASE_VERSION=$(cat components/package.json | jq -r .version)"
create-new-release:
name: Create New Release π
runs-on: ubuntu-latest
environment: publish
needs: [release-version,publish-npm, tag-release]
if: needs.release-version.outputs.release_version != ''
permissions:
contents: write
id-token: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/[email protected]
with:
fetch-depth: 0 # Fetch all history for all tags and branches
- name: Get contributors
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
run: |
CONTRIBUTORS=$(gh api repos/${{ github.repository }}/contributors --jq 'map(.login) | join(", @")')
echo "CONTRIBUTORS=@$CONTRIBUTORS" >> $GITHUB_ENV
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
run: |
gh release create itthynk-components@${{ needs.release-version.outputs.release_version }} \
--title "itthynk-components@${{ needs.release-version.outputs.release_version }}" \
--notes "## π What's new in this release:
${{ needs.release-version.outputs.pr_log }}
## ππΎ Thank You:
A big thank you to all our amazing engineers and maintainers
"