fix(ci-cd): Fix ci:cd

This commit is contained in:
Myzel394 2024-10-20 13:36:25 +02:00
parent 6aceec2c06
commit c42329093e
No known key found for this signature in database
GPG Key ID: ED20A1D1D423AF3F
2 changed files with 71 additions and 40 deletions

View File

@ -60,7 +60,7 @@ jobs:
build-extension:
name: Build extension for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
needs:
# Wait for server to build so that we know the checks have passed
- build-server
@ -68,26 +68,26 @@ jobs:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
cross: false
- target: aarch64-apple-darwin
os: macos-latest
cross: false
- goos: linux
goarch: amd64
vscode_target: linux-x64
- goos: linux
goarch: arm64
vscode_target: linux-arm64
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
cross: false
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
cross: false
- goos: darwin
goarch: amd64
vscode_target: darwin-x64
- goos: darwin
goarch: arm64
vscode_target: darwin-arm64
# - target: x86_64-pc-windows-msvc
# os: windows-latest
# cross: false
# - target: aarch64-pc-windows-msvc
# os: windows-latest
# cross: false
- goos: windows
goarch: amd64
vscode_target: win32-x64
- goos: windows
goarch: arm64
vscode_target: win32-arm64
steps:
- name: Checkout
@ -95,38 +95,39 @@ jobs:
with:
fetch-depth: 0
- uses: cachix/install-nix-action@v27
- name: Set up Go
uses: actions/setup-go@v5
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
go-version: stable
- name: Check Flake
run: nix flake check
- name: Create bare extension
run: nix build .#"vs-code-extension-bare"
- name: Build extension
run: nix build .#"vs-code-extension"
run: cd server && GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -a -gcflags=all="-l -B" -ldflags="-s -w" -o config-lsp
- name: Rename extension
run: cp result/*.vsix $(basename result/*.vsix)-${{ matrix.target }}.vsix
- name: Prepare folder
run: cp -rL result dist && chmod -R 777 dist
- name: Move binary to extension
run: mv server/config-lsp dist/out/
- name: Shrink binary
if: ${{ matrix.goos == 'linux' }}
run: nix develop .#"shrink" --command bash -c "upx dist/out/config-lsp"
- name: Package extension
run: nix develop .#"vs-code-extension" --command bash -c "cd dist && vsce package --target ${{ matrix.vscode_target }}"
- name: Move vsix to root
run: mv dist/*.vsix .
- uses: softprops/action-gh-release@v2
with:
files: '*.vsix'
- name: Target to vs code target
id: vscode_target
run: |
if [ "${{ matrix.target }}" = "x86_64-apple-darwin" ]; then
echo "target=darwin-x64" >> $GITHUB_OUTPUT
elif [ "${{ matrix.target }}" = "aarch64-apple-darwin" ]; then
echo "target=darwin-arm64" >> $GITHUB_OUTPUT
elif [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ]; then
echo "target=linux-x64" >> $GITHUB_OUTPUT
elif [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
echo "target=linux-arm64" >> $GITHUB_OUTPUT
fi
- name: Upload extension to VS Code Marketplace
run: nix develop .#"vs-code-extension" --command bash -c "vsce publish --target ${{ steps.vscode_target.outputs.target }} --packagePath *.vsix"
run: nix develop .#"vs-code-extension" --command bash -c "vsce publish --packagePath *.vsix"
env:
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}

View File

@ -68,6 +68,36 @@
in {
packages = {
default = server;
"vs-code-extension-bare" = let
name = "config-lsp";
node-modules = pkgs.mkYarnPackage {
src = ./vs-code-extension;
name = name;
packageJSON = ./vs-code-extension/package.json;
yarnLock = ./vs-code-extension/yarn.lock;
yarnNix = ./vs-code-extension/yarn.nix;
buildPhase = ''
yarn --offline run compile:prod
'';
installPhase = ''
mkdir -p extension
# No idea why this is being created
rm deps/${name}/config-lsp
cp -rL deps/${name}/. extension
mkdir -p $out
cp -r extension/. $out
'';
distPhase = "true";
buildInputs = [
pkgs.vsce
];
};
in node-modules;
"vs-code-extension" = let
name = "config-lsp";
node-modules = pkgs.mkYarnPackage {