-
Notifications
You must be signed in to change notification settings - Fork 0
212 lines (195 loc) · 7.39 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
on:
push:
tags:
- "*-rc*"
permissions:
contents: write
packages: write
jobs:
build:
uses: ./.github/workflows/build_shared.yml
with:
ref: ${{ github.ref }}
tag: ${{ github.ref_name }}
strip_rc: true
test-e2e-server:
needs: [build]
runs-on: ubuntu-latest
env:
NODE_ENV: test
E2E_TEST: "true"
DATABASE_URL: postgres://root:postgres@localhost:5432/badger_test
steps:
- uses: actions/checkout@v4
# - name: Use Node.js 18.x
# uses: actions/setup-node@v4
# with:
# node-version: 18.x
# cache: "yarn"
# cache-dependency-path: "yarn.lock"
# - name: Set ref in docker-compose
# run: sed -i "s/__RC_REF__/${{ github.ref_name }}/g" docker-compose-rc-test.yml
# - name: Start services
# run: docker compose -f docker-compose.yml -f docker-compose-rc-test.yml up -d
# - run: yarn install --immutable --inline-builds
# - uses: ./.github/steps/setup-playwright
# with:
# working-directory: ./server
# - name: Migrate database
# run: |
# yarn prisma:migrateProd
# - name: Retart services
# run: |
# docker compose -f docker-compose.yml -f docker-compose-rc-test.yml restart server jobrunner
# - name: Run Playwright tests
# run: yarn ${{ runner.debug && 'test:e2e:debug' || 'test:e2e' }}
# working-directory: ./server
# env:
# PLAYWRIGHT_HTML_REPORT: ${{ github.workspace }}/server/playwright-report
# - uses: actions/upload-artifact@v3
# if: failure()
# with:
# name: playwright-report-server
# path: ./server/playwright-report/
# retention-days: 30
test-desktop:
runs-on: windows-latest
needs: [build]
steps:
- uses: actions/checkout@v4
# - name: Use Node.js 18.x
# uses: actions/setup-node@v4
# with:
# node-version: 18.x
# cache: "yarn"
# cache-dependency-path: "yarn.lock"
# - name: Download Desktop build
# uses: actions/download-artifact@v4
# with:
# name: badger-desktop-windows
# - name: Install Badger
# run: |
# $version = "${{ github.ref_name }}" -replace "^v", "" -replace "-rc.*", ""
# Start-Process -FilePath "Badger Desktop-$version.exe" -ArgumentList "/S","/D=${{ runner.temp }}\badger" -Wait
# shell: pwsh
# - run: yarn install --immutable --inline-builds
# - name: Run tests
# run: yarn test:e2e --project=standalone
# working-directory: ./desktop
# env:
# TEST_APPLICATION_PATH: ${{ runner.temp }}\badger\Badger Desktop.exe
linear:
needs: [test-e2e-server, test-desktop]
runs-on: ubuntu-latest
outputs:
issue_id: ${{ steps.issue.outputs.issue_id }}
steps:
- name: Determine version number
run: echo "VERSION=$(echo '${{ github.ref_name }}' | sed 's/-rc.*//')" >> $GITHUB_ENV
- uses: actions/setup-node@v3
with:
node-version: "20.x"
- run: npm install @linear/sdk
- name: Create Linear release ticket
id: issue
uses: actions/github-script@v7
with:
script: |
const { LinearClient } = require('@linear/sdk');
const lin = new LinearClient({
accessToken: "${{ secrets.LINEAR_ACCESS_TOKEN }}"
});
const issueCreate = await lin.createIssue({
teamId: "${{ vars.LINEAR_TEAM_ID }}",
templateId: "${{ vars.LINEAR_RELEASE_ISSUE_TEMPLATE_ID }}",
stateId: "${{ vars.LINEAR_TODO_STATE_ID }}",
title: `Release v${process.env.VERSION}`,
});
if (!issueCreate.success) {
throw new Error(`Failed to create issue`);
}
await lin.createComment({
issueId: issueCreate.issue.id,
body: `Artifacts:
Server Docker image: \`ghcr.io/ystv/badger/server:${{ github.ref_name }}\`
Jobrunner Docker Image: \`ghcr.io/ystv/badger/jobrunner:${{ github.ref_name }}\`
Desktop Windows installer: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
Once testing is complete, please approve [this workflow](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
`.replace(/^\s*/gm, ''),
});
core.notice(`Release issue: ${issueCreate.issue.url}`);
core.setOutput('issue_id', issueCreate.issue.id);
release:
needs: [test-e2e-server, test-desktop, linear]
environment: release
runs-on: ubuntu-latest
steps:
- name: Determine version number
run: echo "VERSION=$(echo '${{ github.ref_name }}' | sed 's/-rc.*//')" >> $GITHUB_ENV
- name: Download Desktop build
uses: actions/download-artifact@v4
with:
pattern: badger-desktop-*
path: artifacts
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Re-tag and push Docker images
run: |
for img in server jobrunner; do
docker pull ghcr.io/ystv/badger/$img:${{ github.ref_name }}
docker tag ghcr.io/ystv/badger/$img:${{ github.ref_name }} ghcr.io/ystv/badger/$img:$VERSION
docker push ghcr.io/ystv/badger/$img:$VERSION
docker tag ghcr.io/ystv/badger/$img:${{ github.ref_name }} ghcr.io/ystv/badger/$img:latest
docker push ghcr.io/ystv/badger/$img:latest
done
shell: bash
- name: Create GitHub release
uses: actions/github-script@v7
id: release
with:
script: |
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
target_commitish: context.sha,
tag_name: process.env.VERSION,
name: process.env.VERSION,
draft: true,
generate_release_notes: true,
make_latest: "true"
});
core.setOutput('id', release.data.id)
core.setOutput('tag_name', release.data.tag_name)
- name: Upload artifacts
run: |
find artifacts -type f -exec gh release upload ${{ steps.release.outputs.tag_name }} {} \;
- name: Publish release
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ steps.release.outputs.id }},
draft: false
})
- uses: actions/setup-node@v3
with:
node-version: "20.x"
- run: npm install @linear/sdk
- name: Close Linear issue
uses: actions/github-script@v7
with:
script: |
const { LinearClient } = require('@linear/sdk');
const lin = new LinearClient({
accessToken: "${{ secrets.LINEAR_ACCESS_TOKEN }}"
});
await lin.updateIssue({
issueId: ${{ needs.linear.outputs.issue_id }},
stateId: "${{ vars.LINEAR_DONE_STATE_ID }}",
});