1+ name : Build and release
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+ build-and-test :
10+ name : Build and test
11+ runs-on : ubuntu-latest
12+ environment : test
13+ steps :
14+ - name : Checkout
15+ uses : actions/checkout@v4
16+
17+ - name : Install Foundry
18+ uses : foundry-rs/foundry-toolchain@v1
19+
20+ - uses : pnpm/action-setup@v4
21+ name : Install pnpm
22+ with :
23+ run_install : false
24+
25+ - name : Install Node.js
26+ uses : actions/setup-node@v4
27+ with :
28+ node-version : 20
29+ cache : ' pnpm'
30+
31+ - name : Install dependencies
32+ run : pnpm install
33+
34+ - name : Run tests
35+ run : pnpm test
36+
37+ semantic-release :
38+ needs : build-and-test
39+ if : " !contains(github.event.head_commit.message, '[skip ci]')"
40+
41+ name : Semantic Release
42+ runs-on : ubuntu-latest
43+ environment : staging
44+ permissions :
45+ contents : write # to be able to publish a GitHub release
46+ issues : write # to be able to comment on released issues
47+ pull-requests : write # to be able to comment on released pull requests
48+ id-token : write # to enable use of OIDC for npm provenance
49+
50+ steps :
51+ - name : Checkout
52+ uses : actions/checkout@v4
53+ with :
54+ fetch-depth : 0
55+ persist-credentials : false
56+
57+ - uses : pnpm/action-setup@v4
58+ name : Install pnpm
59+ with :
60+ run_install : false
61+
62+ - name : Install Node.js
63+ uses : actions/setup-node@v4
64+ with :
65+ node-version : 20
66+ cache : ' pnpm'
67+
68+ - name : Install dependencies
69+ run : pnpm install
70+
71+ - name : Semantic Release
72+ uses : cycjimmy/semantic-release-action@v4
73+ id : semantic # Need an `id` for output variables
74+ with :
75+ extra_plugins : |
76+ @semantic-release/commit-analyzer
77+ @semantic-release/release-notes-generator
78+ @semantic-release/changelog
79+ @semantic-release/github
80+ @semantic-release/npm
81+ env :
82+ GITHUB_TOKEN : ${{ secrets.GH_PA_TOKEN }}
83+ NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
84+
85+ - name : Do something when a new release published
86+ if : steps.semantic.outputs.new_release_published == 'true'
87+ run : |
88+ echo ${{ steps.semantic.outputs.new_release_version }}
89+ echo ${{ steps.semantic.outputs.new_release_major_version }}
90+ echo ${{ steps.semantic.outputs.new_release_minor_version }}
91+ echo ${{ steps.semantic.outputs.new_release_patch_version }}
0 commit comments