From 4826f0e8493424496686ed22f5edda7bac1d4d05 Mon Sep 17 00:00:00 2001 From: Enrico Candino Date: Fri, 3 Jan 2025 17:30:11 +0100 Subject: [PATCH 1/3] goreleaser action --- .github/workflows/gorelease.yml | 59 +++++++++++++++++++++++++++++++++ package/Dockerfile | 9 +++-- package/Dockerfile.kubelet | 4 ++- 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/gorelease.yml diff --git a/.github/workflows/gorelease.yml b/.github/workflows/gorelease.yml new file mode 100644 index 0000000..8aacd04 --- /dev/null +++ b/.github/workflows/gorelease.yml @@ -0,0 +1,59 @@ +name: Gorelease + +on: + workflow_dispatch: + inputs: + registry: + type: choice + description: Select the container registry + options: + - dockerhub + - ghcr.io + +env: + GH_TOKEN: ${{ github.token }} + +permissions: + contents: write + id-token: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + + - name: "Read secrets" + uses: rancher-eio/read-vault-secrets@main + if: "${{ github.event.inputs.registry == 'dockerhub' }}" + with: + secrets: | + secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials username | DOCKER_USERNAME ; + secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials password | DOCKER_PASSWORD ; + + - name: Login to Docker Container Registry + uses: docker/login-action@v3 + if: "${{ github.event.inputs.registry == 'dockerhub' }}" + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ env.DOCKER_PASSWORD }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + if: "${{ github.event.inputs.registry == 'ghcr.io' }}" + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: v2 + args: --snapshot --clean --skip archive diff --git a/package/Dockerfile b/package/Dockerfile index 5409782..9339380 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,4 +1,9 @@ FROM alpine -COPY bin/k3k /usr/bin/ -COPY bin/k3kcli /usr/bin/ + +ARG BIN_K3K=bin/k3k +ARG BIN_K3KCLI=bin/k3kcli + +COPY ${BIN_K3K} /usr/bin/ +COPY ${BIN_K3KCLI} /usr/bin/ + CMD ["k3k"] diff --git a/package/Dockerfile.kubelet b/package/Dockerfile.kubelet index a77597d..1bb3dce 100644 --- a/package/Dockerfile.kubelet +++ b/package/Dockerfile.kubelet @@ -1,6 +1,8 @@ # TODO: swicth this to BCI-micro or scratch. Left as base right now so that debug can be done a bit easier FROM registry.suse.com/bci/bci-base:15.6 -COPY bin/k3k-kubelet /usr/bin/ +ARG BIN_K3K_KUBELET=bin/k3k-kubelet + +COPY ${BIN_K3K_KUBELET} /usr/bin/ ENTRYPOINT ["/usr/bin/k3k-kubelet"] From c554948315e1d7d38380de52bdb2f0a5637d9308 Mon Sep 17 00:00:00 2001 From: Enrico Candino Date: Fri, 3 Jan 2025 17:32:51 +0100 Subject: [PATCH 2/3] push trigger --- .github/workflows/gorelease.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/gorelease.yml b/.github/workflows/gorelease.yml index 8aacd04..e1da414 100644 --- a/.github/workflows/gorelease.yml +++ b/.github/workflows/gorelease.yml @@ -1,6 +1,8 @@ name: Gorelease on: + push: + pull_request: workflow_dispatch: inputs: registry: From b468556bf4d5d75213337e4803e57d8df78100dc Mon Sep 17 00:00:00 2001 From: Enrico Candino Date: Fri, 3 Jan 2025 17:41:13 +0100 Subject: [PATCH 3/3] goreleaser --- .github/workflows/gorelease.yml | 35 --------------------------------- 1 file changed, 35 deletions(-) diff --git a/.github/workflows/gorelease.yml b/.github/workflows/gorelease.yml index e1da414..90619c8 100644 --- a/.github/workflows/gorelease.yml +++ b/.github/workflows/gorelease.yml @@ -1,8 +1,6 @@ name: Gorelease on: - push: - pull_request: workflow_dispatch: inputs: registry: @@ -26,36 +24,3 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - - - name: "Read secrets" - uses: rancher-eio/read-vault-secrets@main - if: "${{ github.event.inputs.registry == 'dockerhub' }}" - with: - secrets: | - secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials username | DOCKER_USERNAME ; - secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials password | DOCKER_PASSWORD ; - - - name: Login to Docker Container Registry - uses: docker/login-action@v3 - if: "${{ github.event.inputs.registry == 'dockerhub' }}" - with: - username: ${{ env.DOCKER_USERNAME }} - password: ${{ env.DOCKER_PASSWORD }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - if: "${{ github.event.inputs.registry == 'ghcr.io' }}" - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v6 - with: - distribution: goreleaser - version: v2 - args: --snapshot --clean --skip archive