1
- name : CI
1
+ name : Create Releases
2
2
on :
3
- pull_request :
4
- branches :
5
- - master
6
- types :
7
- - opened
8
- - synchronize
3
+ workflow_dispatch :
4
+ inputs :
5
+ projects :
6
+ description : ' Package Bump'
7
+ required : true
8
+ default : ' json-api-nestjs,json-api-nestjs-sdk,nestjs-json-rpc,nestjs-json-rpc-sdk'
9
+ first-release :
10
+ description : ' Is first release?'
11
+ required : false
12
+ type : boolean
13
+ default : false
14
+ dry-run :
15
+ description : ' Is dry run?'
16
+ required : false
17
+ type : boolean
18
+ default : false
9
19
jobs :
10
- run -test :
11
- name : Try build and run unit test
20
+ build-and -test :
21
+ name : " Build and test"
12
22
runs-on : ubuntu-latest
23
+ permissions :
24
+ contents : " read"
25
+ actions : " read"
13
26
steps :
14
27
- uses : actions/checkout@v4
15
28
with :
16
29
fetch-depth : 0
17
30
- name : Npm install
18
31
uses : ./.github/actions
19
- - name : Get branch names.
20
- id : branch-names
21
- uses : tj-actions/branch-names@v8
32
+ - name : Get git hash
33
+ run : |
34
+ COMMIT=$(git show-ref --tags --hash | tail -n 1)
35
+ echo "NX_BASE=$(echo ${COMMIT})" >> $GITHUB_ENV
36
+ - name : Set GIST_SECRET to env
37
+ run : |
38
+ echo "GIST_SECRET=${{ secrets.GIST_SECRET }}" >> $GITHUB_ENV
39
+ echo "GIST_ID=${{ secrets.GIST_ID }}" >> $GITHUB_ENV
22
40
- name : Restore cached .nx
23
41
id : cache-nx-restore
24
42
uses : actions/cache/restore@v4
25
43
with :
26
44
path : |
27
45
.nx
28
- key : ${{ runner.os }}-nx-${{ steps.branch-names.outputs.current_branch }}
29
- - run : git branch --track main origin/master
46
+ key : ${{ runner.os }}-nx-master
30
47
- name : Test
31
48
env :
32
49
NX_REJECT_UNKNOWN_LOCAL_CACHE : 0
35
52
env :
36
53
NX_REJECT_UNKNOWN_LOCAL_CACHE : 0
37
54
run : npx nx affected -t build --exclude='json-api-front,json-api-server,json-api-server-e2e,json-shared-type,microorm-database,typeorm-database,@nestjs-json-api/source,type-for-rpc'
55
+ - name : Upload test coverage badge
56
+ run : npx nx affected -t upload-badge --exclude='json-api-front,json-api-server,shared-utils,json-api-server-e2e,json-shared-type,microorm-database,typeorm-database,@nestjs-json-api/source,type-for-rpc'
38
57
- name : Save cached .nx
39
58
id : cache-dependencies-save
40
59
uses : actions/cache/save@v4
46
65
runs-on : ubuntu-latest
47
66
name : Try run e2e test
48
67
needs :
49
- - run -test
68
+ - build-and -test
50
69
services :
51
70
# Label used to access the service container
52
71
postgres :
@@ -71,25 +90,49 @@ jobs:
71
90
fetch-depth : 0
72
91
- name : Npm install
73
92
uses : ./.github/actions
74
- - name : Get branch names.
75
- id : branch-names
76
- uses : tj-actions/branch-names@v8
77
93
- name : Restore cached .nx
78
94
id : cache-nx-restore
79
95
uses : actions/cache/restore@v4
80
96
with :
81
97
path : |
82
98
.nx
83
- key : ${{ runner.os }}-nx-${{ steps.branch-names.outputs.current_branch }}
99
+ key : ${{ runner.os }}-nx-master
84
100
- run : git branch --track main origin/master
85
101
- run : npm run typeorm migration:run
86
102
- run : npm run seed:run
87
103
- run : npx nx affected -t e2e --parallel=1
88
- - run : npx nx affected -t e2e-micro --parallel=1
89
104
- name : Save cached .nx
90
105
id : cache-dependencies-save
91
106
uses : actions/cache/save@v4
92
107
with :
93
108
path : |
94
109
.nx
95
110
key : ${{ steps.cache-nx-restore.outputs.cache-primary-key }}
111
+ bump-version :
112
+ name : " Bump version"
113
+ needs :
114
+ - run-e2e-test
115
+ runs-on : ubuntu-latest
116
+ permissions :
117
+ contents : " write"
118
+ actions : " read"
119
+ id-token : " write"
120
+ timeout-minutes : 10
121
+ steps :
122
+ - name : Checkout repository
123
+ uses : actions/checkout@v4
124
+ with :
125
+ fetch-depth : 0
126
+ token : ${{ secrets.PAT }}
127
+ - name : Npm install
128
+ uses : ./.github/actions
129
+ - name : Bump version
130
+ run : |
131
+ git config --global user.email "[email protected] "
132
+ git config --global user.name "GitHub Actions"
133
+ npx nx release --skip-publish --first-release=${{ github.event.inputs.first-release }} --projects=${{ github.event.inputs.projects }} --dry-run=${{ github.event.inputs.dry-run }}
134
+ shell : bash
135
+ env :
136
+ NODE_AUTH_TOKEN : ${{ secrets.NPM_ACCESS_TOKEN }}
137
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
138
+ NPM_CONFIG_PROVENANCE : true
0 commit comments