-
Notifications
You must be signed in to change notification settings - Fork 6
170 lines (163 loc) · 5.36 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
name: Release
on:
workflow_dispatch:
# Run every Sunday at 12:00 UTC
schedule:
- cron: '0 12 * * 0'
env:
CARGO_TERM_COLOR: always
ASSET_DIR: ${{ github.workspace }}/frontend/dist
SQLX_OFFLINE: "true"
jobs:
build:
name: Build
strategy:
matrix:
target:
- os: ubuntu-latest
name: x86_64-unknown-linux-musl
binary: backend/target/x86_64-unknown-linux-musl/release/abacus
- os: macos-latest
name: aarch64-apple-darwin
binary: backend/target/aarch64-apple-darwin/release/abacus
- os: windows-latest
name: x86_64-pc-windows-msvc
binary: backend/target/x86_64-pc-windows-msvc/release/abacus.exe
runs-on: ${{ matrix.target.os }}
defaults:
run:
working-directory: ./backend
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
working-directory: ./frontend
- name: Build
run: npm run build
working-directory: ./frontend
- name: Setup Rust
run: rustup update stable && rustup default stable
- name: Install target
run: rustup target add ${{ matrix.target.name }}
- name: Install musl
run: sudo apt-get update && sudo apt-get install -y musl-tools
if: matrix.target.os == 'ubuntu-latest'
- name: Run tests
run: cargo --locked test --release
- name: Build
run: cargo --locked build --release --features memory-serve --target=${{ matrix.target.name }}
- uses: actions/upload-artifact@v4
with:
name: abacus-${{ matrix.target.os }}
path: ${{ matrix.target.binary }}
playwright-d2d:
name: Playwright d2d tests (${{ matrix.os }}, ${{ matrix.shardIndex }}/${{ matrix.shardTotal }})
needs:
- build
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
shardIndex: [1, 2, 3]
shardTotal: [3]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps --no-shell
- name: Download abacus
uses: actions/download-artifact@v4
with:
name: abacus-${{ matrix.os }}
path: builds/backend
- name: make backend build executable
run: chmod a+x ../builds/backend/abacus
if: runner.os != 'Windows'
- name: Run DOM to Database e2e tests
run: npm run e2e:d2d -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
release:
name: Release
needs:
- build
- playwright-d2d
runs-on: ubuntu-latest
permissions:
# contents write permission is needed to push the tag
contents: write
steps:
- uses: actions/checkout@v4
- name: Determine release tag
run: |
VERSION=$(sed -n '/version\s*=\s*"\([^"]*\)"/{s//\1/p;q}' Cargo.toml)
BUILD_DATE=$(date -u +'%Y-%m-%d')
BUILD_DATE_SHORT=$(date -u +'%Y%m%d')
SHA_SHORT=$(git rev-parse --short HEAD)
TAG="v${VERSION}-alpha.${BUILD_DATE_SHORT}.${SHA_SHORT}"
echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV
echo "TAG=$TAG" >> $GITHUB_ENV
working-directory: backend
- name: Create release directory
run: mkdir -p release
- name: Download abacus
uses: actions/download-artifact@v4
with:
path: release/
- name: Rename binary
run: |
mv abacus-ubuntu-latest/abacus abacus-linux-${{ env.TAG}}
mv abacus-macos-latest/abacus abacus-macos-${{ env.TAG}}
mv abacus-windows-latest/abacus.exe abacus-windows-${{ env.TAG}}.exe
rmdir abacus-ubuntu-latest abacus-macos-latest abacus-windows-latest
working-directory: release
- name: Create a SHA256SUMS file
run: sha256sum -b * > SHA256SUMS
working-directory: release
- name: Create git tag
run: git tag $TAG
- name: Push git tag
run: git push origin $TAG
- name: Release
uses: softprops/action-gh-release@v2
with:
body: This is an alpha release of Abacus, commit ${{ github.sha }} on ${{ env.BUILD_DATE }}
tag_name: ${{ env.TAG }}
prerelease: true
target_commitish: "${{ github.sha }}"
files: release/*
token: ${{ secrets.GITHUB_TOKEN }}
name: Version ${{ env.TAG }}
deploy:
name: Deploy to abacus-test.nl
needs:
- build
- release
environment:
name: release
url: https://${{ github.sha }}.abacus-test.nl
permissions:
contents: read
deployments: write
runs-on: ubuntu-latest
steps:
- name: Download abacus
uses: actions/download-artifact@v4
with:
name: abacus-ubuntu-latest
- name: Upload binary to test server
run: |
curl -s \
-H "Authorization: Bearer ${{ secrets.ABACUS_TEST_API_KEY }}" \
-T ./abacus \
https://abacus-test.nl/etes/api/v1/executable/${{ github.sha }}/${{ github.sha }}