diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 670e509..e4b788c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -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 @@ -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: diff --git a/CHANGELOG.md b/CHANGELOG.md index 92abf5a..86b517f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Versioning.md b/Versioning.md new file mode 100644 index 0000000..bb7a765 --- /dev/null +++ b/Versioning.md @@ -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 +``` diff --git a/cmd/spctl/main.go b/cmd/spctl/main.go index 9cb0191..b5c0fd6 100644 --- a/cmd/spctl/main.go +++ b/cmd/spctl/main.go @@ -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) @@ -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) diff --git a/cmd/spctl/plugin.go b/cmd/spctl/plugin.go index 39fbf62..cb6b43a 100644 --- a/cmd/spctl/plugin.go +++ b/cmd/spctl/plugin.go @@ -2,15 +2,18 @@ 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") @@ -18,7 +21,7 @@ func getPluginVersion() (string, error) { resp, err := client.Do(req) if err != nil { - return pluginVersion, err + return Version, err } defer resp.Body.Close() @@ -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) +}