-
Notifications
You must be signed in to change notification settings - Fork 6
194 lines (189 loc) · 5.72 KB
/
release.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
name: Release Keel
on:
push:
branches:
- next
- prerelease
workflow_dispatch:
inputs:
branch:
required: true
type: choice
default: main
options:
- main
- next
- prerelease
jobs:
instantiate:
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.assign-branch.outputs.BRANCH }}
channel: ${{ steps.assign-channel.outputs.CHANNEL }}
steps:
- name: Assign branch
id: assign-branch
shell: bash
run: |
if ${{ github.event_name == 'workflow_dispatch' }}
then
echo "Set branch to '${{ inputs.branch }}' for manual trigger"
echo "BRANCH=${{ inputs.branch }}" >> $GITHUB_OUTPUT
elif ${{ github.event_name == 'push' }}
then
echo "Set branch to '${{ github.ref_name }}' for push trigger"
echo "BRANCH=${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "Unhandled trigger"
fi
- name: Assign channel
id: assign-channel
shell: bash
run: |
if ${{ steps.assign-branch.outputs.BRANCH == 'main' }}
then
echo "Set channel to 'latest' for main branch"
echo "CHANNEL=latest" >> $GITHUB_OUTPUT
else
echo "Set channel to '${{ steps.assign-branch.outputs.BRANCH }}'"
echo "CHANNEL=${{ steps.assign-branch.outputs.BRANCH }}" >> $GITHUB_OUTPUT
fi
semantic-release:
needs: instantiate
runs-on: ubuntu-latest
outputs:
is_published: ${{ steps.semantic.outputs.new_release_published }}
new_version: ${{ steps.semantic.outputs.new_release_version }}
steps:
- name: With branch
shell: bash
run: |
echo ${{ needs.instantiate.outputs.branch }}
- name: Instantiation check
if: ${{ needs.instantiate.outputs.branch == '' || needs.instantiate.outputs.channel == '' }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('branch or channel not set')
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
ref: ${{ needs.instantiate.outputs.branch }}
fetch-depth: 0
- name: Semantic Release
id: semantic
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 21.1.1
extra_plugins: |
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.KEEL_CI_SEMANTIC_RELEASE }}
- name: Version tag created
run: |
echo v${{ steps.semantic.outputs.new_release_version }}
go-releaser:
needs:
- semantic-release
if: ${{ needs.semantic-release.outputs.is_published }}
runs-on: ubuntu-latest
steps:
- name: With version
shell: bash
run: |
echo ${{ needs.semantic-release.outputs.new_version }}
- name: Instantiation check
if: ${{ needs.semantic-release.outputs.new_version == '' }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('new_version not set')
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
ref: v${{ needs.semantic-release.outputs.new_version }}
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: Run goreleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.KEEL_CI_SEMANTIC_RELEASE }}
npm-publish:
needs:
- instantiate
- semantic-release
- go-releaser
if: ${{ needs.semantic-release.outputs.is_published }}
runs-on: ubuntu-latest
strategy:
matrix:
package:
[
"wasm",
"functions-runtime",
"testing-runtime",
"client-react",
"client-react-query",
"keel"
]
steps:
- name: With version and channel
shell: bash
run: |
echo ${{ needs.semantic-release.outputs.new_version }}
echo ${{ needs.instantiate.outputs.channel }}
- name: Instantiation check
if: ${{ needs.semantic-release.outputs.new_version == '' || needs.instantiate.outputs.channel == '' }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('new_version or channel not set')
- uses: actions/setup-go@v3
with:
go-version: "1.20"
- uses: actions/setup-node@v3
with:
node-version: 18.12.1
token: ${{ secrets.NPM_TOKEN }}
- uses: pnpm/[email protected]
with:
version: 8.10.0
- name: Checkout
uses: actions/checkout@v3
with:
ref: v${{ needs.semantic-release.outputs.new_version }}
fetch-depth: 0
- name: "Update package.json version ${{ matrix.package }}"
uses: reedyuk/[email protected]
with:
version: ${{ needs.semantic-release.outputs.new_version }}
package: ./packages/${{ matrix.package }}
- name: Install Go deps
if: ${{ matrix.package == 'wasm' }}
run: go mod download
- name: Generate wasm binary
if: ${{ matrix.package == 'wasm' }}
run: make wasm
- name: Install ${{ matrix.package }} publish dependencies
working-directory: ./packages/${{ matrix.package }}
run: pnpm install --frozen-lockfile
- name: NPM Publish ${{ matrix.package }}
uses: JS-DevTools/npm-publish@v2
with:
token: ${{ secrets.NPM_TOKEN }}
tag: ${{ needs.instantiate.outputs.channel }}
package: ./packages/${{ matrix.package }}
dry-run: false
strategy: all
ignore-scripts: false
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}