-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (92 loc) · 3.53 KB
/
lsp-release.yml
File metadata and controls
107 lines (92 loc) · 3.53 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
name: lsp-release
# Builds prebuilt `sqlshield-lsp` binaries and attaches them to the
# matching `sqlshield-lsp-vX.Y.Z` GitHub Release. The Zed extension's
# download fallback expects asset names of the form
# `sqlshield-lsp-{rust-target}.{tar.gz|zip}`.
on:
push:
tags: ['sqlshield-lsp-v*']
workflow_dispatch:
inputs:
tag:
description: 'Existing tag to attach assets to (e.g. sqlshield-lsp-v0.0.2)'
required: true
permissions:
contents: write
jobs:
build:
name: build (${{ matrix.target.rust }})
runs-on: ${{ matrix.target.runner }}
strategy:
fail-fast: false
matrix:
target:
- { runner: ubuntu-latest, rust: x86_64-unknown-linux-gnu, use_cross: false }
- { runner: ubuntu-latest, rust: aarch64-unknown-linux-gnu, use_cross: true }
- { runner: macos-14, rust: aarch64-apple-darwin, use_cross: false }
- { runner: macos-14, rust: x86_64-apple-darwin, use_cross: false }
- { runner: windows-latest, rust: x86_64-pc-windows-msvc, use_cross: false }
- { runner: windows-latest, rust: aarch64-pc-windows-msvc, use_cross: false }
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Add rust target
shell: bash
run: rustup target add ${{ matrix.target.rust }}
- uses: Swatinem/rust-cache@v2
with:
key: lsp-release-${{ matrix.target.rust }}
- name: Install cross
if: matrix.target.use_cross
run: cargo install cross --locked
- name: Build (cross)
if: matrix.target.use_cross
run: cross build -p sqlshield-lsp --release --target ${{ matrix.target.rust }}
- name: Build (native)
if: ${{ !matrix.target.use_cross }}
run: cargo build -p sqlshield-lsp --release --target ${{ matrix.target.rust }}
- name: Package
shell: bash
run: |
mkdir -p dist _stage
target=${{ matrix.target.rust }}
# Stage in a dedicated directory: the repo root already
# contains a `sqlshield-lsp/` directory (workspace member),
# so a bare `cp` would copy *into* that directory and tar
# would archive the whole crate instead of just the binary.
if [[ "${{ runner.os }}" == "Windows" ]]; then
cp target/$target/release/sqlshield-lsp.exe _stage/sqlshield-lsp.exe
7z a -tzip dist/sqlshield-lsp-$target.zip ./_stage/sqlshield-lsp.exe
else
cp target/$target/release/sqlshield-lsp _stage/sqlshield-lsp
chmod +x _stage/sqlshield-lsp
tar -C _stage -czf dist/sqlshield-lsp-$target.tar.gz sqlshield-lsp
fi
- uses: actions/upload-artifact@v4
with:
name: sqlshield-lsp-${{ matrix.target.rust }}
path: dist/*
if-no-files-found: error
upload:
name: upload assets
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: dist
pattern: sqlshield-lsp-*
merge-multiple: true
- name: Compute release tag
id: tag
run: |
if [[ -n "${{ inputs.tag }}" ]]; then
echo "ref=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "ref=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
fi
- uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.ref }}
files: dist/*
fail_on_unmatched_files: true