Skip to content

Setting up CI/CD.

Setting up CI/CD. #33

Workflow file for this run

name: Go
on:
push:
branches: ["main"]
tags: ["v*"]
pull_request:
branches: ["main"]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64]
exclude:
- goos: windows
goarch: arm64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.24.6"
- name: Get version info
id: version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
fi
COMMIT=$(git rev-parse --short HEAD)
DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
mkdir -p dist
LDFLAGS="-X main.version=${{ steps.version.outputs.version }}"
if [ "$GOOS" = "windows" ]; then
go build -ldflags "$LDFLAGS" -o dist/nvim-server-${{ matrix.goos }}-${{ matrix.goarch }}.exe
else
go build -ldflags "$LDFLAGS" -o dist/nvim-server-${{ matrix.goos }}-${{ matrix.goarch }}
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: nvim-server-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.24.6"
- name: Test
run: go test -v ./...
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [build, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create release
uses: softprops/action-gh-release@v1
with:
files: artifacts/*/nvim-server-*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}