diff --git a/.github/.goreleaser-release.yaml b/.github/.goreleaser-release.yaml new file mode 100644 index 00000000..0e43d9d7 --- /dev/null +++ b/.github/.goreleaser-release.yaml @@ -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 diff --git a/.github/workflows/release-image.yaml b/.github/workflows/release-image.yaml new file mode 100644 index 00000000..a45d9337 --- /dev/null +++ b/.github/workflows/release-image.yaml @@ -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 }}