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

Add new release documentation and release verification workflow #6113

Merged
merged 12 commits into from
Sep 13, 2023
84 changes: 84 additions & 0 deletions .github/scripts/release-verification.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# ------------------------------------------------------------
# Copyright 2023 The Radius Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------

# RELEASE_VERSION_NUMBER is the Radius release version number
# (e.g. 0.24.0, 0.24.0-rc1)
RELEASE_VERSION_NUMBER=$1

if [[ -z "${RELEASE_VERSION_NUMBER}" ]]; then
echo "Error: RELEASE_VERSION_NUMBER is not set."
exit 1
fi

# EXPECTED_CLI_VERSION is the same as the RELEASE_VERSION_NUMBER
EXPECTED_CLI_VERSION=$RELEASE_VERSION_NUMBER

EXPECTED_TAG_VERSION=$RELEASE_VERSION_NUMBER
# if RELEASE_VERSION_NUMBER doesn't contain -rc, then it is a prerelease.
# In that case, we need to set expected tag version to the major.minor of the
# release version number
if [[ $RELEASE_VERSION_NUMBER != *"rc"* ]]; then
EXPECTED_TAG_VERSION=$(echo $RELEASE_VERSION_NUMBER | cut -d '.' -f 1,2)
fi

echo "RELEASE_VERSION_NUMBER: ${RELEASE_VERSION_NUMBER}"
echo "EXPECTED_CLI_VERSION: ${EXPECTED_CLI_VERSION}"
echo "EXPECTED_TAG_VERSION: ${EXPECTED_TAG_VERSION}"

curl https://get.radapp.dev/tools/rad/$RELEASE_VERSION_NUMBER/linux-x64/rad --output rad
chmod +x ./rad

RELEASE_FROM_RAD_VERSION=$(./rad version -o json | jq -r '.release')
VERSION_FROM_RAD_VERSION=$(./rad version -o json | jq -r '.version')

if [[ "${RELEASE_FROM_RAD_VERSION}" != "${EXPECTED_CLI_VERSION}" ]]; then
echo "Error: Release: ${RELEASE_FROM_RAD_VERSION} from rad version does not match the desired release: ${EXPECTED_CLI_VERSION}."
exit 1
fi

if [[ "${VERSION_FROM_RAD_VERSION}" != "v${EXPECTED_CLI_VERSION}" ]]; then
echo "Error: Version: ${VERSION_FROM_RAD_VERSION} from rad version does not match the desired version: v${EXPECTED_CLI_VERSION}."
exit 1
fi

kind create cluster
./rad install kubernetes

EXPECTED_APPCORE_RP_IMAGE="radius.azurecr.io/applications-rp:${EXPECTED_TAG_VERSION}"
EXPECTED_UCP_IMAGE="radius.azurecr.io/ucpd:${EXPECTED_TAG_VERSION}"
EXPECTED_DE_IMAGE="radius.azurecr.io/deployment-engine:${EXPECTED_TAG_VERSION}"

APPCORE_RP_IMAGE=$(kubectl describe pods -n radius-system -l control-plane=applications-rp | awk '/^.*Image:/ {print $2}')
UCP_IMAGE=$(kubectl describe pods -n radius-system -l control-plane=ucp | awk '/^.*Image:/ {print $2}')
DE_IMAGE=$(kubectl describe pods -n radius-system -l control-plane=bicep-de | awk '/^.*Image:/ {print $2}')


if [[ "${APPCORE_RP_IMAGE}" != "${EXPECTED_APPCORE_RP_IMAGE}" ]]; then
echo "Error: Applications RP image: ${APPCORE_RP_IMAGE} does not match the desired image: ${EXPECTED_APPCORE_RP_IMAGE}."
exit 1
fi

if [[ "${UCP_IMAGE}" != "${EXPECTED_UCP_IMAGE}" ]]; then
echo "Error: UCP image: ${UCP_IMAGE} does not match the desired image: ${EXPECTED_UCP_IMAGE}."
exit 1
fi

if [[ "${DE_IMAGE}" != "${EXPECTED_DE_IMAGE}" ]]; then
echo "Error: DE image: ${DE_IMAGE} does not match the desired image: ${EXPECTED_DE_IMAGE}."
exit 1
fi

echo "Release verification successful."
45 changes: 45 additions & 0 deletions .github/scripts/validate_semver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# ------------------------------------------------------------
# Copyright 2023 The Radius Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------

# This script validates that the provided version is a valid semver

import os
import re
import sys

def main():
if len(sys.argv) != 2:
print("Usage: validate_semver.py <version>")
sys.exit(1)

# From https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
SEMVER_REGEX = r"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"

pattern = re.compile(SEMVER_REGEX)

version = sys.argv[1]
match = pattern.search(version)

# If no match, then return an error (provided version is not valid semver)
if match is None:
print("Provided version is not valid semver")
sys.exit(1)
else:
print("Provided version is valid semver")
sys.exit(0)

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ jobs:
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login -u ${{ github.actor }} --password-stdin ${{ env.OCI_REGISTRY }}
helm push ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}/radius-${{ env.CHART_VERSION }}.tgz oci://${{ env.OCI_REGISTRY }}/${{ env.OCI_REPOSITORY }}
publish_release:
name: Publish rad CLI binaries
name: Publish GitHub Release
needs: [ 'build' ]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/release-verification.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# ------------------------------------------------------------
# Copyright 2023 The Radius Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------

name: Release verification

on:
workflow_dispatch:
inputs:
version:
description: 'Radius version number to use (e.g. 0.24, 0.24.0, 0.24.0-rc1)'
required: true
default: ''
type: string

jobs:
release-verification:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
- name: Ensure inputs.version is valid semver
run: |
python ./.github/scripts/validate_semver.py ${{ inputs.version }}
- name: Run release verification
run: |
./.github/scripts/release-verification.sh ${{ inputs.version }}
Loading