Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrote token implementation and added official cache support #608

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 71 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ permissions:
contents: read

jobs:
build:
name: Build
test:
name: Test
runs-on: ubuntu-latest
permissions:
actions: read
Expand All @@ -26,64 +26,110 @@ jobs:
env:
GO111MODULE: on
steps:
- name: Check out code into the Go module directory
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: "go.mod"
cache: false
id: go

- name: Build
run: make

- name: Test
- name: Run tests
run: make test

- name: Build (linux)
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@4fe8c5f003fae66aa5ebb77cfd3e7bfbbda0b6b0 # v3.1.5

build-linux:
name: Build Linux
runs-on: ubuntu-latest
needs: test
steps:
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install cross-compilation toolchains
run: |
sudo apt-get update && sudo apt-get install -y \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabihf

- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: "go.mod"
cache: false

- name: Build Linux AMD64
run: make
env:
GOOS: linux
GOARCH: amd64
run: make

- name: Build (linux/arm64)
- name: Build Linux ARM64
run: make
env:
GOOS: linux
GOARCH: arm64
run: make
CC: aarch64-linux-gnu-gcc

- name: Build (linux/armv7)
- name: Build Linux ARMv7
run: make
env:
GOOS: linux
GOARCH: arm
GOARM: "7"
run: make
CC: arm-linux-gnueabihf-gcc

build-macos:
name: Build macOS
runs-on: macos-latest
needs: test
steps:
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Build (darwin)
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: "go.mod"
cache: false

- name: Build macOS AMD64
run: make
env:
GOOS: darwin
GOARCH: amd64
run: make

- name: Build (darwin/arm)
- name: Build macOS ARM64
run: make
env:
GOOS: darwin
GOARCH: arm64
run: make

- name: Build (windows)
build-windows:
name: Build Windows
runs-on: windows-latest
needs: test
steps:
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: "go.mod"
cache: false

- name: Build Windows AMD64
run: make
env:
GOOS: windows
GOARCH: amd64
run: make

- name: Build (windows/arm)
- name: Build Windows ARM64
run: make
env:
GOOS: windows
GOARCH: arm64
run: make

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@4fe8c5f003fae66aa5ebb77cfd3e7bfbbda0b6b0 # v3.1.5
156 changes: 123 additions & 33 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,36 @@ permissions:
contents: read

jobs:
build:
name: Build
create-release:
name: Create Release
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
deployments: read
packages: none
env:
GO111MODULE: on
outputs:
release_id: ${{ steps.create_release.outputs.id }}
version: ${{ steps.changelog_reader.outputs.version }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: "go.mod"
cache: false
id: go

# Read changelog and read versions etc.
- name: Check version is mentioned in Changelog.md
id: changelog_reader
uses: mindsers/changelog-reader-action@b97ce03a10d9bdbb07beb491c76a5a01d78cd3ef # v2.2.2
with:
validation_depth: 10
path: "CHANGELOG.md"

# Check if the newest tag already exists
- name: Check if tag exist
uses: mukunku/tag-exists-action@5dfe2bf779fe5259360bb10b2041676713dcc8a3 # v1.1.0
id: check-tag-exists
with:
tag: "v${{ steps.changelog_reader.outputs.version }} release" # following the pattern of vx.x.xx release used in this repo
tag: "v${{ steps.changelog_reader.outputs.version }} release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Create Release with artifacts

# Create Release
- name: Create Kubelogin Release
id: create_release
if: ${{ steps.check-tag-exists.outputs.exists == 'false'}}
Expand All @@ -51,55 +44,152 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ steps.changelog_reader.outputs.version }}"
name: "v${{ steps.changelog_reader.outputs.version }} release" # following the pattern of vx.x.xx release used in this repo
name: "v${{ steps.changelog_reader.outputs.version }} release"
body: ${{ steps.changelog_reader.outputs.changes }}

# We need the latest tag in the git local workspace before it start building.
build-linux:
name: Build Linux
runs-on: ubuntu-latest
needs: create-release
if: ${{ needs.create-release.outputs.release_id != '' }}
steps:
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Get tags
run: git fetch --tags

- name: Build (linux)
- name: Install cross-compilation toolchains
run: |
sudo apt-get update && sudo apt-get install -y \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabihf

- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: "go.mod"
cache: false

- name: Build Linux AMD64
run: make
env:
GOOS: linux
GOARCH: amd64
run: make

- name: Build (linux/arm64)
- name: Build Linux ARM64
run: make
env:
GOOS: linux
GOARCH: arm64
run: make
CC: aarch64-linux-gnu-gcc

- name: Build (linux/armv7)
- name: Build Linux ARMv7
run: make
env:
GOOS: linux
GOARCH: arm
GOARM: "7"
run: make
CC: arm-linux-gnueabihf-gcc

- name: Upload Linux artifacts
uses: actions/upload-artifact@v3
with:
name: linux-binaries
path: bin/linux_*

build-macos:
name: Build macOS
runs-on: macos-latest
needs: create-release
if: ${{ needs.create-release.outputs.release_id != '' }}
steps:
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Get tags
run: git fetch --tags

- name: Build (darwin)
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: "go.mod"
cache: false

- name: Build macOS AMD64
run: make
env:
GOOS: darwin
GOARCH: amd64
run: make

- name: Build (darwin/arm)
- name: Build macOS ARM64
run: make
env:
GOOS: darwin
GOARCH: arm64
run: make

- name: Build (windows)
- name: Upload macOS artifacts
uses: actions/upload-artifact@v3
with:
name: macos-binaries
path: bin/darwin_*

build-windows:
name: Build Windows
runs-on: windows-latest
needs: create-release
if: ${{ needs.create-release.outputs.release_id != '' }}
steps:
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Get tags
run: git fetch --tags

- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: "go.mod"
cache: false

- name: Build Windows AMD64
run: make
env:
GOOS: windows
GOARCH: amd64
run: make

- name: Build (windows/arm)
- name: Build Windows ARM64
run: make
env:
GOOS: windows
GOARCH: arm64
run: make

- name: Upload Windows artifacts
uses: actions/upload-artifact@v3
with:
name: windows-binaries
path: bin/windows_*

package-and-publish:
name: Package and Publish
runs-on: ubuntu-latest
needs: [create-release, build-linux, build-macos, build-windows]
if: ${{ needs.create-release.outputs.release_id != '' }}
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: bin

- name: Move binaries to correct locations
run: |
mkdir -p bin/linux_amd64 bin/linux_arm64 bin/linux_armv7 \
bin/darwin_amd64 bin/darwin_arm64 \
bin/windows_amd64 bin/windows_arm64
mv bin/linux-binaries/linux_* bin/
mv bin/macos-binaries/darwin_* bin/
mv bin/windows-binaries/windows_* bin/
rm -rf bin/linux-binaries bin/macos-binaries bin/windows-binaries

- name: Zip
uses: montudor/action-zip@a8e75c9faefcd80fac3baf53ef40b9b119d5b702 # v1
Expand Down Expand Up @@ -158,4 +248,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: kubelogin.zip kubelogin-win-amd64.zip kubelogin-win-arm64.zip kubelogin-darwin-amd64.zip kubelogin-darwin-arm64.zip kubelogin-linux-amd64.zip kubelogin-linux-arm64.zip kubelogin-linux-armv7.zip kubelogin.zip.sha256 kubelogin-win-amd64.zip.sha256 kubelogin-win-arm64.zip.sha256 kubelogin-darwin-amd64.zip.sha256 kubelogin-darwin-arm64.zip.sha256 kubelogin-linux-amd64.zip.sha256 kubelogin-linux-arm64.zip.sha256 kubelogin-linux-armv7.zip.sha256
releaseId: ${{ steps.create_release.outputs.id }}
releaseId: ${{ needs.create-release.outputs.release_id }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ version:
@echo VERSION: $(VERSION)

$(TARGET): clean
CGO_ENABLED=0 go build -o $(BIN) -ldflags "$(LDFLAGS)"
CGO_ENABLED=1 go build -o $(BIN) -ldflags "$(LDFLAGS)"

clean:
-rm -f $(BIN)
2 changes: 1 addition & 1 deletion docs/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- [Command-Line Tool](./cli-reference.md)
- [convert-kubeconfig](./cli/convert-kubeconfig.md)
- [get-token](./cli/get-token.md)
- [remove-tokens](./cli/remove-tokens.md)
- [remove-cache-dir](./cli/remove-cache-dir.md)
- [Topics](./topics.md)
- [Using in different environments](./topics/environments.md)
- [Using Service Principal](./topics/sp.md)
Expand Down
Loading