-
Notifications
You must be signed in to change notification settings - Fork 0
202 lines (173 loc) · 5.53 KB
/
cd.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
---
name: 'CD'
on:
workflow_run:
workflows: ['CI']
types:
- completed
jobs:
tag:
runs-on: ubuntu-24.04
name: Tag the release
if: startsWith(github.event.workflow_run.head_commit.message, 'bump:')
permissions:
contents: write
outputs:
version: ${{ steps.calculate_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Set git user info
run: |
git config user.name 'Temeraire'
git config user.email '[email protected]'
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Calculate the next version
id: calculate_version
run: |
PATH=$(pnpm bin):$PATH
VERSION=$(git cliff --bumped-version)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Install jq
run: |
sudo apt-get update
sudo apt-get -y install jq
- name: Update package.json
run: |
JQ_VERSION=${{ steps.calculate_version.outputs.version }} jq '.version=env.JQ_VERSION' ./core/package.json > /tmp/package.json
mv /tmp/package.json ./core/package.json
git add ./core/package.json
git commit -m "chore(core): bump version to ${{ steps.calculate_version.outputs.version }}"
- name: Tag the release
run: |
git tag ${{ steps.calculate_version.outputs.version }} -m "${{ steps.calculate_version.outputs.version }}"
- name: Push changes
uses: ad-m/[email protected]
with:
branch: ${{ github.ref }}
ssh: true
tags: true
changelog:
runs-on: ubuntu-24.04
needs: [tag]
name: Generate and commit changelog
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true
ref: ${{ needs.tag.outputs.version }}
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Set git user info
run: |
git config user.name 'Temeraire'
git config user.email '[email protected]'
- name: Generate a complete changelog
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: -v --no-exec --github-repo ${{ github.repository }}
env:
OUTPUT: CHANGELOG.md
- name: Commit changelog
run: |
git checkout main
git add CHANGELOG.md
git commit -m "docs(changelog.md): update [skip ci]"
- name: Push changes
uses: ad-m/[email protected]
with:
ssh: true
branch: ${{ github.ref }}
- name: Generate a changelog for the latest release
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: -v --no-exec --github-repo ${{ github.repository }} --latest --strip header
env:
GITHUB_REPO: ${{ github.repository }}
OUTPUT: CHANGES.md
- name: Get current tag
id: get_tag
run: echo "tag_name=$(git describe --abbrev=0 --tags)" >> "$GITHUB_OUTPUT"
- name: Create release
uses: softprops/action-gh-release@v2
with:
body_path: CHANGES.md
fail_on_unmatched_files: true
tag_name: ${{ steps.get_tag.outputs.tag_name }}
token: ${{ secrets.GITHUB_TOKEN }}
publish:
runs-on: ubuntu-24.04
needs: [tag]
name: Publish to NPM
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.tag.outputs.version }}
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: pnpm install --frozen-lockfile
# https://github.com/pnpm/pnpm/issues/4937
- name: Set up special NPM voodoo
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
echo "@garudalinux:registry=https://registry.npmjs.org/" >> ~/.npmrc
- name: Publish to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpx nx run core:publish
publish-docs:
runs-on: ubuntu-24.04
needs: [tag]
name: Deploy docs to Cloudflare Pages
permissions:
contents: read
steps:
- name: Checkout tag
uses: actions/checkout@v4
with:
ref: ${{ needs.tag.outputs.version }}
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build the documentation
run: pnpx nx build docs
- name: Deploy Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: pages deploy --branch main
packageManager: pnpm