Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use bundle release action for operator catalog release #645

Merged
merged 3 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 13 additions & 26 deletions .github/workflows/bundle-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Function-Mesh Release
name: Function-Mesh Bundle Release (Manually)

on:
workflow_dispatch:
Expand All @@ -9,7 +9,6 @@ on:

jobs:
operatorhub:
if: startsWith(github.ref, 'refs/tags/v')
name: publish to operatorhub.io
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -122,7 +121,6 @@ jobs:
popd

openshift:
if: startsWith(github.ref, 'refs/tags/v')
name: publish to openshift certificated
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -198,21 +196,22 @@ jobs:
CATALOG_BRANCH_TAG: latest
CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID: ${{ secrets.CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID }}
run: |
VERSION=$(echo $VERSION|cut -c 2-)
echo $VERSION
make redhat-certificated-image-build
docker tag $IMAGE_TAG_BASE:$VERSION quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:$VERSION
docker push quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:$VERSION
docker tag $IMAGE_TAG_BASE:v$VERSION quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:v$VERSION
docker push quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:v$VERSION

- name: Trigger openshift preflight test
env:
VERSION: ${{ inputs.tag }}
CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID: ${{ secrets.CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID }}
PFLT_PYXIS_API_TOKEN: ${{ secrets.PFLT_PYXIS_API_TOKEN }}
REDHAT_CERTITICATED_CONTAINER_AUTHFILE: ${{ secrets.REDHAT_CERTITICATED_CONTAINER_AUTHFILE }}
REDHAT_CERTIFICATED_CONTAINER_AUTHFILE: ${{ secrets.REDHAT_CERTIFICATED_CONTAINER_AUTHFILE }}
run: |
echo $VERSION
mkdir ./artifacts
echo $REDHAT_CERTITICATED_CONTAINER_AUTHFILE > ./authfile.json
echo $REDHAT_CERTIFICATED_CONTAINER_AUTHFILE > ./authfile.json
docker run -it --rm --security-opt=label=disable --env PFLT_LOGLEVEL=trace --env PFLT_ARTIFACTS=/artifacts --env PFLT_LOGFILE=/artifacts/preflight.log --env PFLT_CERTIFICATION_PROJECT_ID=$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID --env PFLT_PYXIS_API_TOKEN=$PFLT_PYXIS_API_TOKEN --env PFLT_DOCKERCONFIG=/temp-authfile.json -v ./artifacts:/artifacts -v ./authfile.json:/temp-authfile.json:ro quay.io/opdev/preflight:stable check container quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:$VERSION --submit

- name: Label the image as latest
Expand All @@ -222,14 +221,14 @@ jobs:
IMAGE_TAG_BASE: registry.connect.redhat.com/streamnative/function-mesh
CATALOG_BRANCH_TAG: latest
CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID: ${{ secrets.CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID }}
PFLT_PYXIS_API_TOKEN: ${{ secrets.PFLT_PYXIS_API_TOKEN }}
run: |
echo $VERSION
docker tag $IMAGE_TAG_BASE:$VERSION quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:latest
docker push quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:latest
docker rmi quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:latest
curl -H "X-API-KEY: $PFLT_PYXIS_API_TOKEN" -s "https://catalog.redhat.com/api/containers/v1/projects/certification/id/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID/images?filter=repositories.tags.name==$VERSION"
curl -H "X-API-KEY: $PFLT_PYXIS_API_TOKEN" -s "https://catalog.redhat.com/api/containers/v1/projects/certification/id/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID/images?filter=repositories.tags.name==$VERSION" | jq --exit-status '.data[0]' >/dev/null
docker rmi quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:$VERSION
docker pull quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:$VERSION
docker inspect quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:$VERSION
docker pull registry.connect.redhat.com/streamnative/function-mesh:$VERSION
docker inspect registry.connect.redhat.com/streamnative/function-mesh:$VERSION

- name: Build the openshift bundle
env:
Expand All @@ -239,6 +238,7 @@ jobs:
CATALOG_BRANCH_TAG: latest
CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID: ${{ secrets.CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID }}
run: |
VERSION=$(echo $VERSION|cut -c 2-)
echo $VERSION
make redhat-certificated-bundle redhat-certificated-bundle-build

Expand All @@ -254,30 +254,17 @@ jobs:
GITHUB_TOKEN: ${{ secrets.SNBOT_GITHUB_TOKEN }}
VERSION: ${{ inputs.tag }}
run: |
# install operator-manifest-tools
wget -q https://github.com/operator-framework/operator-manifest-tools/releases/download/v0.2.2/operator-manifest-tools_0.2.2_linux_amd64 -O operator-manifest-tools
chmod +x operator-manifest-tools
mv operator-manifest-tools /usr/local/bin

# install skopeo
sudo apt-get -y install skopeo

pushd certified-operators
echo $VERSION
export BRANCH=function-mesh-operator-$VERSION
echo $BRANCH
git push -d origin $BRANCH || echo 'Skip branch deletion'
git checkout -b $BRANCH

export TARGET_DIR=operators/function-mesh/${{ inputs.channel-tag }}
export TARGET_DIR=operators/function-mesh/$VERSION
mkdir -p $TARGET_DIR
cp -rf ../bundle.Dockerfile $TARGET_DIR
cp -rf ../bundle/* $TARGET_DIR
#
# export MANIFEST_DIR=$TARGET_DIR/manifests
# operator-manifest-tools pinning pin $MANIFEST_DIR
# operator-manifest-tools pinning replace $MANIFEST_DIR replacements.json
# rm references.json replacements.json

git add .
git commit -s -m "operator function-mesh ($VERSION)"
Expand Down
275 changes: 1 addition & 274 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,277 +93,4 @@ jobs:
file: install.sh
asset_name: install.sh
tag: ${{ github.ref }}
overwrite: true

operatorhub:
if: startsWith(github.ref, 'refs/tags/v')
name: publish to operatorhub.io
runs-on: ubuntu-latest
steps:
- name: clean disk
run: |
sudo swapoff -a
sudo rm -rf /swapfile /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo apt clean
docker rmi $(docker images -q) -f
df -h

- name: checkout
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up GO 1.20.4
uses: actions/setup-go@v1
with:
go-version: 1.20.4
id: go

- name: InstallKubebuilder
run: |
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.1/kubebuilder_2.3.1_linux_amd64.tar.gz | tar -xz -C /tmp/
sudo mv /tmp/kubebuilder_2.3.1_linux_amd64 /usr/local/kubebuilder
export PATH=$PATH:/usr/local/kubebuilder/bin

- name: Install operator-sdk
run: |
RELEASE_VERSION=v1.14.0
curl -LO "https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk_linux_amd64"
chmod +x operator-sdk_linux_amd64 && sudo mkdir -p /usr/local/bin/ && sudo mv operator-sdk_linux_amd64 /usr/local/bin/operator-sdk

- name: Set up yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/v4.30.4/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
yq --help

- name: Get vertical-pod-autoscaler crd
run: |
wget https://raw.githubusercontent.com/kubernetes/autoscaler/master/vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml -O config/crd/bases/vpa-v1-crd.yaml

- name: build release
id: build_release
env:
VERSION: ${{ github.event.release.tag_name }}
IMAGE_TAG_BASE: streamnative/function-mesh
CATALOG_BRANCH_TAG: latest
run: |
# convert vx.y.z to x.y.z because a valid semver is needed in creating the bundle
VERSION=$(echo $VERSION|cut -c 2-)
make release

- name: Login to Quay
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_DOCKER_USERNAME }}
password: ${{ secrets.QUAY_DOCKER_PASSWORD }}

- name: Build RedHat certificated bundle And Publish to Quay
env:
VERSION: ${{ github.event.release.tag_name }}
DOCKER_REPO: quay.io/streamnativeio
IMAGE_TAG_BASE: quay.io/streamnativeio/function-mesh
CATALOG_BRANCH_TAG: latest
run: |
# convert vx.y.z to x.y.z because a valid semver is needed in creating the bundle
VERSION=$(echo $VERSION|cut -c 2-)
echo $VERSION
make redhat-certificated-image-build redhat-certificated-image-push redhat-certificated-bundle redhat-certificated-bundle-build redhat-certificated-bundle-push

- name: Checkout streamnative community-operators
uses: actions/checkout@v3
with:
repository: streamnative/community-operators
path: community-operators
token: ${{ secrets.SNBOT_GITHUB_TOKEN }}

- name: Copy bundle to community-operators and create pr
env:
GITHUB_TOKEN: ${{ secrets.SNBOT_GITHUB_TOKEN }}
VERSION: ${{ github.event.release.tag_name }}
run: |
pushd community-operators
export VERSION=$(echo $VERSION|cut -c 2-)
echo $VERSION
export BRANCH=function-mesh-operator-$VERSION
echo $BRANCH
git push -d origin $BRANCH || echo 'Skip branch deletion'
git checkout -b $BRANCH

export TARGET_DIR=operators/function-mesh/$VERSION
mkdir -p $TARGET_DIR
cp -rf ../bundle.Dockerfile $TARGET_DIR
cp -rf ../bundle/* $TARGET_DIR

git add .
git commit -s -m "operator function-mesh ($VERSION)"
git push --set-upstream origin $BRANCH
gh pr create --title "operator function-mesh ($VERSION)" -F ../.github/openshift/community-operators -R k8s-operatorhub/community-operators
popd

openshift:
if: startsWith(github.ref, 'refs/tags/v')
name: publish to openshift certificated
runs-on: ubuntu-latest
steps:
- name: clean disk
run: |
sudo swapoff -a
sudo rm -rf /swapfile /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo apt clean
docker rmi $(docker images -q) -f
df -h

- name: checkout
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up GO 1.20.4
uses: actions/setup-go@v1
with:
go-version: 1.20.4
id: go

- name: InstallKubebuilder
run: |
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.1/kubebuilder_2.3.1_linux_amd64.tar.gz | tar -xz -C /tmp/
sudo mv /tmp/kubebuilder_2.3.1_linux_amd64 /usr/local/kubebuilder
export PATH=$PATH:/usr/local/kubebuilder/bin

- name: Install operator-sdk
run: |
RELEASE_VERSION=v1.14.0
curl -LO "https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk_linux_amd64"
chmod +x operator-sdk_linux_amd64 && sudo mkdir -p /usr/local/bin/ && sudo mv operator-sdk_linux_amd64 /usr/local/bin/operator-sdk

- name: Set up yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/v4.30.4/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
yq --help

- name: Get vertical-pod-autoscaler crd
run: |
wget https://raw.githubusercontent.com/kubernetes/autoscaler/master/vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml -O config/crd/bases/vpa-v1-crd.yaml

- name: build release
id: build_release
env:
VERSION: ${{ github.event.release.tag_name }}
IMAGE_TAG_BASE: streamnative/function-mesh
CATALOG_BRANCH_TAG: latest
run: |
VERSION=$(echo $VERSION|cut -c 2-)
make release

- name: Login to Quay for RedHat container certification
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.REDHAT_CERTIFICATED_CONTAINER_REGISTRY_USER }}
password: ${{ secrets.REDHAT_CERTIFICATED_CONTAINER_REGISTRY_PASSWORD }}

- name: Build Openshift certificated container And Publish to Quay
env:
VERSION: ${{ github.event.release.tag_name }}
DOCKER_REPO: registry.connect.redhat.com/streamnative
IMAGE_TAG_BASE: registry.connect.redhat.com/streamnative/function-mesh
CATALOG_BRANCH_TAG: latest
CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID: ${{ secrets.CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID }}
run: |
echo $VERSION
make redhat-certificated-image-build
docker tag $IMAGE_TAG_BASE:$VERSION quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:$VERSION
docker push quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:$VERSION

- name: Trigger openshift preflight test
env:
VERSION: ${{ github.event.release.tag_name }}
CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID: ${{ secrets.CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID }}
PFLT_PYXIS_API_TOKEN: ${{ secrets.PFLT_PYXIS_API_TOKEN }}
REDHAT_CERTITICATED_CONTAINER_AUTHFILE: ${{ secrets.REDHAT_CERTITICATED_CONTAINER_AUTHFILE }}
run: |
echo $VERSION
mkdir ./artifacts
echo $REDHAT_CERTITICATED_CONTAINER_AUTHFILE > ./authfile.json
docker run -it --rm --security-opt=label=disable --env PFLT_LOGLEVEL=trace --env PFLT_ARTIFACTS=/artifacts --env PFLT_LOGFILE=/artifacts/preflight.log --env PFLT_CERTIFICATION_PROJECT_ID=$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID --env PFLT_PYXIS_API_TOKEN=$PFLT_PYXIS_API_TOKEN --env PFLT_DOCKERCONFIG=/temp-authfile.json -v ./artifacts:/artifacts -v ./authfile.json:/temp-authfile.json:ro quay.io/opdev/preflight:stable check container quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:$VERSION --submit

- name: Label the image as latest
env:
VERSION: ${{ github.event.release.tag_name }}
DOCKER_REPO: registry.connect.redhat.com/streamnative
IMAGE_TAG_BASE: registry.connect.redhat.com/streamnative/function-mesh
CATALOG_BRANCH_TAG: latest
CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID: ${{ secrets.CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID }}
run: |
echo $VERSION
docker tag $IMAGE_TAG_BASE:$VERSION quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:latest
docker push quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:latest
docker rmi quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:latest
docker rmi quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:$VERSION
docker pull quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:$VERSION
docker inspect quay.io/redhat-isv-containers/$CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID:$VERSION

- name: Build the openshift bundle
env:
VERSION: ${{ github.event.release.tag_name }}
DOCKER_REPO: registry.connect.redhat.com/streamnative
IMAGE_TAG_BASE: registry.connect.redhat.com/streamnative/function-mesh
CATALOG_BRANCH_TAG: latest
CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID: ${{ secrets.CONTAINER_IMAGE_CERTIFICATION_PROJECT_ID }}
run: |
echo $VERSION
make redhat-certificated-bundle redhat-certificated-bundle-build

- name: Checkout streamnative certified-operators
uses: actions/checkout@v3
with:
repository: streamnative/certified-operators
path: certified-operators
token: ${{ secrets.SNBOT_GITHUB_TOKEN }}

- name: Copy bundle to certified-operators and create pr
env:
GITHUB_TOKEN: ${{ secrets.SNBOT_GITHUB_TOKEN }}
VERSION: ${{ github.event.release.tag_name }}
run: |
# install operator-manifest-tools
wget -q https://github.com/operator-framework/operator-manifest-tools/releases/download/v0.2.2/operator-manifest-tools_0.2.2_linux_amd64 -O operator-manifest-tools
chmod +x operator-manifest-tools
mv operator-manifest-tools /usr/local/bin

# install skopeo
sudo apt-get -y install skopeo

pushd certified-operators
echo $VERSION
export BRANCH=function-mesh-operator-$VERSION
echo $BRANCH
git push -d origin $BRANCH || echo 'Skip branch deletion'
git checkout -b $BRANCH

export TARGET_DIR=operators/function-mesh/${{ inputs.channel-tag }}
mkdir -p $TARGET_DIR
cp -rf ../bundle.Dockerfile $TARGET_DIR
cp -rf ../bundle/* $TARGET_DIR
#
# export MANIFEST_DIR=$TARGET_DIR/manifests
# operator-manifest-tools pinning pin $MANIFEST_DIR
# operator-manifest-tools pinning replace $MANIFEST_DIR replacements.json
# rm references.json replacements.json

git add .
git commit -s -m "operator function-mesh ($VERSION)"
git push --set-upstream origin $BRANCH
gh pr create --title "operator function-mesh ($VERSION)" --body "Signed-off-by: streamnativebot streamnativebot@streamnative.io" -R redhat-openshift-ecosystem/certified-operators
popd
overwrite: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ index.Dockerfile*
index_build_*/

*.bak
.DS_Store