From 0c83f28c0433b0b3f444113aed0769fa7f0d79c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ljubo=20Nikoli=C4=87?= Date: Tue, 4 Jun 2024 14:22:08 +0200 Subject: [PATCH 1/6] add lint job to CI --- .github/workflows/ci.yml | 55 ++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 503746c..729a12b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,31 +1,54 @@ -name: Release +name: CI on: push: - tags: - - 'v*' + pull_request: + branches: + - main + +env: + GO_VERSION: 1.22 + GORELEASER_VERSION: v1.25.1 jobs: - release: + lint: + name: Lint runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Check out source code uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 with: - fetch-depth: 0 + go-version: ${{ env.GO_VERSION }} + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: latest + + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '1.22' - - name: Login to DockerHub - uses: docker/login-action@v3 + go-version: ${{ env.GO_VERSION }} + - name: Cache Go modules + uses: actions/cache@v4 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_TOKEN }} - - name: Run goreleaser + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Install goreleaser uses: goreleaser/goreleaser-action@v5 with: - version: v1.25.1 - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + version: ${{ env.GORELEASER_VERSION }} + install-only: true + - name: Build + run: goreleaser build --clean --snapshot + - name: Run tests + run: go test -v ./... \ No newline at end of file From 01e3695dffff0d8432eff40ac0f43c58b9bb39d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ljubo=20Nikoli=C4=87?= Date: Tue, 4 Jun 2024 14:05:48 +0200 Subject: [PATCH 2/6] rebase on #2 --- .github/workflows/release.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d1d9970 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,35 @@ +name: Release + +on: + push: + tags: + - 'v*' + +env: + GO_VERSION: 1.22 + GORELEASER_VERSION: v1.25.1 + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: Run goreleaser + uses: goreleaser/goreleaser-action@v5 + with: + version: ${{ env.GORELEASER_VERSION }} + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 57fa667691111932129cb9dc3c2b6d9e4852cce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ljubo=20Nikoli=C4=87?= Date: Tue, 4 Jun 2024 14:46:47 +0200 Subject: [PATCH 3/6] trigger release after build and lint job from CI workflow finish with the success and trigger is tag pushed with `v*` --- .github/workflows/release.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d1d9970..e7cd64c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,10 @@ name: Release on: - push: - tags: - - 'v*' + workflow_run: + workflows: ["CI"] + types: + - completed env: GO_VERSION: 1.22 @@ -12,6 +13,7 @@ env: jobs: release: runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' && startsWith(github.ref, 'refs/tags/') }} steps: - name: Checkout code uses: actions/checkout@v4 From f55c4f1634b76c6fd22f3b8a5caee2826fc4872c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ljubo=20Nikoli=C4=87?= Date: Tue, 4 Jun 2024 14:54:11 +0200 Subject: [PATCH 4/6] fix linting to test release --- server/config.go | 2 +- server/server.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/config.go b/server/config.go index a4e314e..8abc633 100644 --- a/server/config.go +++ b/server/config.go @@ -20,7 +20,7 @@ import ( "github.com/c2h5oh/datasize" "github.com/palantir/go-baseapp/baseapp" - "github.com/palantir/go-baseapp/baseapp/datadog" + "github.com/palantir/go-baseapp/appmetrics/emitter/datadog" "github.com/palantir/go-githubapp/githubapp" "github.com/pkg/errors" "gopkg.in/yaml.v2" diff --git a/server/server.go b/server/server.go index b310b05..91ec846 100644 --- a/server/server.go +++ b/server/server.go @@ -25,7 +25,7 @@ import ( "github.com/die-net/lrucache" "github.com/gregjones/httpcache" "github.com/palantir/go-baseapp/baseapp" - "github.com/palantir/go-baseapp/baseapp/datadog" + "github.com/palantir/go-baseapp/appmetrics/emitter/datadog" "github.com/palantir/go-githubapp/githubapp" "github.com/palantir/policy-bot/pull" "github.com/pkg/errors" From d1c49ebafaa5ffa66955fc949f8f1da44feb5fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ljubo=20Nikoli=C4=87?= Date: Tue, 4 Jun 2024 15:25:04 +0200 Subject: [PATCH 5/6] run release after CI finished --- .github/workflows/ci.yml | 7 ++++++- .github/workflows/release.yml | 6 +----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 729a12b..714af45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,4 +51,9 @@ jobs: - name: Build run: goreleaser build --clean --snapshot - name: Run tests - run: go test -v ./... \ No newline at end of file + run: go test -v ./... + + release: + needs: [build, lint] + uses: ./.github/workflows/release.yml + if: startsWith(github.ref, 'refs/tags/v') \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e7cd64c..36d9829 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,7 @@ name: Release on: - workflow_run: - workflows: ["CI"] - types: - - completed + workflow_call: env: GO_VERSION: 1.22 @@ -13,7 +10,6 @@ env: jobs: release: runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' && startsWith(github.ref, 'refs/tags/') }} steps: - name: Checkout code uses: actions/checkout@v4 From 9941186171f710b8f15792992a027460f68dd4cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ljubo=20Nikoli=C4=87?= Date: Tue, 4 Jun 2024 15:30:32 +0200 Subject: [PATCH 6/6] add environment --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 36d9829..723228f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,7 @@ env: jobs: release: runs-on: ubuntu-latest + environment: release steps: - name: Checkout code uses: actions/checkout@v4