From 4c1c5065d4afd12d7931eb0c86b6b8a40624230b Mon Sep 17 00:00:00 2001 From: Matthew Espino <65783406+mcecode@users.noreply.github.com> Date: Fri, 20 Sep 2024 22:03:16 +0800 Subject: [PATCH] feat(vscode-plugin): add publish workflow --- .github/workflows/publish_vscode_plugin.yml | 75 +++++++++++++++++++++ justfile | 11 +-- packages/.prettierrc | 1 + 3 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/publish_vscode_plugin.yml diff --git a/.github/workflows/publish_vscode_plugin.yml b/.github/workflows/publish_vscode_plugin.yml new file mode 100644 index 00000000..f1b51d2b --- /dev/null +++ b/.github/workflows/publish_vscode_plugin.yml @@ -0,0 +1,75 @@ +name: Publish VS Code Plugin + +on: + push: + tags: ["harper-vscode*"] + workflow_dispatch: + +jobs: + package: + strategy: + matrix: + platform: + - os: windows-latest + rust_target: x86_64-pc-windows-gnu + code_target: win32-x64 + - os: macOS-latest + rust_target: x86_64-apple-darwin + code_target: darwin-x64 + - os: macOS-latest + rust_target: aarch64-apple-darwin + code_target: darwin-arm64 + - os: ubuntu-20.04 + rust_target: x86_64-unknown-linux-gnu + code_target: linux-x64 + - os: ubuntu-20.04 + rust_target: aarch64-unknown-linux-gnu + code_target: linux-arm64 + name: Package - ${{ matrix.platform.code_target }} + runs-on: ${{ matrix.platform.os }} + steps: + - uses: actions/checkout@v4 + - uses: extractions/setup-just@v2 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Build harper-ls + uses: houseabsolute/actions-rust-cross@v0 + with: + target: ${{ matrix.platform.rust_target }} + args: "--locked --release --bin harper-ls" + strip: true + - name: Package extension + shell: bash + run: | + bin_dir="packages/vscode-plugin/bin" + release_dir="target/${{ matrix.platform.rust_target }}/release" + + mkdir "$bin_dir" + + if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then + cp "${release_dir}/harper-ls.exe" "$bin_dir" + else + cp "${release_dir}/harper-ls" "$bin_dir" + fi + + just package-vscode ${{ matrix.platform.code_target }} + - name: Upload extension + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.platform.code_target }} + path: "packages/vscode-plugin/*.vsix" + + publish: + name: Publish + needs: package + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Publish extension + run: npx @vscode/vsce publish --packagePath $(find . -iname *.vsix) + env: + VSCE_PAT: ${{ secrets.VSCE_PAT }} diff --git a/justfile b/justfile index 79cbf629..a32c17ae 100644 --- a/justfile +++ b/justfile @@ -39,16 +39,17 @@ build-obsidian: zip harper-obsidian-plugin.zip manifest.json main.js -package-vscode: +# This assumes that `harper-ls` or `harper-ls.exe` exists in `packages/vscode-plugin/bin`. +package-vscode target: #! /bin/bash set -eo pipefail - path="{{justfile_directory()}}/packages/vscode-plugin" - cp LICENSE "${path}/LICENSE" - cd "$path" + ext_dir="{{justfile_directory()}}/packages/vscode-plugin" + cp LICENSE "$ext_dir" + cd "$ext_dir" yarn install -f - yarn package + yarn package --target {{target}} check: #! /bin/bash diff --git a/packages/.prettierrc b/packages/.prettierrc index 3f7802c3..be9e570f 100644 --- a/packages/.prettierrc +++ b/packages/.prettierrc @@ -3,6 +3,7 @@ "singleQuote": true, "trailingComma": "none", "printWidth": 100, + "endOfLine": "auto", "plugins": ["prettier-plugin-svelte"], "overrides": [ {