forked from kubeshop/botkube
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add release process for Botkube plugins (kubeshop#882)
- Loading branch information
Showing
11 changed files
with
131 additions
and
79 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,8 @@ tags | |
./botkube | ||
./botkube-test | ||
|
||
# Release | ||
dist/ | ||
plugin-dist/ | ||
plugins-index.yaml | ||
CHANGELOG.md |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,37 @@ | ||
# GoReleaser already creates Botkube artifacts in the ./dist folder. | ||
# To not override them during release, we use a different folder | ||
dist: plugin-dist | ||
|
||
before: | ||
hooks: | ||
- go mod download | ||
|
||
builds: | ||
- id: echo | ||
main: cmd/executor/echo/main.go | ||
binary: executor_echo_{{ .Os }}_{{ .Arch }} | ||
|
||
no_unique_dist_dir: true | ||
main: cmd/executor/echo/main.go | ||
env: | ||
env: &env | ||
- CGO_ENABLED=0 | ||
goos: | ||
goos: &goos | ||
- linux | ||
- darwin | ||
goarch: | ||
goarch: &goarch | ||
- amd64 | ||
- arm64 | ||
goarm: | ||
goarm: &goarm | ||
- 7 | ||
|
||
- id: cm-watcher | ||
main: cmd/source/cm-watcher/main.go | ||
binary: source_cm-watcher_{{ .Os }}_{{ .Arch }} | ||
|
||
no_unique_dist_dir: true | ||
main: cmd/source/cm-watcher/main.go | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
goarm: | ||
- 7 | ||
env: *env | ||
goos: *goos | ||
goarch: *goarch | ||
goarm: *goarm | ||
|
||
snapshot: | ||
name_template: 'v{{ .Version }}' |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/sirupsen/logrus" | ||
"gopkg.in/yaml.v3" | ||
|
||
"github.com/kubeshop/botkube/internal/plugin" | ||
) | ||
|
||
const filePerm = 0o644 | ||
|
||
func main() { | ||
var ( | ||
urlBasePath = flag.String("url-base-path", os.Getenv("PLUGIN_DOWNLOAD_URL_BASE_PATH"), "Defines the URL base path for downloading the plugin binaries") | ||
binsDir = flag.String("binaries-path", "./plugin-dist", "Defines the local path to plugins binaries folder") | ||
output = flag.String("output-path", "./plugins-index.yaml", "Defines the local path where index YAML should be saved") | ||
) | ||
|
||
flag.Parse() | ||
logger := logrus.New() | ||
|
||
idxBuilder := plugin.NewIndexBuilder(logger) | ||
|
||
absBinsDir, err := filepath.Abs(*binsDir) | ||
exitOnError("while resolving an absolute path of binaries folder", err) | ||
|
||
logger.WithFields(logrus.Fields{ | ||
"binDir": absBinsDir, | ||
"urlBasePath": *urlBasePath, | ||
}).Info("Building index..") | ||
idx, err := idxBuilder.Build(absBinsDir, *urlBasePath) | ||
exitOnError("while building plugin index", err) | ||
|
||
raw, err := yaml.Marshal(idx) | ||
exitOnError("while marshaling index into YAML format", err) | ||
|
||
logger.WithField("output", *output).Info("Saving index file...") | ||
err = os.WriteFile(*output, raw, filePerm) | ||
exitOnError("while saving index file", err) | ||
} | ||
|
||
func exitOnError(context string, err error) { | ||
if err != nil { | ||
log.Fatalf("%s: %s", context, err) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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