Skip to content

Commit 02f8a6a

Browse files
cre8lukasjhangithub-actions
authored
Set main as default (#171)
Signed-off-by: Lukas.J.Han <[email protected]> Signed-off-by: Mirko Mollik <[email protected]> Signed-off-by: Lukas <[email protected]> Co-authored-by: Lukas.J.Han <[email protected]> Co-authored-by: github-actions <[email protected]>
1 parent 220e3a6 commit 02f8a6a

6 files changed

+205
-45
lines changed

.github/settings.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repository:
1414
homepage: https://sdjwt.js.org/
1515
# A comma-separated list of topics to set on the repository
1616
topics: sd-jwt, jwt
17-
default_branch: next
17+
default_branch: main
1818

1919
# Labels: define labels for Issues and Pull Requests
2020
labels:

.github/workflows/build-test-publish-on-push-cached.yaml

+9-22
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
name: build-test-publish-on-push-cached
2-
on:
3-
workflow_dispatch:
2+
on:
43
pull_request:
5-
branches:
6-
- 'main'
7-
- 'next'
8-
- 'unstable'
4+
branches:
5+
- 'main'
96
push:
10-
branches:
11-
- 'main'
12-
- 'next'
13-
- 'unstable'
7+
branches:
8+
- 'main'
149

1510
jobs:
1611
build:
@@ -109,12 +104,12 @@ jobs:
109104
node-version: 20
110105
cache: 'pnpm'
111106
# we are not using the github action for biome, but the package.json script. this makes sure we are using the same versions.
112-
- name: Run Biome
107+
- name: Run Biome
113108
run: pnpm run biome:ci
114109

115110
# Only run this job when the push is on main, next or unstable
116-
publish:
117-
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next' || github.ref == 'refs/heads/unstable')
111+
publish:
112+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
118113
# needs permissions to write tags to the repository
119114
permissions:
120115
contents: write
@@ -166,14 +161,6 @@ jobs:
166161
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
167162
npm whoami
168163
169-
- name: 'Publish @latest when on main'
170-
if: github.ref == 'refs/heads/main'
171-
run: pnpm publish:latest
172-
173-
- name: 'Publish @next when on next'
164+
- name: 'Publish next version'
174165
if: github.ref == 'refs/heads/next'
175166
run: pnpm publish:next
176-
177-
- name: 'Publish @unstable when on unstable branch'
178-
if: github.ref == 'refs/heads/unstable'
179-
run: pnpm publish:unstable

.github/workflows/release.yml

+185
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
name: release
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
check-author:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout repository
10+
uses: actions/checkout@v4
11+
12+
- name: Check if user is in CODEOWNERS
13+
id: check_user
14+
run: |
15+
CODEOWNERS_PATH="CODEOWNERS"
16+
if [ ! -f "$CODEOWNERS_PATH" ]; then
17+
echo "CODEOWNERS file not found."
18+
exit 1
19+
fi
20+
21+
# Extract GitHub usernames from CODEOWNERS file (assumes usernames, not emails or teams)
22+
USERS=$(grep '@' $CODEOWNERS_PATH | sed -E 's/.*@([^ ]+).*/\1/' | tr '\n' ' ')
23+
24+
# Check if the actor is in the list of users
25+
if [[ ! " $USERS " =~ " ${{ github.actor }} " ]]; then
26+
echo "Error: Actor ${{ github.actor }} is not listed in CODEOWNERS."
27+
exit 1
28+
else
29+
echo "Actor ${{ github.actor }} is listed in CODEOWNERS."
30+
fi
31+
# we can add an approval stage with the environment so it can only be run when accepted by two authorized users.
32+
build:
33+
needs: check-author
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
with:
38+
fetch-depth: 0
39+
persist-credentials: false
40+
- uses: pnpm/action-setup@v3
41+
with:
42+
version: 8
43+
- run: pnpm add -g pnpm
44+
- name: 'Setup Node.js with pnpm cache'
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version: 20
48+
cache: 'pnpm'
49+
50+
- run: pnpm install
51+
- run: pnpm build
52+
- name: 'Save build output'
53+
uses: actions/cache/save@v4
54+
with:
55+
path: ${{ github.workspace }}
56+
key: ${{ runner.os }}-build-${{ github.sha }}-${{ github.run_id }}
57+
58+
test:
59+
needs: build
60+
runs-on: ubuntu-latest
61+
strategy:
62+
matrix:
63+
node-version: ['16.x', '18.x', '20.x']
64+
steps:
65+
- uses: pnpm/action-setup@v3
66+
with:
67+
version: 8
68+
- run: pnpm add -g pnpm
69+
- name: 'Restore build output'
70+
uses: actions/cache/restore@v4
71+
with:
72+
path: ${{ github.workspace }}
73+
key: ${{ runner.os }}-build-${{ github.sha }}-${{ github.run_id }}
74+
restore-keys: ${{ runner.os }}-build-${{ github.sha }}
75+
fail-on-cache-miss: true
76+
- name: 'Setup Node.js with pnpm cache'
77+
uses: actions/setup-node@v4
78+
with:
79+
node-version: ${{ matrix.node-version }}
80+
cache: 'pnpm'
81+
- name: 'Run node'
82+
run: pnpm test
83+
- uses: actions/upload-artifact@v4
84+
# we are only uploading the 20 coverage report so we do not have to merge them in the next step.
85+
if: matrix.node-version == '20.x'
86+
with:
87+
name: coverage-artifacts
88+
path: coverage/
89+
90+
report-coverage:
91+
runs-on: ubuntu-latest
92+
needs: [test]
93+
steps:
94+
- uses: actions/checkout@v4
95+
with:
96+
fetch-depth: 0
97+
persist-credentials: false
98+
- uses: actions/download-artifact@v4
99+
with:
100+
name: coverage-artifacts
101+
path: coverage
102+
- uses: codecov/codecov-action@v4
103+
with:
104+
fail_ci_if_error: true
105+
env:
106+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
107+
108+
lint:
109+
needs: build
110+
runs-on: ubuntu-latest
111+
steps:
112+
- uses: pnpm/action-setup@v3
113+
with:
114+
version: 8
115+
- run: pnpm add -g pnpm
116+
- name: 'Restore build output'
117+
uses: actions/cache/restore@v4
118+
with:
119+
path: ${{ github.workspace }}
120+
key: ${{ runner.os }}-build-${{ github.sha }}-${{ github.run_id }}
121+
restore-keys: ${{ runner.os }}-build-${{ github.sha }}
122+
fail-on-cache-miss: true
123+
- name: 'Setup Node.js with pnpm cache'
124+
uses: actions/setup-node@v4
125+
with:
126+
node-version: 20
127+
cache: 'pnpm'
128+
# we are not using the github action for biome, but the package.json script. this makes sure we are using the same versions.
129+
- name: Run Biome
130+
run: pnpm run biome:ci
131+
132+
publish:
133+
# needs permissions to write tags to the repository
134+
permissions:
135+
contents: write
136+
needs:
137+
- build
138+
- test
139+
- lint
140+
env:
141+
NPM_TOKEN: ${{secrets.NPM_TOKEN }}
142+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN }}
143+
GH_TOKEN: ${{secrets.GITHUB_TOKEN }}
144+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN }}
145+
GH_USER: github-actions
146+
147+
runs-on: ubuntu-latest
148+
steps:
149+
- uses: actions/checkout@v4
150+
with:
151+
fetch-depth: 0
152+
token: ${{secrets.GITHUB_TOKEN }}
153+
- uses: pnpm/action-setup@v3
154+
with:
155+
version: 8
156+
- run: pnpm add -g pnpm
157+
- name: 'Setup Node.js with pnpm cache'
158+
uses: actions/setup-node@v4
159+
with:
160+
node-version: 20
161+
cache: 'pnpm'
162+
163+
- name: 'Restore build output'
164+
uses: actions/cache/restore@v4
165+
with:
166+
path: ${{ github.workspace }}
167+
key: ${{ runner.os }}-build-${{ github.sha }}-${{ github.run_id }}
168+
restore-keys: ${{ runner.os }}-build-${{ github.sha }}
169+
fail-on-cache-miss: true
170+
171+
- name: 'Setup git coordinates'
172+
run: |
173+
git remote set-url origin https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/${{ github.repository }}.git
174+
git config user.name $GH_USER
175+
git config user.email $GH_EMAIL
176+
177+
- name: 'Setup npm registry'
178+
run: |
179+
echo "@sd-jwt:registry=https://registry.npmjs.org/" > .npmrc
180+
echo "registry=https://registry.npmjs.org/" >> .npmrc
181+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
182+
npm whoami
183+
184+
- name: 'Publish latest version'
185+
run: pnpm publish:latest

.github/workflows/sync-next-with-latest.yml

-22
This file was deleted.

CONTRIBUTING.md

+9
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,12 @@ We use GitHub issues to track public bugs. Report a bug by opening a new issue i
4242
- What you expected would happen
4343
- What actually happens
4444
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
45+
46+
## Release procedure
47+
48+
Each PR to the `main` branch has to pass the `build`, `test`, `lint` and `code coverage` steps from the CI. The PR also needs a review from one authorized person.
49+
All commits needs to be signed to pass the DCO check.
50+
51+
After the PR is merged, a new `next` version is build and deployed to `npmjs` for all packages with the `next` tag.
52+
53+
The release of a new version is done by running the `release` workflow manually. This workflow can only be triggered successfully by an authorized person that is listed inside the `CODEOWNERS` file. The test and coverage steps are executed again and the new version is published to `npmjs` for all packages with the `latest` tag. The version number is calculated based on the commits since the last release and the `semver` rules.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
![Coverage](https://img.shields.io/codecov/c/github/openwallet-foundation-labs/sd-jwt-js)
22
![License](https://img.shields.io/github/license/openwallet-foundation-labs/sd-jwt-js.svg)
33
![NPM](https://img.shields.io/npm/v/%40sd-jwt%2Fcore)
4+
![NPM-Downloads](https://img.shields.io/endpoint?&url=https://runkit.io/thetarnav/combined-weekly-npm-downloads/1.0.3/@sd-jwt/core,@sd-jwt/types,@sd-jwt/decode,@sd-jwt/utils,@sd-jwt/sd-jwt-vc,@sd-jwt/crypto-nodejs,@sd-jwt/crypto-browser,@sd-jwt/hash&label=npm%20downloads&color=ff7724)
45
![Release](https://img.shields.io/github/v/release/openwallet-foundation-labs/sd-jwt-js)
56
![Stars](https://img.shields.io/github/stars/openwallet-foundation-labs/sd-jwt-js)
67

0 commit comments

Comments
 (0)