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

[release-1.32] Verify promotion tag for patch releases #2780

Merged
merged 2 commits into from
Jul 23, 2024
Merged
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
88 changes: 88 additions & 0 deletions .github/workflows/validate-release-promotion.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
name: Validate Release Promotion

on:
pull_request:
branches:
- 'release-**'

jobs:
promotion:
if: ${{ github.event_name == 'pull_request' && contains(github.base_ref, 'release-') }}
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}
steps:

- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: 1.21.x

- name: Install yq
run: |
go install github.com/mikefarah/yq/v3@latest

- name: Checkout
uses: actions/checkout@v4
with:
path: ./src/github.com/openshift-knative/serverless-operator
fetch-depth: 0

- name: Merge upstream
if: github.event_name == 'pull_request'
working-directory: ./src/github.com/openshift-knative/serverless-operator
run: |
if ! git config user.name > /dev/null; then
git config user.name "John Doe"
fi
if ! git config user.email > /dev/null; then
git config user.email "johndoe@localhost"
fi
git remote add upstream https://github.com/openshift-knative/serverless-operator.git
git pull --no-rebase upstream ${{ github.base_ref }}
shell: bash

- name: Checkout openshift/release
uses: actions/checkout@v4
with:
branch: 'master'
repository: 'openshift/release'
path: ./src/github.com/openshift/release

- name: Verify promotion tag or name in openshift/release
working-directory: ./src/github.com/openshift/release
shell: bash
run: |
tag="release-$(yq read ../../openshift-knative/serverless-operator/olm-catalog/serverless-operator/project.yaml 'project.version')"
release=${{ github.base_ref }}

count=0

while IFS= read -r -d '' file
do
promotion_name=$(yq r "$file" 'promotion.to[0].name')
if [ "$promotion_name" != "" ] && [ "$promotion_name" != "${tag}" ]; then
count=$(( count + 1 ))
echo "File: $file"
echo "promotion.to[0].name: $promotion_name"
echo
fi
promotion_tag=$(yq r "$file" 'promotion.to[0].tag')
if [ "$promotion_tag" != "" ] && [ "$promotion_tag" != "${tag}" ]; then
count=$(( count + 1 ))
echo "File: $file"
echo "promotion.to[0].name: $promotion_tag"
echo
fi
done < <(find ci-operator/config/openshift-knative/serverless-operator -type f -name "*${release}*" -print0)

if [ $count -ne 0 ]; then
echo "## $count files with an unexpected promotion name or tag"
echo "1. Use the [release-generate-ci](https://github.com/openshift-knative/serverless-operator/actions/workflows/release-generate-ci.yaml?query=branch%3A${release}) GH actions workflow in serverless-operator on the $release branch with inputs:"
echo " - **use workflow from**: **$release**"
echo " - **branch**: **$release**"
echo " - **tag**: **$tag**"
echo "2. merge the created PR in openshift/release"
exit 1
fi
Loading