Skip to content

Commit

Permalink
Build .vsix per target platform (#15)
Browse files Browse the repository at this point in the history
* working draft

* add bin/ to gitignore

* add github actions for packaging

* make vsce a devDependency

* fix typo

* fix order of building and cleaning intermediary files

* fix macos -> darwin typo

* fix wrong environment variables

* fix upload-artifact@v3 deprecation

* fix setup-go caching fails
  • Loading branch information
rtk0c authored Nov 14, 2024
1 parent 1b08711 commit 7d651f2
Show file tree
Hide file tree
Showing 7 changed files with 3,730 additions and 117 deletions.
46 changes: 0 additions & 46 deletions .github/workflows/go.yml

This file was deleted.

61 changes: 61 additions & 0 deletions .github/workflows/vsix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Package VSIX

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
cache-dependency-path: |
server/go.sum
- name: Prepare building environment
run: |
cd client
npm install
- name: Build for Linux x86_64
run: |
cd client
GOOS=linux GOARCH=amd64 npx vsce package -t linux-x64 -o vls-linux.vsix
rm -r bin
- name: Upload Linux x86_64 artifact
uses: actions/upload-artifact@v4
with:
name: vls-linux-amd64
path: client/vls-linux.vsix

- name: Build for Windows x86_64
run: |
cd client
GOOS=windows GOARCH=amd64 npx vsce package -t win32-x64 -o vls-windows.vsix
rm -r bin
- name: Upload Windows x86_64 artifact
uses: actions/upload-artifact@v4
with:
name: vls-windows-amd64
path: client/vls-windows.vsix

- name: Build for macOS x86_64
run: |
cd client
GOOS=darwin GOARCH=amd64 npx vsce package -t darwin-x64 -o vls-darwin.vsix
rm -r bin
- name: Upload macOS x86_64 artifact
uses: actions/upload-artifact@v4
with:
name: vls-darwin-amd64
path: client/vls-darwin.vsix
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dist-newstyle/
node_modules/
bun.lockb
bin/
out/
dist/
client/LICENSE
Expand Down
3 changes: 2 additions & 1 deletion client/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
.vscode/
.vscode-test/
SECURITY.md
bin/
build/
codereview.cfg
docs/
Expand All @@ -23,4 +22,6 @@ test/
third_party/
tools/
tsconfig.json
eslint.config.mjs
build.mjs
typings/
37 changes: 37 additions & 0 deletions client/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { spawn } from "child_process";
import * as path from "path";
import * as fs from "fs";
const fsp = fs.promises;
import * as process from "process";
import { fileURLToPath } from 'url';

function getExecutableFilename(basename) {
if (process.env["GOOS"] == "windows") {
return basename + ".exe";
} else {
return basename;
}
}

const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);

// cd to repository root
process.chdir(path.join(dirname, ".."));

// Misc resource files
fsp.copyFile("README.md", path.join("client", "README.md"));
fsp.copyFile("LICENSE", path.join("client", "LICENSE"));

const goBuild = spawn(
"go",
["build", "-o", path.resolve("client", "bin", getExecutableFilename("verilog_language_server"))],
// Target OS and architecture should be specified to the node process running this script, e.g.
// bash -c 'GOOS=windows GOARCH=amd64 node build.mjs'
{ cwd: "server" },
);
goBuild.on('exit', exitCode => {
if (exitCode != 0) {
throw `go build failed with exit code ${exitCode}`;
}
});
Loading

0 comments on commit 7d651f2

Please sign in to comment.