-
Notifications
You must be signed in to change notification settings - Fork 10
187 lines (183 loc) · 6.79 KB
/
release-main.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
name: Update Release PR or Release Versions and Publish
on:
push:
branches:
- main
# This is for .npmrc. Nx automatically creates an .npmrc before changesets runs
# and creates one itself, so we need to explicitly have one.
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
concurrency: commits-to-main
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout all commits
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup
uses: ./.github/actions/setup-all
with:
node_version: 20.10.0
go_version: 1.23.0
# The SDK is referenced via dist in the tsconfig.base.json
# because the next executor does not actually support
# buildLibsFromSource=false
# With this configuration NX does not build the SDK as expected
# when it is an app dependency
- name: Force build SDK
shell: bash
run: npx nx run sdk:build
- name: Build for publishing
shell: bash
run: npx nx run-many --target=build --configuration=production --all --parallel=5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
CCRI_TOKEN: ${{ secrets.CCRI_TOKEN }}
# If there are changesets, then we are in PR prep mode and will
# update the release pull request. Note that if there are no changesets
# this step will be skipped because no publish script is specified.
- name: Update release pull request
id: changesets
uses: changesets/action@v1
with:
commit: 'chore: release packages'
version: npm run version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Replace src code with dists for publishing
if: steps.changesets.outputs.hasChangesets == 'false'
run: ./scripts/replace-src-with-dists-for-publishing.sh
# If no changesets were detected in the PR prep step then we are in
# release/publish mode. Check for and publish any new versions to NPM.
- name: Publish to NPM and create GitHub releases
id: changesets_release
if: steps.changesets.outputs.hasChangesets == 'false'
uses: changesets/action@v1
with:
publish: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Release Go modules
# If a release was published, release the Go modules
if: steps.changesets_release.outputs.published == 'true'
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PAT_REPOSITORY_DISPATCH }}
repository: siafoundation/web
event-type: release-go
release-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout all commits
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup
uses: ./.github/actions/setup-all
with:
node_version: 20.10.0
go_version: 1.23.0
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# The SDK is referenced via dist in the tsconfig.base.json
# because the next executor does not actually support
# buildLibsFromSource=false
# With this configuration NX does not build the SDK as expected
# when it is an app dependency
- name: Force build SDK
shell: bash
run: npx nx run sdk:build
- name: Containers
shell: bash
run: npx nx run-many --target=container --configuration=production -all --parallel=5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
CCRI_TOKEN: ${{ secrets.CCRI_TOKEN }}
- name: Containers zen
shell: bash
run: npx nx run-many --target=container --configuration=production-testnet-zen -all --parallel=5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
CCRI_TOKEN: ${{ secrets.CCRI_TOKEN }}
# This job should always pass because the workflow is running run against code that
# was already linted and tested in PR.
# This runs in parallel to the build and release process as an extra check but does
# not actually block the release if job fails.
test-js:
runs-on: ubuntu-latest
steps:
- name: Checkout all commits
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup
uses: ./.github/actions/setup-all
with:
node_version: 20.10.0
go_version: 1.23.0
- name: Lint TypeScript
shell: bash
run: npx nx run-many --target=lint --all --parallel=5
# The SDK is referenced via dist in the tsconfig.base.json
# because the next executor does not actually support
# buildLibsFromSource=false
# With this configuration NX does not build the SDK as expected
# when it is an app dependency
- name: Force build SDK
shell: bash
run: npx nx run sdk:build
- name: Test TypeScript
shell: bash
run: npx nx run-many --target=test --all --parallel=5
# This job should always pass because the workflow is running run against code that
# was already linted and tested in PR.
# This runs in parallel to the build and release process as an extra check but does
# not actually block the release if job fails.
e2e:
uses: ./.github/workflows/e2e.yml
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# This job should always pass because the workflow is running run against code that
# was already linted and tested in PR.
# This runs in parallel to the build and release process as an extra check but does
# not actually block the release if job fails.
test-go:
# Run matrix since Go modules are used across all platforms
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
module: [./renterd, ./hostd, ./walletd]
steps:
- name: Checkout all commits
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Git
uses: ./.github/actions/setup-git
# Only Go setup is necessary for running Go tests
- name: Setup Go
uses: ./.github/actions/setup-go
with:
go_version: 1.23.0
- name: Lint Go
uses: golangci/golangci-lint-action@v4
with:
working-directory: ${{ matrix.module }}
skip-cache: true
- name: Test Go
uses: n8maninger/action-golang-test@v2
with:
args: '-race'
working-directory: ${{ matrix.module }}