Skip to content

Commit 16aef37

Browse files
committed
add autorelease
1 parent dd8515f commit 16aef37

File tree

9 files changed

+6180
-50
lines changed

9 files changed

+6180
-50
lines changed
251 KB
Loading
41.2 KB
Loading
245 KB
Loading
165 KB
Loading

adminforth/documentation/blog/2025-01-09-how-adminforth-manages-version/index.md

Lines changed: 202 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,231 @@ In this post I will share our journey of how we did a transition from manual Cha
1111

1212
## Prehistory
1313

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.
1527

1628
## Transition
1729

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.
32+
33+
```
34+
echo "# test-sem-release" >> README.md
35+
git init
36+
git add README.md
37+
git commit -m "first commit"
38+
git branch -M main
39+
git remote add origin [email protected]:devforth/test-sem-release.git
40+
git push -u origin main
41+
```
42+
43+
Now lets init new `npm package`:
1944

2045
```
21-
git clone [email protected]:devforth/test-sem-release.git
2246
npm init -y
47+
npm install typescript --save-dev
48+
npx tsc --init
49+
```
50+
51+
Create a file `index.ts`:
52+
53+
```
54+
export const greet = (name: string): string => {
55+
return `Hello, ${name}!`;
56+
};
2357
```
2458

59+
2560
In `package.json` add:
2661

2762
```
2863
{
29-
"name": "test-sem-release",
64+
"name": "@devforth/test-sem-release",
65+
//diff-add
66+
"publishConfig": {
67+
//diff-add
68+
"access": "public"
69+
//diff-add
70+
},
3071
"version": "1.0.0",
3172
"main": "index.js",
3273
"scripts": {
3374
"test": "echo \"Error: no test specified\" && exit 1"
75+
//diff-add
76+
"build": "tsc",
3477
},
3578
"author": "",
3679
"license": "ISC",
3780
"description": "",
3881
//diff-add
3982
"release": {
4083
//diff-add
41-
"branches": ["master", "next"]
84+
"branches": [main", "next"]
4285
//diff-add
4386
}
4487
}
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+
![Woodpecker project settings](image-3.png)
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+
![Woodpecker Secrets](image.png)
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+
![Woodpecker Secrets List](image-2.png)
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.

adminforth/documentation/docs/tutorial/03-Customization/13-standardPagesTuning.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export default {
235235
```
236236

237237

238-
Also you can assign adminUser ID by adminUser.dbUser.id in same hook:
238+
Also you can assign adminUser ID by `adminUser.dbUser.id`:
239239

240240
```typescript title="./resources/apartments.ts"
241241
export default {
@@ -311,4 +311,22 @@ export default {
311311
},
312312
...
313313
],
314-
```
314+
```
315+
316+
> `editReadonly` is check enforced both on fronted and backend. So it is safe to use it to make sure that data will be never changes.
317+
318+
319+
320+
### minValue and maxValue
321+
322+
323+
[Documentation in progress]
324+
325+
326+
### Validation
327+
328+
[Documentation in progress]
329+
330+
### Foreign resources
331+
332+
[Documentation in progress]

0 commit comments

Comments
 (0)