Skip to content

Commit d35fc28

Browse files
ci: add release workflow (#39)
1 parent 226d9bc commit d35fc28

File tree

5 files changed

+293
-211
lines changed

5 files changed

+293
-211
lines changed

.cargo/config.toml

Whitespace-only changes.

.github/dependabot.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ updates:
44
directory: "/"
55
schedule:
66
interval: "weekly"
7-
ignore:
8-
- dependency-name: "semver"
9-
- dependency-name: "crates-io"
10-
rebase-strategy: "auto"
7+
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/release.yml

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# A huge thanks to the helix-editor project for this
2+
# If you're here for inspiration, please go to the original source
3+
# https://github.com/helix-editor/helix/blob/master/.github/workflows/release.yml#L14-L18
4+
name: Release
5+
on:
6+
push:
7+
tags:
8+
- "[0-9]+.[0-9]+.[0-9]+"
9+
branches:
10+
- "ci-*"
11+
pull_request:
12+
paths:
13+
- ".github/workflows/release.yml"
14+
15+
env:
16+
preview: ${{ !startsWith(github.ref, 'refs/tags/') || github.repository != 'github-language-server/github-lsp' }}
17+
18+
jobs:
19+
dist:
20+
name: Dist
21+
env:
22+
CARGO: cargo
23+
TARGET_DIR: ./target
24+
RUST_BACKTRACE: 1
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
fail-fast: false # don't fail other jobs if one fails
28+
matrix:
29+
build: [x86_64-linux, x86_64-macos, x86_64-windows] #, x86_64-win-gnu, win32-msvc
30+
include:
31+
- build: x86_64-linux
32+
os: ubuntu-latest
33+
rust: stable
34+
target: x86_64-unknown-linux-gnu
35+
cross: false
36+
skip_tests: false
37+
- build: aarch64-linux
38+
os: ubuntu-latest
39+
rust: stable
40+
target: aarch64-unknown-linux-gnu
41+
cross: true
42+
skip_tests: false
43+
- build: x86_64-macos
44+
os: macos-latest
45+
rust: stable
46+
target: x86_64-apple-darwin
47+
cross: false
48+
skip_tests: false
49+
- build: x86_64-windows
50+
os: windows-latest
51+
rust: stable
52+
target: x86_64-pc-windows-msvc
53+
cross: false
54+
skip_tests: false
55+
- build: aarch64-macos
56+
os: macos-latest
57+
rust: stable
58+
target: aarch64-apple-darwin
59+
cross: false
60+
skip_tests: true
61+
62+
steps:
63+
- name: Checkout sources
64+
uses: actions/checkout@v4
65+
66+
- name: Install ${{ matrix.rust }} toolchain
67+
uses: dtolnay/rust-toolchain@master
68+
with:
69+
toolchain: ${{ matrix.rust }}
70+
target: ${{ matrix.target }}
71+
72+
- name: Install ssl
73+
if: "matrix.build == 'aarch64-linux'"
74+
run: |
75+
sudo apt-get update
76+
sudo apt-get -y install pkg-config libudev-dev libssl-dev
77+
78+
- name: Install Cross
79+
if: "matrix.cross"
80+
run: |
81+
cargo install cross --git https://github.com/cross-rs/cross.git --rev 47df5c76e7cba682823a0b6aa6d95c17b31ba63a
82+
echo "CARGO=cross" >> $GITHUB_ENV
83+
84+
- name: Run cargo test
85+
if: "!matrix.skip_tests"
86+
run: ${{ env.CARGO }} test --release --locked --target ${{ matrix.target }} --workspace
87+
88+
- name: Set profile.release.strip = true
89+
shell: bash
90+
run: |
91+
cat >> .cargo/config.toml <<EOF
92+
[profile.release]
93+
strip = true
94+
EOF
95+
96+
- name: Build release binary
97+
run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}
98+
99+
- name: Build archive
100+
shell: bash
101+
run: |
102+
mkdir -p dist
103+
if [ "${{ matrix.os }}" = "windows-2019" ]; then
104+
cp "target/${{ matrix.target }}/release/github-lsp.exe" "dist/"
105+
else
106+
cp "target/${{ matrix.target }}/release/github-lsp" "dist/"
107+
fi
108+
109+
- uses: actions/upload-artifact@v4
110+
with:
111+
name: bins-${{ matrix.build }}
112+
path: dist
113+
114+
publish:
115+
name: Publish
116+
needs: [dist]
117+
runs-on: ubuntu-latest
118+
steps:
119+
- name: Checkout sources
120+
uses: actions/checkout@v4
121+
122+
- uses: actions/download-artifact@v4
123+
124+
- name: Build archive
125+
shell: bash
126+
run: |
127+
set -ex
128+
129+
source="$(pwd)"
130+
131+
cd "$(mktemp -d)"
132+
mv $source/bins-* .
133+
mkdir dist
134+
135+
for dir in bins-* ; do
136+
platform=${dir#"bins-"}
137+
if [[ $platform =~ "windows" ]]; then
138+
exe=".exe"
139+
fi
140+
pkgname=github-lsp-$GITHUB_REF_NAME-$platform
141+
mkdir -p $pkgname
142+
cp $source/LICENSE $source/README.md $pkgname
143+
mv bins-$platform/github-lsp$exe $pkgname
144+
chmod +x $pkgname/github-lsp$exe
145+
146+
if [ "$exe" = "" ]; then
147+
tar cJf dist/$pkgname.tar.xz $pkgname
148+
else
149+
7z a -r dist/$pkgname.zip $pkgname
150+
fi
151+
done
152+
153+
tar cJf dist/github-lsp-$GITHUB_REF_NAME-source.tar.xz -C $source .
154+
mv dist $source/
155+
156+
- name: Upload binaries to release
157+
uses: svenstaro/upload-release-action@v2
158+
if: env.preview == 'false'
159+
with:
160+
repo_token: ${{ secrets.GITHUB_TOKEN }}
161+
file: dist/*
162+
file_glob: true
163+
tag: ${{ github.ref_name }}
164+
overwrite: true
165+
166+
- name: Upload binaries as artifact
167+
uses: actions/upload-artifact@v4
168+
if: env.preview == 'true'
169+
with:
170+
name: release
171+
path: dist/*

0 commit comments

Comments
 (0)