From 0bcd0d5dd51b29f5139a45e50ddd50de4d0e36c9 Mon Sep 17 00:00:00 2001 From: Antoine Date: Tue, 7 Jan 2025 21:25:01 +0100 Subject: [PATCH] fix some ci enhancement (#435) * fix(release): customize goreleaser config file, by adding json schema and fixing configuration version * fix(go): rename invalid comment format * fix(ci): made release workflow work again replace goreleaser --rm-dist flag by --clean increment go version for release pipeline fetch previous tags use by goreleaser give release workflow content write permissions to publish release --- .github/workflows/release.yml | 7 +++++-- .goreleaser.yml | 4 ++++ cmd/kubectx/version.go | 2 +- cmd/kubens/version.go | 2 +- internal/env/constants.go | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 54fae36..ac40795 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,14 +19,17 @@ on: - 'v*.*.*' jobs: goreleaser: + permissions: + contents: write runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@master + - run: git fetch --tags - name: Setup Go uses: actions/setup-go@v2 with: - go-version: '1.20' + go-version: '1.22' - name: Install Snapcraft uses: samuelmeuli/action-snapcraft@v1 - name: Setup Snapcraft @@ -38,7 +41,7 @@ jobs: uses: goreleaser/goreleaser-action@v2 with: version: latest - args: release --rm-dist + args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Update new version for plugin 'ctx' in krew-index diff --git a/.goreleaser.yml b/.goreleaser.yml index dec3285..b7d3304 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,3 +1,5 @@ +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json + # Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,6 +16,8 @@ # This is an example goreleaser.yaml file with some sane defaults. # Make sure to check the documentation at http://goreleaser.com + +version: 2 before: hooks: - go mod download diff --git a/cmd/kubectx/version.go b/cmd/kubectx/version.go index 964f334..dc5c8be 100644 --- a/cmd/kubectx/version.go +++ b/cmd/kubectx/version.go @@ -11,7 +11,7 @@ var ( version = "v0.0.0+unknown" // populated by goreleaser ) -// VersionOps describes printing version string. +// VersionOp describes printing version string. type VersionOp struct{} func (_ VersionOp) Run(stdout, _ io.Writer) error { diff --git a/cmd/kubens/version.go b/cmd/kubens/version.go index 964f334..dc5c8be 100644 --- a/cmd/kubens/version.go +++ b/cmd/kubens/version.go @@ -11,7 +11,7 @@ var ( version = "v0.0.0+unknown" // populated by goreleaser ) -// VersionOps describes printing version string. +// VersionOp describes printing version string. type VersionOp struct{} func (_ VersionOp) Run(stdout, _ io.Writer) error { diff --git a/internal/env/constants.go b/internal/env/constants.go index e6a2a92..c4fd5ba 100644 --- a/internal/env/constants.go +++ b/internal/env/constants.go @@ -19,7 +19,7 @@ const ( // interactive context selection when fzf is installed. EnvFZFIgnore = "KUBECTX_IGNORE_FZF" - // EnvForceColor describes the environment variable to disable color usage + // EnvNoColor describes the environment variable to disable color usage // when printing current context in a list. EnvNoColor = `NO_COLOR`