Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit aae007a

Browse files
authored
Merge pull request #144 from hashicorp/gha-release
Docker release
2 parents 7a96780 + a08df75 commit aae007a

File tree

3 files changed

+55
-26
lines changed

3 files changed

+55
-26
lines changed

.github/workflows/release.yml

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,61 @@
1-
# This is a basic workflow to help you get started with Actions
2-
31
name: Release
42

5-
# Controls when the action will run. Triggers the workflow on push or pull request
6-
# events but only for the master branch
73
on:
84
push:
95
tags:
10-
- v*.*.*
6+
- "v[0-9]+.[0-9]+.[0-9]+*"
7+
8+
permissions:
9+
contents: write
10+
11+
env:
12+
KUBEBUILDER_VERSION: 3.3.0
1113

1214
jobs:
13-
release:
15+
go-version:
1416
runs-on: ubuntu-latest
17+
outputs:
18+
version: ${{ steps.go-version.outputs.version }}
1519
steps:
16-
- uses: actions/checkout@v2
17-
- name: Set up Go
18-
uses: actions/setup-go@v1
19-
with:
20-
go-version: 1.16.9
21-
- name: Install kubebuilder
22-
run: |
23-
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.1/kubebuilder_2.3.1_linux_amd64.tar.gz -o /tmp/kb.tgz
24-
tar zxf /tmp/kb.tgz -C /tmp/
25-
- name: Run GoReleaser
26-
uses: goreleaser/goreleaser-action@v2.8.0
27-
with:
28-
args: release --skip-sign
29-
env:
30-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31-
KUBEBUILDER_ASSETS: /tmp/kubebuilder_2.3.1_linux_amd64/bin/
32-
20+
- uses: actions/checkout@v2
21+
- id: go-version
22+
run: echo "::set-output name=version::$(cat ./.go-version)"
23+
release-github:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
with:
29+
fetch-depth: 0
30+
- name: Set up Go
31+
uses: actions/setup-go@v3
32+
with:
33+
go-version: "${{ needs.go-version.outputs.version }}"
34+
- name: Install kubebuilder
35+
run: |
36+
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${{ env.KUBEBUILDER_VERSION }}/kubebuilder_${{ env.KUBEBUILDER_VERSION }}_linux_amd64.tar.gz -o /tmp/kb.tgz
37+
tar zxf /tmp/kb.tgz -C /tmp/
38+
- name: Run GoReleaser
39+
uses: goreleaser/goreleaser-action@v3.0.0
40+
if: startsWith(github.ref, 'refs/tags/')
41+
with:
42+
args: release --skip-sign
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
KUBEBUILDER_ASSETS: /tmp/kubebuilder_${{ env.KUBEBUILDER_VERSION }}_linux_amd64/bin/
46+
release-docker-hub:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Login to DockerHub
50+
uses: docker/login-action@v2
51+
with:
52+
username: ${{ secrets.DOCKERHUB_USERNAME }}
53+
password: ${{ secrets.DOCKERHUB_TOKEN }}
54+
- name: Build and push
55+
uses: docker/build-push-action@v3
56+
if: startsWith(github.ref, 'refs/tags/')
57+
with:
58+
push: false
59+
tags: hashicorp/terraform-k8s:${{ github.ref_name }}
60+
secrets: |
61+
GIT_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }}

.go-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.15.2
1+
1.18.3

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the terraform-k8s binary
2-
FROM golang:1.15-alpine as builder
2+
FROM golang:1.18-alpine as builder
33

44
WORKDIR /workspace
55
# Copy the Go Modules manifests
@@ -15,7 +15,7 @@ COPY . .
1515
# Build
1616
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o terraform-k8s main.go
1717

18-
FROM alpine:3.15.0
18+
FROM alpine:3.16.0
1919
WORKDIR /
2020
COPY --from=builder /workspace/terraform-k8s /bin/terraform-k8s
2121
USER nobody:nobody

0 commit comments

Comments
 (0)