|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + - master |
| 9 | + release: |
| 10 | + types: |
| 11 | + - published |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + neva_ref: |
| 15 | + description: "nevalang/neva-lsp ref (branch, tag or SHA)" |
| 16 | + required: false |
| 17 | + default: "master" |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: ci-${{ github.ref }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +env: |
| 24 | + NODE_VERSION: "20" |
| 25 | + |
| 26 | +jobs: |
| 27 | + build-lsp-binaries: |
| 28 | + name: Build LSP ${{ matrix.target.name }} |
| 29 | + runs-on: ubuntu-latest |
| 30 | + strategy: |
| 31 | + fail-fast: false |
| 32 | + matrix: |
| 33 | + target: |
| 34 | + - name: darwin-amd64 |
| 35 | + goos: darwin |
| 36 | + goarch: amd64 |
| 37 | + output: neva-lsp-darwin-amd64 |
| 38 | + - name: darwin-arm64 |
| 39 | + goos: darwin |
| 40 | + goarch: arm64 |
| 41 | + output: neva-lsp-darwin-arm64 |
| 42 | + - name: linux-amd64 |
| 43 | + goos: linux |
| 44 | + goarch: amd64 |
| 45 | + output: neva-lsp-linux-amd64 |
| 46 | + - name: linux-arm64 |
| 47 | + goos: linux |
| 48 | + goarch: arm64 |
| 49 | + output: neva-lsp-linux-arm64 |
| 50 | + - name: windows-amd64 |
| 51 | + goos: windows |
| 52 | + goarch: amd64 |
| 53 | + output: neva-lsp-windows-amd64.exe |
| 54 | + - name: windows-arm64 |
| 55 | + goos: windows |
| 56 | + goarch: arm64 |
| 57 | + output: neva-lsp-windows-arm64.exe |
| 58 | + |
| 59 | + steps: |
| 60 | + - name: Checkout extension repository |
| 61 | + uses: actions/checkout@v4 |
| 62 | + |
| 63 | + - name: Resolve neva ref |
| 64 | + id: neva-ref |
| 65 | + run: | |
| 66 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.neva_ref }}" ]; then |
| 67 | + echo "value=${{ github.event.inputs.neva_ref }}" >> "$GITHUB_OUTPUT" |
| 68 | + else |
| 69 | + echo "value=master" >> "$GITHUB_OUTPUT" |
| 70 | + fi |
| 71 | +
|
| 72 | + - name: Checkout nevalang/neva-lsp |
| 73 | + uses: actions/checkout@v4 |
| 74 | + with: |
| 75 | + repository: nevalang/neva-lsp |
| 76 | + ref: ${{ steps.neva-ref.outputs.value }} |
| 77 | + path: neva-src |
| 78 | + |
| 79 | + - name: Setup Go |
| 80 | + uses: actions/setup-go@v5 |
| 81 | + with: |
| 82 | + go-version-file: neva-src/go.mod |
| 83 | + |
| 84 | + - name: Build LSP binary |
| 85 | + run: | |
| 86 | + mkdir -p bin |
| 87 | + cd neva-src |
| 88 | + GOOS=${{ matrix.target.goos }} GOARCH=${{ matrix.target.goarch }} \ |
| 89 | + go build -ldflags="-s -w" -o "../bin/${{ matrix.target.output }}" ./cmd/lsp |
| 90 | +
|
| 91 | + - name: Upload binary artifact |
| 92 | + uses: actions/upload-artifact@v4 |
| 93 | + with: |
| 94 | + name: lsp-${{ matrix.target.name }} |
| 95 | + path: bin/${{ matrix.target.output }} |
| 96 | + if-no-files-found: error |
| 97 | + |
| 98 | + build-extension: |
| 99 | + name: Build VSIX |
| 100 | + needs: |
| 101 | + - build-lsp-binaries |
| 102 | + runs-on: ubuntu-latest |
| 103 | + |
| 104 | + steps: |
| 105 | + - name: Checkout extension repository |
| 106 | + uses: actions/checkout@v4 |
| 107 | + |
| 108 | + - name: Setup Node |
| 109 | + uses: actions/setup-node@v4 |
| 110 | + with: |
| 111 | + node-version: ${{ env.NODE_VERSION }} |
| 112 | + cache: npm |
| 113 | + |
| 114 | + - name: Download LSP binary artifacts |
| 115 | + uses: actions/download-artifact@v4 |
| 116 | + with: |
| 117 | + pattern: lsp-* |
| 118 | + path: bin |
| 119 | + merge-multiple: true |
| 120 | + |
| 121 | + - name: Verify packaged binaries |
| 122 | + run: | |
| 123 | + test -f bin/neva-lsp-darwin-amd64 |
| 124 | + test -f bin/neva-lsp-darwin-arm64 |
| 125 | + test -f bin/neva-lsp-linux-amd64 |
| 126 | + test -f bin/neva-lsp-linux-arm64 |
| 127 | + test -f bin/neva-lsp-windows-amd64.exe |
| 128 | + test -f bin/neva-lsp-windows-arm64.exe |
| 129 | +
|
| 130 | + - name: Install dependencies |
| 131 | + run: npm ci |
| 132 | + |
| 133 | + - name: Build extension |
| 134 | + run: npm run build |
| 135 | + |
| 136 | + - name: Package VSIX |
| 137 | + run: npx vsce package |
| 138 | + |
| 139 | + - name: Upload VSIX artifact |
| 140 | + uses: actions/upload-artifact@v4 |
| 141 | + with: |
| 142 | + name: vscode-neva-vsix |
| 143 | + path: '*.vsix' |
| 144 | + if-no-files-found: error |
| 145 | + |
| 146 | + publish-marketplace: |
| 147 | + name: Publish to VS Code Marketplace |
| 148 | + needs: |
| 149 | + - build-extension |
| 150 | + if: github.event_name == 'release' |
| 151 | + runs-on: ubuntu-latest |
| 152 | + |
| 153 | + steps: |
| 154 | + - name: Setup Node |
| 155 | + uses: actions/setup-node@v4 |
| 156 | + with: |
| 157 | + node-version: ${{ env.NODE_VERSION }} |
| 158 | + |
| 159 | + - name: Download VSIX artifact |
| 160 | + uses: actions/download-artifact@v4 |
| 161 | + with: |
| 162 | + name: vscode-neva-vsix |
| 163 | + path: dist |
| 164 | + |
| 165 | + - name: Publish to Marketplace |
| 166 | + env: |
| 167 | + VSCE_PAT: ${{ secrets.VSCE_PAT }} |
| 168 | + run: | |
| 169 | + test -n "$VSCE_PAT" |
| 170 | + VSIX_FILE=$(ls -1 dist/*.vsix | head -n 1) |
| 171 | + npx vsce publish --packagePath "$VSIX_FILE" -p "$VSCE_PAT" |
0 commit comments