You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: adminforth/documentation/blog/2025-01-09-how-adminforth-manages-version/index.md
+202-6Lines changed: 202 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,35 +11,231 @@ In this post I will share our journey of how we did a transition from manual Cha
11
11
12
12
## Prehistory
13
13
14
-
Before 1.6.0 AdminForth was using manual ChangeLog. We were reviwing PRs, merged them all to `main` branch and there did manually npm release. We were constantly releasing to next pre-release version and used it internally on our projets for testing. Once we collected enough features and fixes, we were doing a release to `latest` version.
14
+
Before 1.6.0 AdminForth was using manual ChangeLog. We were reviwing PRs, merged them all to `main` branch and there did manually npm release. We were constantly releasing to `next` pre-release version from `main` and used `next` it internally on our projets for testing. Once we collected enough features and fixes, we were doing a release to `latest` version, and at this time we did release documentation.
15
+
ChangeLog included only main "latest" chain of versions, so while we releasing to `next` we added items under one version in ChangeLog. So user was not able to distinguish `1.5.0-next.0` from `1.5.0-next.1` in ChangeLog.
16
+
17
+
Anyway this was a pretty good approach, but it was hard to maintain ChangeLog: first you have to write commit message, then write same message in ChangeLog. And from time to time we were missing updating ChangeLog at all.
18
+
19
+
Also since release was manual from my PC there was a chance that I will forget to push tags to GitHub and release already happened. And chance that I will forget to push ChangeLog to GitHub.
20
+
21
+
Git tags were applied only after release and there again was a chance that I will forget to push them to GitHub before release.
22
+
So only one reliabile way to check what is difference in source code between versions was to use https://npmdiff.dev/ and not rely on git and ChangeLog.
23
+
24
+
Another thing is documentation. If I added something to documentation and decided to release it, there was a chance that I will release items for `next` version which are not yet in `latest` version. But this was easily solvable by maintaining `next` and `latest` branches instead of doing `next` development in `main` branch. In the end we switched to this approach.
25
+
26
+
Another thing - structure of repository. Historically for faster development in dev demo, we added all plugins into one repository. This was good for development(and very bad when count of plugins increased), and very bad for release process. Every plugin had its own version and its own ChangeLog. So we had to enter every plugin folder, do release, and push ChangeLog to GitHub. This was very time consuming and error-prone. It started to be obvious that we need to split plugins to separate repositories what was done now.
15
27
16
28
## Transition
17
29
18
-
I will show a flow on empty fake repository
30
+
I will show a flow on empty fake small project to not overcomplicate things.
31
+
We will use minimal typescript package with `npm` and `semantic-release` to show how it works.
"test": "echo \"Error: no test specified\" && exit 1"
75
+
//diff-add
76
+
"build": "tsc",
34
77
},
35
78
"author": "",
36
79
"license": "ISC",
37
80
"description": "",
38
81
//diff-add
39
82
"release": {
40
83
//diff-add
41
-
"branches": ["master", "next"]
84
+
"branches": [main", "next"]
42
85
//diff-add
43
86
}
44
87
}
45
-
```
88
+
```
89
+
90
+
Make sure name in package.json has your organisation name like mine `@devforth/` and you have access to publish packages to npmjs.com.
91
+
92
+
```
93
+
npm install --save-dev semantic-release
94
+
```
95
+
96
+
## Connecting to CI
97
+
98
+
We will use Woodpecker CI for this example. Woodpecker is a free and open-source CI/CD tool that you can install to your own server / VPS and will not need to pay only for server. No limits on pipelines, users, repositories, etc. If you want to try it, we have [Woodpecker installation guide](https://devforth.io/blog/step-by-step-guide-to-modern-secure-ci-setup/)
99
+
100
+
Create a file `.woodpecker.yml` in root of your repository:
101
+
102
+
```
103
+
clone:
104
+
git:
105
+
image: woodpeckerci/plugin-git
106
+
settings:
107
+
partial: false
108
+
depth: 5
109
+
110
+
steps:
111
+
build:
112
+
image: node:22
113
+
volumes:
114
+
- /var/run/docker.sock:/var/run/docker.sock
115
+
commands:
116
+
- npm clean-install
117
+
- npm run build
118
+
- npm audit signatures
119
+
- npx semantic-release
120
+
secrets:
121
+
- GITHUB_TOKEN
122
+
- NPM_TOKEN
123
+
```
124
+
125
+
Go to Woodpecker, authorize via GitHub, click "Add repository", find your repository and add it.
126
+
127
+
Disable "Project settings" -> "Allow Pull Requests" because we do not want to trigger builds on PRs.
128
+
Enable "Project settings" -> "Trusted"
129
+
Enable "Project Visibility" -> "Public"
130
+
131
+

132
+
133
+
134
+
### Generating GitHub acces token
135
+
136
+
if your repo is in GitHub organisation, you need first enable access to personal access tokens for your organisation (if not yet done)
137
+
138
+
1. In the upper-right corner of GitHub, select your profile photo, then click Your organizations.
139
+
2. Next to the organization, click Settings.
140
+
3. In the left sidebar, under Personal access tokens, click Settings.
141
+
4. Select "Allow access via fine-grained personal access tokens"
142
+
5. We recommend setting "Require administrator approval"
143
+
6. "Allow access via personal access tokens (classic)"
144
+
145
+
Now go to your profile, click on "Settings" -> "Developer settings" -> "Personal access tokens" -> "Generate new token"
146
+
147
+
For permissions, select Contents: Read and Write
148
+
select Metadata: Read-only
149
+
150
+
151
+
In Woodpecker Go to settings, Secrets, Add Secret `GITHUB_TOKEN` and paste your token:
152
+
153
+

154
+
155
+
In "Available at following events" select "Push" and "Tag", also you can select "Manual" if you want to trigger builds manually.
156
+
157
+

158
+
159
+
160
+
### Generating NPM token
161
+
162
+
Go to your npmjs.com account, click on "Profile Avatar" -> "Access Tokens" -> "Generate New Token" -> "New Granular Access Token".
163
+
164
+
Packages and scopes Permissions: Read and Write.
165
+
166
+
Add to Woodpecker as secret `NPM_TOKEN`
167
+
168
+
169
+
## Testing
170
+
171
+
For now we did not yet push anything to GitHub and did not publish anything to npm.
172
+
173
+
Lets do it now.
174
+
175
+
176
+
Just push your first commit as:
177
+
178
+
179
+
```
180
+
feat: initial commit
181
+
```
182
+
183
+
This will trigger semantic-release to do first release v1.0.0.
184
+
185
+
Now change something is index.ts and push it as fix
186
+
187
+
```
188
+
fix: fix greet function
189
+
```
190
+
191
+
This will trigger semantic-release to do release v1.0.1.
192
+
193
+
194
+
Now change something in index.ts and push it as feat
195
+
196
+
```
197
+
feat: add new function
198
+
```
199
+
200
+
This will trigger semantic-release to do release v1.1.0 because we added new feature, not just fixed something.
201
+
202
+
203
+
### Next distribution channel
204
+
205
+
Now we will show how to release to `next` channel.
206
+
207
+
```
208
+
git checkout -b next
209
+
```
210
+
211
+
Change something and push it as fix
212
+
213
+
```
214
+
fix: fix greet function in next
215
+
```
216
+
217
+
Commit it and push:
218
+
219
+
```
220
+
git push --set-upstream origin next
221
+
```
222
+
223
+
This will trigger semantic-release to do release `v1.1.1-next.1`. Please not that it bumped patch version because we are in `next` channel.
224
+
225
+
Now lets add feature to next
226
+
227
+
```
228
+
feat: add new feature in next
229
+
```
230
+
231
+
It will trigger release `v1.2.0-next.1` because we added new feature and minor version was bumped. Please not that next number started from 1 again.
232
+
233
+
Noe lets merge `next` to `main` and push it:
234
+
235
+
```
236
+
git checkout main
237
+
git merge next
238
+
git push
239
+
```
240
+
241
+
This will trigger release `v1.2.0` because we merged `next` to `main` and it was a feature release.
0 commit comments