Fix ci scripts #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| pull_request: | |
| permissions: | |
| contents: read | |
| jobs: | |
| ci: | |
| name: ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| - windows-latest | |
| - macos-latest | |
| defaults: | |
| run: | |
| shell: pwsh | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: go.mod | |
| cache-dependency-path: go.sum | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Check formatting | |
| if: matrix.os == 'ubuntu-latest' # Formatting check is platform-agnostic, so only run it once to save time | |
| run: | | |
| $unformatted = gofmt -l . | |
| if ($unformatted) { | |
| Write-Error "The following Go files are not gofmt-formatted:" | |
| $unformatted | |
| exit 1 | |
| } | |
| - name: Vet | |
| run: go vet ./... | |
| - name: Test | |
| run: go test ./... | |
| - name: Build | |
| run: | | |
| New-Item -ItemType Directory -Force dist | Out-Null | |
| $os = ($env:RUNNER_OS).ToLowerInvariant() | |
| $arch = ($env:RUNNER_ARCH).ToLowerInvariant() | |
| $ext = if ($env:RUNNER_OS -eq 'Windows') { '.exe' } else { '' } | |
| go build -v -o "dist/dspm-$os-$arch$ext" ./cmd/dspm | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: dspm-${{ runner.os }}-${{ runner.arch }} | |
| path: dist/* | |
| if-no-files-found: error |