-
Notifications
You must be signed in to change notification settings - Fork 6
213 lines (176 loc) · 6 KB
/
pull-requests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: PR Prerelase
env:
NUGET_OUTPUT: ./Artifacts/NuGet
NUGET_SOURCE: https://nuget.pkg.github.com/cratis/index.json
DOTNET8_VERSION: "8.0.405"
DOTNET_VERSION: "9.0.x"
KERNEL_CACHE: "kernel-cache-${{ github.sha }}"
WORKBENCH_CACHE: "web-cache-${{ github.sha }}"
on:
pull_request:
types: [opened, edited, synchronize, reopened]
branches:
- "**"
paths:
- "Source/**"
- ".github/workflows/**"
jobs:
release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.release.outputs.version }}
publish: ${{ steps.release.outputs.should-publish }}
prerelease: ${{ steps.release.outputs.prerelease }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Release
id: release
uses: cratis/release-action@v1
kernel:
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
needs: [release]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .Net
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
${{ env.DOTNET8_VERSION }}
${{ env.DOTNET_VERSION }}
- uses: actions/cache@v3
id: kernel-output
with:
path: ./Source/Kernel/Server/out
key: ${{ env.KERNEL_CACHE }}
- name: Build
working-directory: ./Source/Kernel/Server
run: |
dotnet publish -c Debug -o out/x64
cp -r out/x64 out/arm64
workbench:
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
needs: [release]
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v3
id: workbench-output
with:
path: ./Source/Workbench/Web/wwwroot
key: ${{ env.WORKBENCH_CACHE }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: "https://registry.npmjs.org"
- uses: actions/cache@v3
id: yarn-cache
with:
path: |
**/node_modules
**/.eslintcache
**/yarn.lock
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Yarn install
working-directory: ./Source/Workbench/Web
run: yarn
- name: Build JS/TS
working-directory: ./Source/Workbench/Web
run: |
export NODE_OPTIONS="--max-old-space-size=4096"
yarn build
publish-nuget-packages:
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
needs: [release]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .Net
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
${{ env.DOTNET8_VERSION }}
${{ env.DOTNET_VERSION }}
- name: Remove any existing artifacts
run: rm -rf ${{ env.NUGET_OUTPUT }}
- name: Build
run: dotnet build --configuration Debug
- name: Add GitHub Package Registry to NuGet
run: dotnet nuget add source --name github --username cratis --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text ${{ env.NUGET_SOURCE }}
- name: Create NuGet packages
run: dotnet pack --no-build --configuration Debug -o ${{ env.NUGET_OUTPUT }} -p:PackageVersion=${{ needs.release.outputs.version }}
- name: Push NuGet packages
run: dotnet nuget push '${{ env.NUGET_OUTPUT }}/*.nupkg' --skip-duplicate --timeout 900 --api-key ${{ secrets.GITHUB_TOKEN }} --source "github"
- name: Add comment for NuGet packages
uses: mshick/add-pr-comment@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: |
NuGet packages for this PR, e.g. Cratis:
https://github.com/cratis/chronicle/packages/1655206?version=${{ needs.release.outputs.version }}
allow-repeats: false
publish-docker:
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
needs: [workbench, kernel, release]
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v3
id: kernel-output
with:
path: ./Source/Kernel/Server/out
key: ${{ env.KERNEL_CACHE }}
- uses: actions/cache@v3
id: workbench-output
with:
path: ./Source/Workbench/Web/wwwroot
key: ${{ env.WORKBENCH_CACHE }}
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Login to GitHub Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Development Docker Image
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Docker/Development/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/cratis/chronicle:${{ needs.release.outputs.version }}
build-args: |
VERSION=${{ needs.release.outputs.version }}
ENTRYPOINT=pr_entrypoint.sh
- name: Add comment for Docker image
uses: mshick/add-pr-comment@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: |
Docker Image for this PR:
https://ghcr.io/cratis/chronicle:${{ needs.release.outputs.version }}
docker run ghcr.io/cratis/chronicle:${{ needs.release.outputs.version }}
allow-repeats: false