From bdfa7baea4e051ab630945d723f127fa4f58ddd3 Mon Sep 17 00:00:00 2001 From: Ori Shoshan Date: Wed, 14 Sep 2022 17:14:25 +0300 Subject: [PATCH] Add CI & release pipeline (#2) * Add CI * fixup * fixup * fixup * fixup * add github token to goreleaser --- .github/workflows/build.yaml | 34 ++++++++++++++++++++++++++++ .github/workflows/release-tag.yaml | 29 ++++++++++++++++++++++++ .gitignore | 3 ++- .goreleaser.yaml | 35 +++++++++++++++++++++++++++++ src/go.mod => go.mod | 2 +- src/go.sum => go.sum | 0 src/pkg/mapperclient/genqlient.yaml | 2 +- src/tools.go => tools.go | 2 +- 8 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/release-tag.yaml create mode 100644 .goreleaser.yaml rename src/go.mod => go.mod (98%) rename src/go.sum => go.sum (100%) rename src/tools.go => tools.go (78%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000..b9e6d38d --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,34 @@ +name: Build +concurrency: + group: "${{ github.repository }}${{ github.ref }}" + cancel-in-progress: true + +on: + pull_request: + types: + - opened + - synchronize + push: + branches: + - main + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Check out the code + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - uses: actions/setup-go@v3 + with: + go-version: '>=1.19.0' + + - name: Build + run: |- + go generate ./... + git config --global url."https://$GITHUB_TOKEN@github.com/".insteadOf "https://github.com/" && go build ./src/cmd && git config --global --unset url."https://$GITHUB_TOKEN@github.com/".insteadOf + env: + GITHUB_TOKEN: ${{ secrets.OTTERIZEBOT_GITHUB_TOKEN }} diff --git a/.github/workflows/release-tag.yaml b/.github/workflows/release-tag.yaml new file mode 100644 index 00000000..7c4d3795 --- /dev/null +++ b/.github/workflows/release-tag.yaml @@ -0,0 +1,29 @@ +name: Build +concurrency: + group: "${{ github.repository }}${{ github.ref }}-release" + +on: + push: + tags: + - 'v*.*.*' + +env: + REGISTRY: 353146681200.dkr.ecr.us-east-1.amazonaws.com/otterize + REPOSITORY_NAME: otterize + +jobs: + publish-release: + name: Push to Docker Hub + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 96ae31de..260d2536 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ # vendor/ # IDE -.idea/ \ No newline at end of file +.idea/ +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 00000000..d6ce18ae --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,35 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + # you may remove this if you don't need go generate + - go generate ./... +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + main: + ./src/cmd + binary: otterize +archives: + - replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' diff --git a/src/go.mod b/go.mod similarity index 98% rename from src/go.mod rename to go.mod index 6e845427..13637320 100644 --- a/src/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/otterize/otterize-cli/src +module github.com/otterize/otterize-cli go 1.18 diff --git a/src/go.sum b/go.sum similarity index 100% rename from src/go.sum rename to go.sum diff --git a/src/pkg/mapperclient/genqlient.yaml b/src/pkg/mapperclient/genqlient.yaml index 5672f7d0..28e56a73 100644 --- a/src/pkg/mapperclient/genqlient.yaml +++ b/src/pkg/mapperclient/genqlient.yaml @@ -1,7 +1,7 @@ # genqlient config; for full documentation see: # https://github.com/Khan/genqlient/blob/main/docs/genqlient.yaml schema: - - ../../../graphql/schema.graphql + - ../../graphql/schema.graphql operations: - genqlient.graphql generated: generated.go diff --git a/src/tools.go b/tools.go similarity index 78% rename from src/tools.go rename to tools.go index 246db031..7417c2b3 100644 --- a/src/tools.go +++ b/tools.go @@ -1,6 +1,6 @@ //go:build tools // +build tools -package networkmapper +package otterize_cli import _ "github.com/Khan/genqlient/generate"