Skip to content

Commit

Permalink
spctl to release pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
koltyakov committed Apr 29, 2023
1 parent 22f485c commit c7251eb
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 6 deletions.
34 changes: 32 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
before:
hooks:
- go mod download

builds:
- flags:
# Build main plugin
- id: plugin
binary: cq-source-sharepoint
flags:
- -buildmode=exe
env:
- CGO_ENABLED=0
Expand All @@ -19,11 +23,37 @@ builds:
ignore:
- goos: windows
goarch: arm64

# Build spctl (CLI)
- id: spctl
main: ./cmd/spctl/
binary: spctl
ldflags:
- -s -w -X main.Version={{.Version}}
goos:
- windows
- linux
- darwin
goarch:
- amd64
- arm64
ignore:
- goos: windows
goarch: arm64

archives:
- name_template: "{{ .Binary }}_{{ .Os }}_{{ .Arch }}"
- id: plugin
builds: [plugin]
name_template: "{{ .Binary }}_{{ .Os }}_{{ .Arch }}"
format: zip
- id: spctl
builds: [spctl]
name_template: "{{ .Binary }}_{{ .Os }}_{{ .Arch }}"
format: zip

checksum:
name_template: "checksums.txt"

changelog:
sort: asc
filters:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.7.0 (2023-04-07)

- Migrate to CloudQuery Plugin SDK v2

## 1.6.0 (2023-03-26)

- Content Types based rollup
Expand Down
22 changes: 22 additions & 0 deletions Versioning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Plugin versioning

Versioning is managed via git tags. Then a new version tag is pushed to the repository, GoReleases pipeline automatically builds and publishes plugin to GitHub packages.

## Set version

```bash
git tag v1.7.2
```

### Push tag

```bash
git push --tags
```

### Delete tag

```bash
git tag -d v1.7.2-test
git push --delete origin v1.7.2-test
```
9 changes: 7 additions & 2 deletions cmd/spctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"github.com/koltyakov/gosip/api"
)

var pluginVersion = "v1.6.2"

func init() {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
Expand All @@ -23,6 +21,13 @@ func init() {
}

func main() {
if len(os.Args) > 1 {
if os.Args[1] == "version" {
printVersion()
return
}
}

siteURL := getSiteURL()
strategy := getStrategy(siteURL)
creds, err := getCreds(strategy)
Expand Down
12 changes: 10 additions & 2 deletions cmd/spctl/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@ package main

import (
"encoding/json"
"fmt"
"net/http"
)

var Version = "development"

func getPluginVersion() (string, error) {
client := &http.Client{}

req, err := http.NewRequest("GET", "https://api.github.com/repos/koltyakov/cq-source-sharepoint/releases/latest", nil)
if err != nil {
return pluginVersion, err
return Version, err
}

req.Header.Add("Accept", "application/vnd.github+json")
req.Header.Add("X-GitHub-Api-Version", "2022-11-28")

resp, err := client.Do(req)
if err != nil {
return pluginVersion, err
return Version, err
}

defer resp.Body.Close()
Expand All @@ -30,3 +33,8 @@ func getPluginVersion() (string, error) {

return data["tag_name"].(string), nil
}

func printVersion() {
pVer, _ := getPluginVersion()
fmt.Printf("spctl: %v, koltyakov/sharepoint (plugin): %s\n", Version, pVer)
}

0 comments on commit c7251eb

Please sign in to comment.