From adb054b90a4255399879c345515b99a2e5bb6989 Mon Sep 17 00:00:00 2001 From: CoolLoong Date: Wed, 4 Sep 2024 17:30:02 +0800 Subject: [PATCH] fix: CI (#3) * fix: ci * 2 * fix 3 * fix 4 * try fix 5 * fix6 * fix7 * fix8 * fix9 * fix10 * fix11 * build: prerelease --- .github/{ => workflows}/ci.yml | 21 ++++++++++++++------- .vscodeignore | 1 + package.json | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) rename .github/{ => workflows}/ci.yml (52%) diff --git a/.github/ci.yml b/.github/workflows/ci.yml similarity index 52% rename from .github/ci.yml rename to .github/workflows/ci.yml index 85cf9c6..fa66ae7 100644 --- a/.github/ci.yml +++ b/.github/workflows/ci.yml @@ -48,22 +48,29 @@ jobs: toolchain: nightly profile: minimal override: true - - name: cross build - run: cargo install cross && cross build --verbose --release --target=${{ matrix.rust_target }} + - name: Install Cross + if: matrix.arch == 'arm64' && matrix.os == 'ubuntu-latest' + run: cargo install cross + - name: Build with Cargo or Cross + run: | + node -e "const { execSync } = require('child_process'); const arch = process.env.MATRIX_ARCH; const os = process.env.MATRIX_OS; const rustTarget = process.env.MATRIX_RUST_TARGET; if (arch === 'arm64' && os === 'ubuntu-latest') { console.log('Using cross to build...'); execSync('cross build --verbose --release --target=' + rustTarget, { stdio: 'inherit' }); } else { console.log('Using cargo to build...'); execSync('rustup set auto-self-update disable', { stdio: 'inherit' }); execSync('rustup target add ' + rustTarget, { stdio: 'inherit' }); execSync('cargo build --verbose --release --target=' + rustTarget, { stdio: 'inherit' }); }" + env: + MATRIX_ARCH: ${{ matrix.arch }} + MATRIX_OS: ${{ matrix.os }} + MATRIX_RUST_TARGET: ${{ matrix.rust_target }} - run: npm install env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} npm_config_arch: ${{ matrix.npm_config_arch }} - - name: Move execute file + - name: build client and move execute file run: | npx webpack --mode production --config webpack.config.js - node -e "try {fs.renameSync('target/${process.env.TARGET}/release/jsonui-lsp', 'dist');}catch(err) {}" - node -e "try {fs.renameSync('target/${process.env.TARGET}/release/jsonui-lsp.exe', 'dist');}catch(err) {}" + node -e "const fs = require('fs'); const path = require('path'); const targetDir = process.env.TARGET; const sourcePaths = ['target/' + targetDir + '/release/jsonui-lsp', 'target/' + targetDir + '/release/jsonui-lsp.exe']; const destDir = 'dist'; sourcePaths.forEach(sourcePath => { const destPath = path.join(destDir, path.basename(sourcePath)); if (fs.existsSync(sourcePath)) { fs.renameSync(sourcePath, destPath); console.log('File', path.basename(sourcePath), 'moved successfully to', destPath); } else { console.log('File', path.basename(sourcePath), 'not found at', sourcePath); } });" env: TARGET: ${{ matrix.rust_target }} - shell: pwsh run: echo "target=${{ matrix.platform }}-${{ matrix.arch }}" >> $env:GITHUB_ENV - - run: npx vsce package --target ${{ env.target }} + - run: npx vsce package --pre-release --target ${{ env.target }} - uses: actions/upload-artifact@v2 with: name: ${{ env.target }} @@ -75,6 +82,6 @@ jobs: if: success() && startsWith( github.ref, 'refs/tags/') steps: - uses: actions/download-artifact@v2 - - run: npx vsce publish --packagePath $(find . -iname *.vsix) + - run: npx vsce publish --pre-release --packagePath $(find . -iname *.vsix) env: VSCE_PAT: ${{ secrets.VSCE_PAT }} diff --git a/.vscodeignore b/.vscodeignore index af8fcc8..656458f 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -1,5 +1,6 @@ .cargo .vscode +.github client/** node_modules out diff --git a/package.json b/package.json index 9a615cb..734edf7 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "onLanguage:json" ], "scripts": { - "postinstall": "cd client && pnpm i", + "postinstall": "cd client && npm i", "vscode:prepublish": "npm run build", "test-compile": "tsc -p ./", "compile": "cross-env NODE_ENV=production tsc -b",