Skip to content

Commit

Permalink
Merge pull request #107 from detiber/prep-release
Browse files Browse the repository at this point in the history
Prepare workflows for release
  • Loading branch information
detiber authored Oct 18, 2021
2 parents 11ecb14 + 405e96a commit 2ba4a1e
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/[email protected].4
uses: actions/[email protected].5
with:
repository: kubernetes-sigs/image-builder
path: image-builder
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,31 @@ jobs:
target: ["verify", "lint", "test"]
steps:
- name: checkout
uses: actions/[email protected].4
uses: actions/[email protected].5
- uses: ./.github/actions/setup-go
- uses: actions/cache@v2
with:
path: hack/tools/bin
key: ${{ runner.os }}-tools-bin-${{ matrix.target }}-${{ hashFiles('Makefile') }}
restore-keys: |
${{ runner.os }}-tools-bin-${{ matrix.target }}-
${{ runner.os }}-tools-bin-
- uses: actions/cache@v2
if: ${{ matrix.target == 'test' }}
with:
path: /tmp/kubebuilder-tools-*.tar.gz
key: ${{ runner.os }}-tmp-${{ matrix.target }}-${{ hashFiles('scripts/fetch_ext_bins.sh') }}
restore-keys: |
${{ runner.os }}-tmp-${{ matrix.target }}-
${{ runner.os }}-tmp-
- name: ${{ matrix.target }}
run: make ${{ matrix.target }}
codespell:
name: Codespell
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/[email protected].4
uses: actions/[email protected].5
- name: Codespell
uses: codespell-project/actions-codespell@master
with:
Expand Down
115 changes: 115 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# workflow to release assets as part of the release
name: Upload Release Asset
on:
push:
tags:
- 'v*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
manager-image:
name: Build and push manager image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- uses: ./.github/actions/setup-go
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-manager-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-manager-
${{ runner.os }}-buildx-
- name: Docker manager metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: latest=false
tags: type=ref,event=tag
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Env
run: |
DOCKER_BUILD_LDFLAGS="$(hack/version.sh)"
echo 'DOCKER_BUILD_LDFLAGS<<EOF' >> $GITHUB_ENV
echo $DOCKER_BUILD_LDFLAGS >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Build and push manager image
uses: docker/build-push-action@v2
with:
context: .
push: true
build-args: |
LDFLAGS=${{ env.DOCKER_BUILD_LDFLAGS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Move cache
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
release:
name: Release
runs-on: ubuntu-latest
needs:
- manager-image
steps:
- name: Checkout code
uses: actions/[email protected]
- uses: ./.github/actions/setup-go
- uses: actions/cache@v2
with:
path: hack/tools/bin
key: ${{ runner.os }}-tools-bin-release-${{ hashFiles('Makefile') }}
restore-keys: |
${{ runner.os }}-tools-bin-release-
${{ runner.os }}-tools-bin-
- name: Docker manager metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: latest=false
tags: type=ref,event=tag
- name: manifest
run: make release
env:
TAG: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
- name: Generate Release Notes
run: |
release_notes=$(gh api repos/{owner}/{repo}/releases/generate-notes -F tag_name=${{ github.ref }} --jq .body)
echo 'RELEASE_NOTES<<EOF' >> $GITHUB_ENV
echo "${release_notes}" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: ${{ env.RELEASE_NOTES }}
draft: false
prerelease: false
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ENVSUBST_VER := v1.2.0
ENVSUBST_BIN := envsubst
ENVSUBST := $(TOOLS_BIN_DIR)/$(ENVSUBST_BIN)

GOLANGCI_LINT_VER := v1.41.1
GOLANGCI_LINT_VER := v1.42.1
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)

Expand Down

0 comments on commit 2ba4a1e

Please sign in to comment.