Skip to content

Commit e0dd7c7

Browse files
authored
feat: integrate GoReleaser for releasing binaries (#6)
* chore: add release workflow with GoReleaser tool * Fix linting issues * Activate release workflow on push in main branch * Disable releasing from old GH actions workflow
1 parent 1bbbe99 commit e0dd7c7

24 files changed

+285
-113
lines changed

.github/workflows/release.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- 'main'
6+
7+
jobs:
8+
release:
9+
name: goreleaser
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
15+
- name: Unshallow
16+
run: git fetch --prune --unshallow
17+
18+
# this step can be removed if setup-go will support reading go-version from go.mod
19+
- name: Determine Go version
20+
run: |
21+
sed -En 's/^go[[:space:]]+([[:digit:].]+)$/GO_VERSION=\1/p' go.mod >> $GITHUB_ENV
22+
23+
- name: Set up Go
24+
uses: actions/setup-go@v2
25+
with:
26+
go-version: ${{ env.GO_VERSION }}
27+
28+
- name: Set up Snyk CLI
29+
uses: snyk/actions/setup@master
30+
31+
- name: Cache Go modules
32+
uses: actions/cache@v2
33+
with:
34+
path: |
35+
~/.cache/go-build
36+
~/go/pkg/mod
37+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
38+
restore-keys: ${{ runner.os }}-go-
39+
40+
- name: Lint source code
41+
run: |
42+
make tools lint
43+
44+
- name: Run tests
45+
env:
46+
DEEPROXY_API_URL: ${{secrets.DEEPROXY_API_URL}}
47+
SNYK_TOKEN: ${{secrets.SNYK_TOKEN }}
48+
run: |
49+
make clean test
50+
51+
- name: Set up Git actions user
52+
uses: fregante/setup-git-user@v1
53+
54+
- name: Create release tag
55+
run: |
56+
git tag "v$(date +'%Y%m%d.%H%M%S')"
57+
git push --tags
58+
sudo mv snyk-linux* /usr/local/bin/
59+
60+
- name: Release binaries with GoReleaser
61+
uses: goreleaser/goreleaser-action@v2
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
with:
65+
args: release --rm-dist

.github/workflows/workflow.yaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,13 @@ jobs:
6868
version: latest
6969
files: output/*
7070
args: "-9f --lzma"
71-
- uses: "marvinpinto/action-automatic-releases@latest"
72-
if: ${{ github.event_name == 'push' && !env.ACT }}
73-
with:
74-
repo_token: "${{ secrets.GITHUB_TOKEN }}"
75-
automatic_release_tag: "${{ env.NOW }}"
76-
prerelease: false
77-
title: "${{ env.NOW }}"
78-
files: |
79-
output/*
71+
# TODO(pavel): refactor the current workflow after https://github.com/snyk/snyk-lsp/pull/6 is merged
72+
# - uses: "marvinpinto/action-automatic-releases@latest"
73+
# if: ${{ github.event_name == 'push' && !env.ACT }}
74+
# with:
75+
# repo_token: "${{ secrets.GITHUB_TOKEN }}"
76+
# automatic_release_tag: "${{ env.NOW }}"
77+
# prerelease: false
78+
# title: "${{ env.NOW }}"
79+
# files: |
80+
# output/*

.goreleaser.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
project_name: "snyk-lsp"
2+
3+
archives:
4+
- format: zip
5+
name_template: "{{ .ProjectName }}_{{ .Version}}_{{ .Os }}_{{ .Arch }}"
6+
7+
before:
8+
hooks:
9+
- go mod tidy
10+
11+
builds:
12+
- flags:
13+
- -trimpath
14+
goarch:
15+
- "386"
16+
- amd64
17+
- arm64
18+
goos:
19+
- darwin
20+
- linux
21+
- windows
22+
ignore:
23+
- goarch: "386"
24+
goos: darwin
25+
- goarch: arm64
26+
goos: windows
27+
ldflags:
28+
- -s -w -X main.gitinfo={{.Version}}
29+
mod_timestamp: "{{ .CommitTimestamp }}"
30+
hooks:
31+
post:
32+
- upx -9fv --lzma "{{ .Path }}"
33+
34+
checksum:
35+
name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS"
36+
algorithm: sha256
37+
38+
dist: build
39+
40+
env:
41+
- GO111MODULE=on
42+
- CGO_ENABLED=0

.idea/.gitignore

Lines changed: 0 additions & 9 deletions
This file was deleted.

code/backend_service.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7+
"io/ioutil"
8+
"net/http"
9+
710
"github.com/rs/zerolog/log"
11+
sglsp "github.com/sourcegraph/go-lsp"
12+
813
"github.com/snyk/snyk-lsp/lsp"
914
"github.com/snyk/snyk-lsp/util"
10-
sglsp "github.com/sourcegraph/go-lsp"
11-
"io/ioutil"
12-
"net/http"
1315
)
1416

1517
var (

code/backend_service_interface.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package code
22

33
import (
4-
"github.com/snyk/snyk-lsp/lsp"
54
sglsp "github.com/sourcegraph/go-lsp"
5+
6+
"github.com/snyk/snyk-lsp/lsp"
67
)
78

89
type BackendService interface {

code/backend_service_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ package code
22

33
import (
44
"encoding/json"
5-
"github.com/snyk/snyk-lsp/util"
6-
sglsp "github.com/sourcegraph/go-lsp"
7-
"github.com/stretchr/testify/assert"
85
"net/http"
96
"os"
107
"testing"
118
"time"
9+
10+
sglsp "github.com/sourcegraph/go-lsp"
11+
"github.com/stretchr/testify/assert"
12+
13+
"github.com/snyk/snyk-lsp/util"
1214
)
1315

1416
const (

code/bundle.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package code
22

33
import (
4-
"github.com/rs/zerolog/log"
5-
"github.com/snyk/snyk-lsp/lsp"
6-
"github.com/snyk/snyk-lsp/util"
7-
sglsp "github.com/sourcegraph/go-lsp"
84
"path/filepath"
95
"sync"
106
"time"
7+
8+
"github.com/rs/zerolog/log"
9+
sglsp "github.com/sourcegraph/go-lsp"
10+
11+
"github.com/snyk/snyk-lsp/lsp"
12+
"github.com/snyk/snyk-lsp/util"
1113
)
1214

1315
var (

code/bundle_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package code
22

33
import (
4-
lsp2 "github.com/snyk/snyk-lsp/lsp"
5-
"github.com/snyk/snyk-lsp/util"
6-
"github.com/sourcegraph/go-lsp"
7-
"github.com/stretchr/testify/assert"
84
"reflect"
95
"sync"
106
"testing"
7+
8+
"github.com/sourcegraph/go-lsp"
9+
"github.com/stretchr/testify/assert"
10+
11+
lsp2 "github.com/snyk/snyk-lsp/lsp"
12+
"github.com/snyk/snyk-lsp/util"
1113
)
1214

1315
var (

code/fake_backend_service.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package code
22

33
import (
44
"fmt"
5-
"github.com/snyk/snyk-lsp/lsp"
6-
"github.com/snyk/snyk-lsp/util"
7-
sglsp "github.com/sourcegraph/go-lsp"
85
"math/rand"
96
"path/filepath"
7+
8+
sglsp "github.com/sourcegraph/go-lsp"
9+
10+
"github.com/snyk/snyk-lsp/lsp"
11+
"github.com/snyk/snyk-lsp/util"
1012
)
1113

1214
var (
@@ -27,7 +29,7 @@ var (
2729
Code: "SNYK-123",
2830
Source: "snyk code",
2931
Message: "This is a dummy error (severity error)",
30-
//CodeDescription: lsp.CodeDescription{Href: "https://snyk.io"},
32+
// CodeDescription: lsp.CodeDescription{Href: "https://snyk.io"},
3133
}
3234
FakeCodeLens = sglsp.CodeLens{
3335
Range: sglsp.Range{

0 commit comments

Comments
 (0)