From e701029c0c5d79d1a49ffe8e3b46cabaaa6501ca Mon Sep 17 00:00:00 2001 From: Andres Morey Date: Sun, 24 Nov 2024 12:19:46 +0300 Subject: [PATCH 1/4] gha improvements --- .github/workflows/ci.yml | 18 +++++++++--------- .github/workflows/release-cli.yml | 10 +++++++++- modules/cli/cmd/root.go | 2 +- set-cli-version.sh | 22 ++++++++++++++++++++++ 4 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 set-cli-version.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d5daa1c..df583acb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 22 - uses: pnpm/action-setup@v3 with: version: 9 @@ -67,7 +67,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 22 - uses: pnpm/action-setup@v3 with: version: 9 @@ -83,7 +83,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 22 - uses: pnpm/action-setup@v3 with: version: 9 @@ -186,7 +186,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 22 - uses: pnpm/action-setup@v3 with: version: 9 @@ -211,7 +211,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 22 - uses: pnpm/action-setup@v3 with: version: 9 @@ -236,7 +236,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 22 - uses: pnpm/action-setup@v3 with: version: 9 @@ -261,7 +261,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 22 - uses: pnpm/action-setup@v3 with: version: 9 @@ -286,7 +286,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 22 - uses: pnpm/action-setup@v3 with: version: 9 @@ -311,7 +311,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 22 - uses: pnpm/action-setup@v3 with: version: 9 diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index e98e71bb..d4744604 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -29,6 +29,11 @@ jobs: GOARCH: amd64 runs-on: ${{ matrix.os }} steps: + - name: Get tag name + uses: olegtarasov/get-tag@2.1.3 + id: tagName + with: + tagRegex: "cli/v(.*)" - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: @@ -39,7 +44,10 @@ jobs: - uses: actions/setup-go@v5 with: go-version: '1.22.7' - cache: false + cache: false + - name: Set CLI version number + working-directory: ./ + run: bash set-cli-version.sh ${{ steps.tagName.outputs.tag }} - name: Run build script working-directory: ./ run: make build diff --git a/modules/cli/cmd/root.go b/modules/cli/cmd/root.go index 320d56f9..76afb22c 100644 --- a/modules/cli/cmd/root.go +++ b/modules/cli/cmd/root.go @@ -23,7 +23,7 @@ import ( // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ Use: "kubetail", - Version: "0.0.7", + Version: "dev", Short: "Kubetail - Kubernetes logging utility", } diff --git a/set-cli-version.sh b/set-cli-version.sh new file mode 100644 index 00000000..1c0e65c6 --- /dev/null +++ b/set-cli-version.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Check if a version number was provided as an argument +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Assign the new version number from command line arguments +NEW_VERSION=$1 +CLI_ROOT_GO_FILE="./modules/cli/cmd/root.go" + +# Check if the file exists +if [ ! -f "$CLI_ROOT_GO_FILE" ]; then + echo "Error: File $CLI_ROOT_GO_FILE not found." + exit 1 +fi + +# Update the Version field in the root.go file +sed -i.bak -E "s/(Version: )\"[^\"]*\"/\1\"$NEW_VERSION\"/" "$CLI_ROOT_GO_FILE" && rm "$CLI_ROOT_GO_FILE.bak" + +echo "Version in $CLI_ROOT_GO_FILE updated to '$NEW_VERSION'." From 5911cf9fc1d2e8f7cf8979d07663b8d0fcab38ca Mon Sep 17 00:00:00 2001 From: Andres Morey Date: Sun, 24 Nov 2024 13:50:41 +0300 Subject: [PATCH 2/4] moved script to .github/scripts --- set-cli-version.sh => .github/scripts/set-cli-version.sh | 0 .github/workflows/release-cli.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename set-cli-version.sh => .github/scripts/set-cli-version.sh (100%) diff --git a/set-cli-version.sh b/.github/scripts/set-cli-version.sh similarity index 100% rename from set-cli-version.sh rename to .github/scripts/set-cli-version.sh diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index d4744604..564d74ed 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -47,7 +47,7 @@ jobs: cache: false - name: Set CLI version number working-directory: ./ - run: bash set-cli-version.sh ${{ steps.tagName.outputs.tag }} + run: bash .github/scripts/set-cli-version.sh ${{ steps.tagName.outputs.tag }} - name: Run build script working-directory: ./ run: make build From 869ce3480793ad0d65ec594b0b174e525ae1633c Mon Sep 17 00:00:00 2001 From: Andres Morey Date: Sun, 24 Nov 2024 13:57:30 +0300 Subject: [PATCH 3/4] wip --- .github/workflows/ci.yml | 26 ++++++++++++++++---------- .github/workflows/release-cli.yml | 2 -- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df583acb..63e5b609 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -193,9 +193,10 @@ jobs: - uses: actions/setup-go@v5 with: go-version: '1.22.7' - cache: false + cache: false + - name: Set CLI version number + run: bash .github/scripts/set-cli-version.sh test - name: Run build script - working-directory: ./ run: make build build-cli-linux-arm64: @@ -219,8 +220,9 @@ jobs: with: go-version: '1.22.7' cache: false + - name: Set CLI version number + run: bash .github/scripts/set-cli-version.sh test - name: Run build script - working-directory: ./ run: make build build-cli-macos-15: @@ -244,8 +246,9 @@ jobs: with: go-version: '1.22.7' cache: false + - name: Set CLI version number + run: bash .github/scripts/set-cli-version.sh test - name: Run build script - working-directory: ./ run: make build build-cli-macos-14: @@ -268,9 +271,10 @@ jobs: - uses: actions/setup-go@v5 with: go-version: '1.22.7' - cache: false + cache: false + - name: Set CLI version number + run: bash .github/scripts/set-cli-version.sh test - name: Run build script - working-directory: ./ run: make build build-cli-macos-13: @@ -293,9 +297,10 @@ jobs: - uses: actions/setup-go@v5 with: go-version: '1.22.7' - cache: false + cache: false + - name: Set CLI version number + run: bash .github/scripts/set-cli-version.sh test - name: Run build script - working-directory: ./ run: make build build-cli-windows: @@ -318,7 +323,8 @@ jobs: - uses: actions/setup-go@v5 with: go-version: '1.22.7' - cache: false + cache: false + - name: Set CLI version number + run: bash .github/scripts/set-cli-version.sh test - name: Run build script - working-directory: ./ run: make build diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 564d74ed..4f37635e 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -46,10 +46,8 @@ jobs: go-version: '1.22.7' cache: false - name: Set CLI version number - working-directory: ./ run: bash .github/scripts/set-cli-version.sh ${{ steps.tagName.outputs.tag }} - name: Run build script - working-directory: ./ run: make build - name: Append os/arch to binary file name run: mv bin/kubetail bin/kubetail-${{ matrix.GOOS }}-${{ matrix.GOARCH }} From 1cc7f7914f2ac6cc855bd039e8a2c1831dc2f132 Mon Sep 17 00:00:00 2001 From: Andres Morey Date: Sun, 24 Nov 2024 14:57:45 +0300 Subject: [PATCH 4/4] moved script --- .github/workflows/ci.yml | 12 ++++++------ .github/workflows/release-cli.yml | 2 +- {.github/scripts => scripts}/set-cli-version.sh | 0 3 files changed, 7 insertions(+), 7 deletions(-) rename {.github/scripts => scripts}/set-cli-version.sh (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63e5b609..731d3fd6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -195,7 +195,7 @@ jobs: go-version: '1.22.7' cache: false - name: Set CLI version number - run: bash .github/scripts/set-cli-version.sh test + run: bash ./scripts/set-cli-version.sh test - name: Run build script run: make build @@ -221,7 +221,7 @@ jobs: go-version: '1.22.7' cache: false - name: Set CLI version number - run: bash .github/scripts/set-cli-version.sh test + run: bash ./scripts/set-cli-version.sh test - name: Run build script run: make build @@ -247,7 +247,7 @@ jobs: go-version: '1.22.7' cache: false - name: Set CLI version number - run: bash .github/scripts/set-cli-version.sh test + run: bash ./scripts/set-cli-version.sh test - name: Run build script run: make build @@ -273,7 +273,7 @@ jobs: go-version: '1.22.7' cache: false - name: Set CLI version number - run: bash .github/scripts/set-cli-version.sh test + run: bash ./scripts/set-cli-version.sh test - name: Run build script run: make build @@ -299,7 +299,7 @@ jobs: go-version: '1.22.7' cache: false - name: Set CLI version number - run: bash .github/scripts/set-cli-version.sh test + run: bash ./scripts/set-cli-version.sh test - name: Run build script run: make build @@ -325,6 +325,6 @@ jobs: go-version: '1.22.7' cache: false - name: Set CLI version number - run: bash .github/scripts/set-cli-version.sh test + run: bash ./scripts/set-cli-version.sh test - name: Run build script run: make build diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 4f37635e..958e9960 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -46,7 +46,7 @@ jobs: go-version: '1.22.7' cache: false - name: Set CLI version number - run: bash .github/scripts/set-cli-version.sh ${{ steps.tagName.outputs.tag }} + run: bash ./scripts/set-cli-version.sh ${{ steps.tagName.outputs.tag }} - name: Run build script run: make build - name: Append os/arch to binary file name diff --git a/.github/scripts/set-cli-version.sh b/scripts/set-cli-version.sh similarity index 100% rename from .github/scripts/set-cli-version.sh rename to scripts/set-cli-version.sh