Skip to content

Commit

Permalink
build: improve GH actions and move cmd/ folder
Browse files Browse the repository at this point in the history
  • Loading branch information
clementnuss committed Nov 23, 2021
1 parent b194536 commit 1020102
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.17.x
go-version: 1.17
stable: true

- run: |
go build ./...
Expand Down
66 changes: 62 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,74 @@
name: ko publish
name: Test and publish

on:
push:
branches: ['main']

jobs:
publish:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.17.x
go-version: 1.17
stable: true

- run: |
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
mkdir -p local/envtest-bin/
setup-envtest use -p env 1.21.x --bin-dir local/envtest-bin > local/envtest-bin/env
- name: Run Unit tests
run: |
source local/envtest-bin/env
export KUBEBUILDER_ASSETS=$(pwd)/$KUBEBUILDER_ASSETS
go test -race -covermode atomic -coverprofile=profile.cov ./...
- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
go install github.com/mattn/goveralls
goveralls -coverprofile=profile.cov -service=github
release-tagged:
if: "startsWith(github.ref, 'refs/tags/v')"
needs:
# - lint
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.17
stable: true

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: postfinance
password: ${{ secrets.DOCKER_TOKEN }}
- uses: imjasonh/[email protected]
env:
KO_DOCKER_REPO: docker.io/postfinance
- run: |
tag=$(echo ${{ github.ref }} | cut -d "/" -f 3 - )
ko publish cmd/kubelet-csr-approver/main.go --base-import-paths --tags $tag
release-untagged:
if: "!startsWith(github.ref, 'refs/tags/v')"
needs:
# - lint
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.17
stable: true

- name: Login to DockerHub
uses: docker/login-action@v1
Expand All @@ -21,4 +78,5 @@ jobs:
- uses: imjasonh/[email protected]
env:
KO_DOCKER_REPO: docker.io/postfinance
- run: ko publish cmd/approverd/main.go
- run: |
ko publish cmd/kubelet-csr-approver/main.go --base-import-paths
File renamed without changes.

0 comments on commit 1020102

Please sign in to comment.