Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Commit

Permalink
Build release iamges with Github action
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmxs committed Sep 3, 2021
1 parent 0cd8e3a commit 7b4747f
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .github/.goreleaser-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
project_name: storageos-operator
builds:
- binary: manager
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
- arm64
- arm
goarm:
- 7
snapshot:
name_template: "{{ .Tag }}"
dockers:
- image_templates:
- storageos/operator:{{ .Tag }}-amd64
dockerfile: Dockerfile
use_buildx: true
goos: linux
goarch: amd64
build_flag_templates:
- "--pull"
- "--build-arg=ARCH=linux/amd64"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.name={{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--label=org.opencontainers.image.source={{ .GitURL }}"
- "--platform=linux/amd64"
extra_files:
- channels/
- image_templates:
- storageos/operator:{{ .Tag }}-arm64
dockerfile: Dockerfile
use_buildx: true
goos: linux
goarch: arm64
build_flag_templates:
- "--pull"
- "--build-arg=ARCH=linux/arm64"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.name={{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--label=org.opencontainers.image.source={{ .GitURL }}"
- "--platform=linux/arm64"
extra_files:
- channels/
- image_templates:
- storageos/operator:{{ .Tag }}-arm
dockerfile: Dockerfile
use_buildx: true
goos: linux
goarch: arm
goarm: 7
build_flag_templates:
- "--pull"
- "--build-arg=ARCH=linux/arm"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.name={{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--label=org.opencontainers.image.source={{ .GitURL }}"
- "--platform=linux/arm/v7"
extra_files:
- channels/

docker_manifests:
- name_template: storageos/operator:{{ .Tag }}
image_templates:
- storageos/operator:{{ .Tag }}-amd64
- storageos/operator:{{ .Tag }}-arm64
- storageos/operator:{{ .Tag }}-arm
82 changes: 82 additions & 0 deletions .github/workflows/release-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Publish release image

on:
push:
tags:
- 'v*'

jobs:
publish-image:
runs-on: ubuntu-latest
name: Publish container image
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
buildkitd-flags: "--debug"
- name: Login to container registry
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DH_USERNAME }}
password: ${{ secrets.DH_PASSWORD }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: --snapshot --rm-dist --config .github/.goreleaser-release.yaml --skip-validate
- name: Set image tag env var
# Refer https://stackoverflow.com/a/58178121 for git tag extraction.
run: |
echo "IMG_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "MANIFEST_LIST=storageos/operator:${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "AMD_IMG=storageos/operator:${GITHUB_REF#refs/*/}-amd64" >> $GITHUB_ENV
echo "ARM64_IMG=storageos/operator:${GITHUB_REF#refs/*/}-arm64" >> $GITHUB_ENV
echo "ARM_IMG=storageos/operator:${GITHUB_REF#refs/*/}-arm" >> $GITHUB_ENV
- name: Push container image
run: |
docker push ${{ env.AMD_IMG }}
docker push ${{ env.ARM64_IMG }}
docker push ${{ env.ARM_IMG }}
- name: Create and publish manifest list
run: |
docker manifest create ${{ env.MANIFEST_LIST }} \
${{ env.AMD_IMG }} ${{ env.ARM64_IMG }} ${{ env.ARM_IMG }}
docker manifest push ${{ env.MANIFEST_LIST }}
publish-manifests-image:
runs-on: ubuntu-latest
name: Publish manifests container image
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Login to container registry
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DH_USERNAME }}
password: ${{ secrets.DH_PASSWORD }}
- name: Set image tag env var
# Refer https://stackoverflow.com/a/58178121 for git tag extraction.
run: |
echo "IMG_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "MANIFEST_LIST=storageos/operator:${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "MANIFESTS_IMG=storageos/operator-manifests:${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Run manifests image build
run: MANIFESTS_IMG=${{ env.MANIFESTS_IMG }} IMG=${{ env.MANIFEST_LIST }} make docker-build-manifests
- name: Push manifests container image
run: docker push ${{ env.MANIFESTS_IMG }}

0 comments on commit 7b4747f

Please sign in to comment.