Skip to content

Commit

Permalink
ci: push release image when there is a tag (#158)
Browse files Browse the repository at this point in the history
The post submit workflow will build and push the addon manager image with "latest" tag, only the main branch's code is the latest, stop other branches.

Signed-off-by: zhujian <[email protected]>
  • Loading branch information
zhujian7 authored Mar 17, 2023
1 parent fd8e0c4 commit 9de90ed
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 6 deletions.
1 change: 0 additions & 1 deletion .github/workflows/go-postsubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
- release-*
workflow_dispatch: {}

env:
Expand Down
80 changes: 75 additions & 5 deletions .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ defaults:
working-directory: go/src/open-cluster-management.io/addon-framework

jobs:
release:
name: release
env:
name: prepare release env
runs-on: ubuntu-latest
steps:
- name: checkout code
Expand All @@ -31,13 +31,83 @@ jobs:
- name: get major release version
run: |
echo "MAJOR_RELEASE_VERSION=${RELEASE_VERSION%.*}" >> $GITHUB_ENV
echo "TRIMED_RELEASE_VERSION=${RELEASE_VERSION#v}" >> $GITHUB_ENV
outputs:
MAJOR_RELEASE_VERSION: ${{ env.MAJOR_RELEASE_VERSION }}
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
images:
name: images
runs-on: ubuntu-latest
needs: [ env ]
strategy:
matrix:
arch: [ amd64, arm64 ]
steps:
- name: checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/addon-framework
- name: install Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: install imagebuilder
run: go install github.com/openshift/imagebuilder/cmd/[email protected]
- name: pull base image
run: docker pull registry.access.redhat.com/ubi8/ubi-minimal:latest --platform=linux/${{ matrix.arch }}
- name: images
run: |
IMAGE_TAG=${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }} \
IMAGE_BUILD_EXTRA_FLAGS="--build-arg OS=linux --build-arg ARCH=${{ matrix.arch }}" \
make image-addon-manager
- name: push image
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login quay.io --username ${{ secrets.DOCKER_USER }} --password-stdin
docker push quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }}
image-manifest:
name: image manifest
runs-on: ubuntu-latest
needs: [ env, images ]
steps:
- name: checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/addon-framework
- name: create
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login quay.io --username ${{ secrets.DOCKER_USER }} --password-stdin
docker manifest create quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} \
quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 \
quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-arm64
- name: annotate
run: |
docker manifest annotate quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} \
quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 --arch amd64
docker manifest annotate quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} \
quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 --arch arm64
- name: push
run: |
docker manifest push quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}
release:
name: release
runs-on: ubuntu-latest
needs: [ env, image-manifest ]
steps:
- name: checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/addon-framework
- name: generate changelog
run: |
echo "# Work $RELEASE_VERSION" > /home/runner/work/changelog.txt
echo "- See the [CHANGELOG](https://github.com/open-cluster-management-io/addon-framework/blob/main/CHANGELOG/CHANGELOG-${MAJOR_RELEASE_VERSION}.md) for more details." >> /home/runner/addon-framework/changelog.txt
echo "# Addon Framework ${{ needs.env.outputs.RELEASE_VERSION }}" > /home/runner/work/changelog.txt
echo "- See the [CHANGELOG](https://github.com/open-cluster-management-io/addon-framework/blob/main/CHANGELOG/CHANGELOG-${{ needs.env.outputs.MAJOR_RELEASE_VERSION }}.md) for more details." >> /home/runner/work/changelog.txt
echo "- The released image is quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}" >> /home/runner/work/changelog.txt
- name: publish release
uses: softprops/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body_path: /home/runner/addon-framework/changelog.txt
body_path: /home/runner/work/changelog.txt

0 comments on commit 9de90ed

Please sign in to comment.