-
Notifications
You must be signed in to change notification settings - Fork 114
270 lines (228 loc) Β· 9.28 KB
/
release.yml
File metadata and controls
270 lines (228 loc) Β· 9.28 KB
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
name: Release Binary
on:
workflow_dispatch:
permissions:
contents: write
env:
# Need these guys for cross-compilation
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc
jobs:
# windows does not run git cliff so we need to do it here
extract_version:
name: Extract Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up git-cliff
uses: kenji-miyake/setup-git-cliff@v1
- name: Set version name
id: set_version
run: echo "version=$(git cliff --bumped-version)" >> "$GITHUB_OUTPUT"
wasm:
name: Build & Test WASM
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Setup Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@main
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.11"
- name: Install dependencies
run: bun install
- name: Build WASM
run: nix develop --command bash -c "bun run build"
working-directory: packages/@postgres-language-server/wasm
- name: Run Tests
run: bun test
working-directory: packages/@postgres-language-server/wasm
- name: Install Playwright
run: bun run test:e2e:install
working-directory: packages/@postgres-language-server/wasm
- name: Run E2E Tests
run: bun run test:e2e
working-directory: packages/@postgres-language-server/wasm
- name: Upload WASM Artifacts
uses: actions/upload-artifact@v4
with:
name: wasm
path: |
packages/@postgres-language-server/wasm/wasm/pgls.js
packages/@postgres-language-server/wasm/wasm/pgls.wasm
if-no-files-found: error
build_and_test:
name: Build & Test for ${{ matrix.config.target }}
needs: extract_version
strategy:
matrix:
config:
- { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu }
- { os: ubuntu-22.04, target: aarch64-unknown-linux-gnu }
- { os: macos-14, target: x86_64-apple-darwin }
- { os: macos-14, target: aarch64-apple-darwin }
- { os: windows-2022, target: x86_64-pc-windows-msvc }
- { os: windows-2022, target: aarch64-pc-windows-msvc }
- { os: ubuntu-22.04, target: x86_64-unknown-linux-musl }
runs-on: ${{ matrix.config.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.config.target }}
- uses: Swatinem/rust-cache@v2
id: rust-cache
# The Aarch64 Linux is a special snowflake, we need to install its toolchain
- name: Install arm64 toolchain
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Install musl toolchain
if: matrix.config.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- uses: actions/cache@v5
with:
path: |
~/.cargo/bin/tree-sitter
target/**/build/pgls_treesitter_grammar-*/out/generated
key: ${{ runner.os }}-tree-sitter-${{ hashFiles('.tree-sitter-cli-version', 'crates/pgls_treesitter_grammar/grammar.js', 'crates/pgls_treesitter_grammar/tree-sitter.json', 'rust-toolchain.toml', 'Cargo.lock') }}
- name: Setup tree-sitter
run: command -v tree-sitter || cargo install tree-sitter-cli --version "$(cat .tree-sitter-cli-version)" --locked
shell: bash
- name: Setup Postgres
uses: ./.github/actions/setup-postgres
- name: π§ͺ Run Tests
run: cargo test --release
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
- name: π οΈ Run Build
run: cargo build -p pgls_cli --release --target ${{ matrix.config.target }}
env:
# Strip all debug symbols from the resulting binaries
RUSTFLAGS: "-C strip=symbols -C codegen-units=1"
# Inline the version in the CLI binary
PGT_VERSION: ${{ needs.extract_version.outputs.version }}
# windows is a special snowflake too, it saves binaries as .exe
- name: π¦ Name the Binary
if: matrix.config.os == 'windows-2022'
run: |
mkdir dist
# deprecated
cp target/${{ matrix.config.target }}/release/postgrestools.exe ./dist/postgrestools_${{ matrix.config.target }}.exe
cp target/${{ matrix.config.target }}/release/postgres-language-server.exe ./dist/postgres-language-server_${{ matrix.config.target }}.exe
- name: π¦ Name the Binary
if: matrix.config.os != 'windows-2022'
run: |
mkdir dist
# deprecated
cp target/${{ matrix.config.target }}/release/postgrestools ./dist/postgrestools_${{ matrix.config.target }}
cp target/${{ matrix.config.target }}/release/postgres-language-server ./dist/postgres-language-server_${{ matrix.config.target }}
# It is not possible to return the artifacts from the matrix jobs individually: Matrix outputs overwrite each other.
# A common workaround is to upload and download the resulting artifacts.
- name: π Upload Artifacts (deprecated)
id: upload-artifacts-deprecated
uses: actions/upload-artifact@v4
with:
name: postgrestools_${{ matrix.config.target }}
path: ./dist/postgrestools_*
# The default compression level is 6; this took the binary down from 350 to 330MB.
# It is recommended to use a lower level for binaries, since the compressed result is not much smaller,
# and the higher levels of compression take much longer.
compression-level: 2
if-no-files-found: error
# It is not possible to return the artifacts from the matrix jobs individually: Matrix outputs overwrite each other.
# A common workaround is to upload and download the resulting artifacts.
- name: π Upload Artifacts
id: upload-artifacts
uses: actions/upload-artifact@v4
with:
name: postgres-language-server_${{ matrix.config.target }}
path: ./dist/postgres-language-server_*
# The default compression level is 6; this took the binary down from 350 to 330MB.
# It is recommended to use a lower level for binaries, since the compressed result is not much smaller,
# and the higher levels of compression take much longer.
compression-level: 2
if-no-files-found: error
create_changelog_and_release:
runs-on: ubuntu-latest
needs: [extract_version, build_and_test, wasm]
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
# we need all commits to create a changelog
fetch-depth: 0
- name: π Create Changelog
uses: orhun/git-cliff-action@v4
id: create_changelog
with:
config: cliff.toml
args: --bump --unreleased
env:
GITHUB_REPO: ${{ github.repository }}
- name: Ensure tag matches
if: steps.create_changelog.outputs.version != needs.extract_version.outputs.version
run: |
echo "Tag does not match: ${{ steps.create_changelog.outputs.version }} vs ${{ needs.extract_version.outputs.version }}"
exit 1
- name: π Download Artifacts (deprecated)
uses: actions/download-artifact@v4
id: download-deprecated
with:
merge-multiple: true
pattern: postgrestools_*
- name: π Download Artifacts
uses: actions/download-artifact@v4
id: download
with:
merge-multiple: true
pattern: postgres-language-server_*
- name: π Download WASM Artifacts
uses: actions/download-artifact@v4
with:
name: wasm
path: wasm-assets
- name: Prepare WASM Assets
run: |
cp wasm-assets/pgls.js ./pgls.js
cp wasm-assets/pgls.wasm ./pgls.wasm
- name: π Create Release
uses: softprops/action-gh-release@v2
id: create-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: ${{ steps.create_changelog.outputs.content }}
tag_name: ${{ steps.create_changelog.outputs.version }}
files: |
postgrestools_*
postgres-language-server_*
pgls.js
pgls.wasm
docs/schema.json
fail_on_unmatched_files: true
draft: true
- name: β
Output Link to Workflow Summary
run: |
{
echo "# π Release completed!"
echo ""
echo "Here is the URL to the Release Draft:"
echo ""
echo "[Link](${{ steps.create-release.outputs.url }})"
echo ""
} >> "$GITHUB_STEP_SUMMARY"