Skip to content

Commit 0099843

Browse files
authored
Add github workflow for release docker images for kpt go functions (#72)
1 parent f639055 commit 0099843

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: release-go-functions
2+
3+
on:
4+
push:
5+
tags:
6+
- release-go-functions-*
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
env:
12+
GOPATH: /home/runner/work/kpt-functions-catalog/functions/go
13+
GO111MODULE: on
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Set up gcloud
17+
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
18+
with:
19+
version: '285.0.0'
20+
project_id: ${{ secrets.GCP_PROJECT_ID }}
21+
service_account_email: ${{ secrets.GCP_SA_EMAIL }}
22+
service_account_key: ${{ secrets.GCP_SA_KEY }}
23+
export_default_credentials: true
24+
# Configure docker to use the gcloud command-line tool as a credential helper
25+
- run: gcloud auth configure-docker
26+
- name: Set up Go 1.13
27+
uses: actions/setup-go@v1
28+
with:
29+
go-version: 1.13
30+
id: go
31+
- name: Check out code into GOPATH
32+
uses: actions/checkout@v1
33+
with:
34+
path: go/src/github.com/${{ github.repository }}
35+
- name: Get the version
36+
id: get_version
37+
run: echo ::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/}
38+
- name: Publish images to container registry
39+
run: |
40+
cd functions/go
41+
./publish-functions.sh
42+
env:
43+
TAG: ${{ steps.branch_name.outputs.TAG_NAME }}

functions/go/publish-functions.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -euo pipefail
17+
18+
image_tag=${TAG:-latest}
19+
20+
# iterate over each subdir, build and push Docker images.
21+
for dir in */
22+
do
23+
image_name=gcr.io/kpt-functions/"${dir%/}"
24+
image="${image_name}":"${image_tag}"
25+
set -x
26+
( cd "${dir}" && make )
27+
docker build -t "${image}" -t "${image_name}" -f "${dir}"/Dockerfile "${dir}"
28+
docker push "${image_name}"
29+
set +x
30+
done

functions/go/set-namespace/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.PHONY: fix vet fmt test lint
2+
3+
GOPATH := $(shell go env GOPATH)
4+
5+
all: fix vet fmt test lint
6+
7+
fix:
8+
go fix ./...
9+
10+
fmt:
11+
go fmt ./...
12+
13+
lint:
14+
(which $(GOPATH)/bin/golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint)
15+
$(GOPATH)/bin/golangci-lint run ./...
16+
17+
test:
18+
go test -cover ./...
19+
20+
vet:
21+
go vet ./...

0 commit comments

Comments
 (0)