Skip to content

Commit 2ba4a1e

Browse files
authored
Merge pull request #107 from detiber/prep-release
Prepare workflows for release
2 parents 11ecb14 + 405e96a commit 2ba4a1e

File tree

4 files changed

+134
-4
lines changed

4 files changed

+134
-4
lines changed

.github/workflows/build-image.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
runs-on: ubuntu-latest
2626
steps:
2727
- name: checkout
28-
uses: actions/[email protected].4
28+
uses: actions/[email protected].5
2929
with:
3030
repository: kubernetes-sigs/image-builder
3131
path: image-builder

.github/workflows/ci.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,31 @@ jobs:
1515
target: ["verify", "lint", "test"]
1616
steps:
1717
- name: checkout
18-
uses: actions/[email protected].4
18+
uses: actions/[email protected].5
1919
- uses: ./.github/actions/setup-go
20+
- uses: actions/cache@v2
21+
with:
22+
path: hack/tools/bin
23+
key: ${{ runner.os }}-tools-bin-${{ matrix.target }}-${{ hashFiles('Makefile') }}
24+
restore-keys: |
25+
${{ runner.os }}-tools-bin-${{ matrix.target }}-
26+
${{ runner.os }}-tools-bin-
27+
- uses: actions/cache@v2
28+
if: ${{ matrix.target == 'test' }}
29+
with:
30+
path: /tmp/kubebuilder-tools-*.tar.gz
31+
key: ${{ runner.os }}-tmp-${{ matrix.target }}-${{ hashFiles('scripts/fetch_ext_bins.sh') }}
32+
restore-keys: |
33+
${{ runner.os }}-tmp-${{ matrix.target }}-
34+
${{ runner.os }}-tmp-
2035
- name: ${{ matrix.target }}
2136
run: make ${{ matrix.target }}
2237
codespell:
2338
name: Codespell
2439
runs-on: ubuntu-latest
2540
steps:
2641
- name: Checkout Code
27-
uses: actions/[email protected].4
42+
uses: actions/[email protected].5
2843
- name: Codespell
2944
uses: codespell-project/actions-codespell@master
3045
with:

.github/workflows/release.yaml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# workflow to release assets as part of the release
2+
name: Upload Release Asset
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
jobs:
11+
manager-image:
12+
name: Build and push manager image
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/[email protected]
17+
- uses: ./.github/actions/setup-go
18+
- name: Set up QEMU
19+
uses: docker/setup-qemu-action@v1
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v1
22+
- name: Cache Docker layers
23+
uses: actions/cache@v2
24+
with:
25+
path: /tmp/.buildx-cache
26+
key: ${{ runner.os }}-buildx-manager-${{ github.sha }}
27+
restore-keys: |
28+
${{ runner.os }}-buildx-manager-
29+
${{ runner.os }}-buildx-
30+
- name: Docker manager metadata
31+
id: meta
32+
uses: docker/metadata-action@v3
33+
with:
34+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
35+
flavor: latest=false
36+
tags: type=ref,event=tag
37+
- name: Log in to the Container registry
38+
uses: docker/login-action@v1
39+
with:
40+
registry: ${{ env.REGISTRY }}
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
- name: Setup Env
44+
run: |
45+
DOCKER_BUILD_LDFLAGS="$(hack/version.sh)"
46+
echo 'DOCKER_BUILD_LDFLAGS<<EOF' >> $GITHUB_ENV
47+
echo $DOCKER_BUILD_LDFLAGS >> $GITHUB_ENV
48+
echo 'EOF' >> $GITHUB_ENV
49+
- name: Build and push manager image
50+
uses: docker/build-push-action@v2
51+
with:
52+
context: .
53+
push: true
54+
build-args: |
55+
LDFLAGS=${{ env.DOCKER_BUILD_LDFLAGS }}
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
platforms: linux/amd64,linux/arm64
59+
cache-from: type=local,src=/tmp/.buildx-cache
60+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
61+
- name: Move cache
62+
# Temp fix
63+
# https://github.com/docker/build-push-action/issues/252
64+
# https://github.com/moby/buildkit/issues/1896
65+
run: |
66+
rm -rf /tmp/.buildx-cache
67+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
68+
release:
69+
name: Release
70+
runs-on: ubuntu-latest
71+
needs:
72+
- manager-image
73+
steps:
74+
- name: Checkout code
75+
uses: actions/[email protected]
76+
- uses: ./.github/actions/setup-go
77+
- uses: actions/cache@v2
78+
with:
79+
path: hack/tools/bin
80+
key: ${{ runner.os }}-tools-bin-release-${{ hashFiles('Makefile') }}
81+
restore-keys: |
82+
${{ runner.os }}-tools-bin-release-
83+
${{ runner.os }}-tools-bin-
84+
- name: Docker manager metadata
85+
id: meta
86+
uses: docker/metadata-action@v3
87+
with:
88+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
89+
flavor: latest=false
90+
tags: type=ref,event=tag
91+
- name: manifest
92+
run: make release
93+
env:
94+
TAG: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
95+
- name: Generate Release Notes
96+
run: |
97+
release_notes=$(gh api repos/{owner}/{repo}/releases/generate-notes -F tag_name=${{ github.ref }} --jq .body)
98+
echo 'RELEASE_NOTES<<EOF' >> $GITHUB_ENV
99+
echo "${release_notes}" >> $GITHUB_ENV
100+
echo 'EOF' >> $GITHUB_ENV
101+
env:
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
OWNER: ${{ github.repository_owner }}
104+
REPO: ${{ github.event.repository.name }}
105+
- name: Create Release
106+
id: create_release
107+
uses: actions/create-release@v1
108+
env:
109+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110+
with:
111+
tag_name: ${{ github.ref }}
112+
release_name: Release ${{ github.ref }}
113+
body: ${{ env.RELEASE_NOTES }}
114+
draft: false
115+
prerelease: false

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ ENVSUBST_VER := v1.2.0
6969
ENVSUBST_BIN := envsubst
7070
ENVSUBST := $(TOOLS_BIN_DIR)/$(ENVSUBST_BIN)
7171

72-
GOLANGCI_LINT_VER := v1.41.1
72+
GOLANGCI_LINT_VER := v1.42.1
7373
GOLANGCI_LINT_BIN := golangci-lint
7474
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
7575

0 commit comments

Comments
 (0)