Skip to content

Commit

Permalink
Prepare LSP builds
Browse files Browse the repository at this point in the history
  • Loading branch information
kossnocorp committed Jan 2, 2025
1 parent e76e393 commit 4b7d17a
Show file tree
Hide file tree
Showing 36 changed files with 500 additions and 306 deletions.
147 changes: 74 additions & 73 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,76 +25,77 @@ jobs:
- name: Run tests
run: cargo nextest run

build:
needs:
- test

runs-on: ${{ matrix.os }}

strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
cli-name: gt
lsp-name: gts

- os: macos-latest
target: x86_64-apple-darwin
cli-name: gt
lsp-name: gts

- os: windows-latest
target: x86_64-pc-windows-msvc
cli-name: gt.exe
lsp-name: gts.exe

steps:
- name: Check out repo
uses: actions/checkout@v4

- name: Set up Rust
uses: ./.github/actions/rust-setup

- name: Cache target
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-target-${{ matrix.target }}-${{ hashFiles('cli/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-target-${{ matrix.target }}-
- name: Add target
run: rustup target add ${{ matrix.target }}

- name: Build CLI
working-directory: cli
run: cargo build --release --target ${{ matrix.target }}

- name: Build LSP
working-directory: lsp
run: cargo build --release --target ${{ matrix.target }}

- name: Archive binaries
if: runner.os != 'Windows'
run: |
tar -czvf ${{ matrix.cli-name }}-${{ matrix.os }}.tar.gz -C target/${{ matrix.target }}/release ${{ matrix.cli-name }}
tar -czvf ${{ matrix.lsp-name }}-${{ matrix.os }}.tar.gz -C target/${{ matrix.target }}/release ${{ matrix.lsp-name }}
- name: Archive binaries
if: runner.os == 'Windows'
run: |
Compress-Archive -Path target\${{ matrix.target }}\release\${{ matrix.cli-name }} -DestinationPath ${{ matrix.cli-name }}-${{ matrix.os }}.zip
Compress-Archive -Path target\${{ matrix.target }}\release\${{ matrix.lsp-name }} -DestinationPath ${{ matrix.lsp-name }}-${{ matrix.os }}.zip
- name: Upload CLI binaries
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.cli-name }}-${{ matrix.os }}
path: ${{ matrix.cli-name }}-${{ matrix.os }}.*

- name: Upload LSP binaries
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.lsp-name }}-${{ matrix.os }}
path: ${{ matrix.lsp-name }}-${{ matrix.os }}.*
# [TODO] Remove or reenable with practical setup
# build:
# needs:
# - test

# runs-on: ${{ matrix.os }}

# strategy:
# matrix:
# include:
# - os: ubuntu-latest
# target: x86_64-unknown-linux-gnu
# cli-name: gt
# lsp-name: gts

# - os: macos-latest
# target: x86_64-apple-darwin
# cli-name: gt
# lsp-name: gts

# - os: windows-latest
# target: x86_64-pc-windows-msvc
# cli-name: gt.exe
# lsp-name: gts.exe

# steps:
# - name: Check out repo
# uses: actions/checkout@v4

# - name: Set up Rust
# uses: ./.github/actions/rust-setup

# - name: Cache target
# uses: actions/cache@v4
# with:
# path: target
# key: ${{ runner.os }}-target-${{ matrix.target }}-${{ hashFiles('cli/Cargo.lock') }}
# restore-keys: |
# ${{ runner.os }}-target-${{ matrix.target }}-

# - name: Add target
# run: rustup target add ${{ matrix.target }}

# - name: Build CLI
# working-directory: cli
# run: cargo build --release --target ${{ matrix.target }}

# - name: Build LSP
# working-directory: lsp
# run: cargo build --release --target ${{ matrix.target }}

# - name: Archive binaries
# if: runner.os != 'Windows'
# run: |
# tar -czvf ${{ matrix.cli-name }}-${{ matrix.os }}.tar.gz -C target/${{ matrix.target }}/release ${{ matrix.cli-name }}
# tar -czvf ${{ matrix.lsp-name }}-${{ matrix.os }}.tar.gz -C target/${{ matrix.target }}/release ${{ matrix.lsp-name }}

# - name: Archive binaries
# if: runner.os == 'Windows'
# run: |
# Compress-Archive -Path target\${{ matrix.target }}\release\${{ matrix.cli-name }} -DestinationPath ${{ matrix.cli-name }}-${{ matrix.os }}.zip
# Compress-Archive -Path target\${{ matrix.target }}\release\${{ matrix.lsp-name }} -DestinationPath ${{ matrix.lsp-name }}-${{ matrix.os }}.zip

# - name: Upload CLI binaries
# uses: actions/upload-artifact@v4
# with:
# name: ${{ matrix.cli-name }}-${{ matrix.os }}
# path: ${{ matrix.cli-name }}-${{ matrix.os }}.*

# - name: Upload LSP binaries
# uses: actions/upload-artifact@v4
# with:
# name: ${{ matrix.lsp-name }}-${{ matrix.os }}
# path: ${{ matrix.lsp-name }}-${{ matrix.os }}.*
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
target
node_modules
/tmp
11 changes: 5 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[target.x86_64-apple-darwin]
image = "ghcr.io/cross-rs/x86_64-apple-darwin-cross:local"

[target.aarch64-apple-darwin]
image = "ghcr.io/cross-rs/aarch64-apple-darwin-cross:local"

[target.aarch64-pc-windows-msvc]
image = "ghcr.io/cross-rs/aarch64-pc-windows-msvc-cross:local"

[target.x86_64-pc-windows-msvc]
image = "ghcr.io/cross-rs/x86_64-pc-windows-msvc-cross:local"
3 changes: 3 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ test-watch:

version version:
cargo release version {{version}} --exclude literals --exclude genotype_runtime --execute
cd lsp && just version {{version}}
# [TODO] Include into the release process?
# cd vscode && just version {{version}}

publish:
cargo release publish --exclude literals --exclude genotype_runtime --execute
2 changes: 2 additions & 0 deletions lsp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
npm/*/bin/*
!npm/*/bin/.gitkeep
56 changes: 55 additions & 1 deletion lsp/Justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,59 @@
install:
cargo install cross

test:
cargo test

test-watch:
cargo watch -x test
cargo watch -x test

build:
# aarch64-apple-darwin
cross build --release --target aarch64-apple-darwin --target-dir target
cp target/aarch64-apple-darwin/release/gts npm/darwin-arm64/bin/
chmod +x npm/darwin-arm64/bin/gts
# x86_64-apple-darwin
cross build --release --target x86_64-apple-darwin --target-dir target
cp target/x86_64-apple-darwin/release/gts npm/darwin-x64/bin/
chmod +x npm/darwin-x64/bin/gts
# aarch64-unknown-linux-gnu
cross build --release --target aarch64-unknown-linux-gnu --target-dir target
cp target/aarch64-unknown-linux-gnu/release/gts npm/linux-arm64/bin/
chmod +x npm/linux-arm64/bin/gts
# x86_64-unknown-linux-gnu
cross build --release --target x86_64-unknown-linux-gnu --target-dir target
cp target/aarch64-unknown-linux-gnu/release/gts npm/linux-x64/bin/
chmod +x npm/linux-x64/bin/gts
# aarch64-pc-windows-msvc
cross build --release --target aarch64-pc-windows-msvc --target-dir target
cp target/aarch64-pc-windows-msvc/release/gts.exe npm/win32-x64/bin/
# x86_64-pc-windows-msvc
cross build --release --target x86_64-pc-windows-msvc --target-dir target
cp target/x86_64-pc-windows-msvc/release/gts.exe npm/win32-arm64/bin/

version version:
npm version {{version}}
cd npm/darwin-arm64 && npm version {{version}}
cd npm/darwin-x64 && npm version {{version}}
cd npm/linux-arm64 && npm version {{version}}
cd npm/linux-x64 && npm version {{version}}
cd npm/win32-x64 && npm version {{version}}
cd npm/win32-arm64 && npm version {{version}}

publish: build
cd npm/darwin-arm64 && npm publish --access public
cd npm/darwin-x64 && npm publish --access public
cd npm/linux-arm64 && npm publish --access public
cd npm/linux-x64 && npm publish --access public
cd npm/win32-x64 && npm publish --access public
cd npm/win32-arm64 && npm publish --access public
npm publish

publish-next: build
cd npm/darwin-arm64 && pnpm publish --tag next --access public
cd npm/darwin-x64 && pnpm publish --tag next --access public
cd npm/linux-arm64 && pnpm publish --tag next --access public
cd npm/linux-x64 && pnpm publish --tag next --access public
cd npm/win32-x64 && pnpm publish --tag next --access public
cd npm/win32-arm64 && pnpm publish --tag next --access public
npm publish --tag next
3 changes: 3 additions & 0 deletions lsp/npm/darwin-arm64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `@genotype-lsp/darwin-arm64`

This is the **aarch64-apple-darwin** binary for `genotype-lsp`
Empty file.
18 changes: 18 additions & 0 deletions lsp/npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@genotype-lsp/darwin-arm64",
"version": "0.6.0-alpha.1",
"os": [
"darwin"
],
"cpu": [
"arm64"
],
"files": [
"bin/gts",
"README.md"
],
"license": "MIT",
"scripts": {
"prepublish": "node -e \"require('fs').lstatSync('bin/gts')\""
}
}
3 changes: 3 additions & 0 deletions lsp/npm/darwin-x64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `@genotype-lsp/darwin-x64`

This is the **x86_64-apple-darwin** binary for `genotype-lsp`
Empty file added lsp/npm/darwin-x64/bin/.gitkeep
Empty file.
18 changes: 18 additions & 0 deletions lsp/npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@genotype-lsp/darwin-x64",
"version": "0.6.0-alpha.1",
"os": [
"darwin"
],
"cpu": [
"x64"
],
"files": [
"bin/gts",
"README.md"
],
"license": "MIT",
"scripts": {
"prepublish": "node -e \"require('fs').lstatSync('bin/gts')\""
}
}
3 changes: 3 additions & 0 deletions lsp/npm/linux-arm64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `@genotype-lsp/linux-arm64`

This is the **aarch64-unknown-linux-gnu** binary for `genotype-lsp`
Empty file.
18 changes: 18 additions & 0 deletions lsp/npm/linux-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@genotype-lsp/linux-arm64",
"version": "0.6.0-alpha.1",
"os": [
"linux"
],
"cpu": [
"arm64"
],
"files": [
"bin/gts",
"README.md"
],
"license": "MIT",
"scripts": {
"prepublish": "node -e \"require('fs').lstatSync('bin/gts')\""
}
}
3 changes: 3 additions & 0 deletions lsp/npm/linux-x64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `@genotype-lsp/linux-x64`

This is the **x86_64-unknown-linux-gnu** binary for `genotype-lsp`
Empty file added lsp/npm/linux-x64/bin/.gitkeep
Empty file.
18 changes: 18 additions & 0 deletions lsp/npm/linux-x64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@genotype-lsp/linux-x64",
"version": "0.6.0-alpha.1",
"os": [
"linux"
],
"cpu": [
"x64"
],
"files": [
"bin/gts",
"README.md"
],
"license": "MIT",
"scripts": {
"prepublish": "node -e \"require('fs').lstatSync('bin/gts')\""
}
}
3 changes: 3 additions & 0 deletions lsp/npm/win32-arm64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `@genotype-lsp/win32-msvc-arm64`

This is the **aarch64-pc-windows-msvc** binary for `genotype-lsp`
Empty file.
18 changes: 18 additions & 0 deletions lsp/npm/win32-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@genotype-lsp/win32-arm64",
"version": "0.6.0-alpha.1",
"os": [
"win32"
],
"cpu": [
"arm64"
],
"files": [
"bin/gts.exe",
"README.md"
],
"license": "MIT",
"scripts": {
"prepublish": "node -e \"require('fs').lstatSync('bin/gts.exe')\""
}
}
3 changes: 3 additions & 0 deletions lsp/npm/win32-x64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `@genotype-lsp/win32-x64`

This is the **x86_64-pc-windows-msvc** binary for `genotype-lsp`
Empty file added lsp/npm/win32-x64/bin/.gitkeep
Empty file.
Loading

0 comments on commit 4b7d17a

Please sign in to comment.