diff --git a/.github/scripts/release-samples.sh b/.github/scripts/release-samples.sh index 9c6d7764..115dc9a0 100755 --- a/.github/scripts/release-samples.sh +++ b/.github/scripts/release-samples.sh @@ -37,6 +37,22 @@ echo "Channel version: ${CHANNEL_VERSION}" echo "Creating release branch for ${REPOSITORY}..." pushd $REPOSITORY + git checkout -B "${CHANNEL_VERSION}" + +# Update bicepconfig.json br:biceptypes.azurecr.io/radius with the CHANNEL +BICEPCONFIG_RADIUS_STRING_REPLACEMENT="br:biceptypes.azurecr.io/radius:${CHANNEL}" +awk -v REPLACEMENT="${BICEPCONFIG_RADIUS_STRING_REPLACEMENT}" '{gsub(/br:biceptypes\.azurecr\.io\/radius:latest/, REPLACEMENT); print}' bicepconfig.json > bicepconfig_updated.json +mv bicepconfig_updated.json bicepconfig.json + +# Update bicepconfig.json br:biceptypes.azurecr.io/aws with the CHANNEL +BICEPCONFIG_AWS_STRING_REPLACEMENT="br:biceptypes.azurecr.io/aws:${CHANNEL}" +awk -v REPLACEMENT="${BICEPCONFIG_AWS_STRING_REPLACEMENT}" '{gsub(/br:biceptypes\.azurecr\.io\/aws:latest/, REPLACEMENT); print}' bicepconfig.json > bicepconfig_updated.json +mv bicepconfig_updated.json bicepconfig.json + +# Push changes to GitHub +git add --all +git commit -m "Update samples for ${VERSION}" git push origin "${CHANNEL_VERSION}" + popd diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 750fd9ad..dd24922b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -4,9 +4,8 @@ on: workflow_dispatch: inputs: version: - description: "Radius version number to use (e.g. 0.1.0, 0.1.0-rc1, edge). Defaults to edge." + description: "Radius version number to use (e.g. 0.1.0, 0.1.0-rc1, edge)." required: false - default: "edge" type: string push: branches: @@ -93,7 +92,6 @@ jobs: credential: aws enableDapr: false env: - BRANCH: ${{ github.base_ref || github.ref_name }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} AZURE_LOCATION: westus3 AWS_REGION: us-west-2 @@ -123,6 +121,49 @@ jobs: echo "TEST_EKS_CLUSTER_NAME=eks-${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT echo "RUN_TEST=${RUN_TEST}" >> $GITHUB_OUTPUT echo "ENABLE_DAPR=${ENABLE_DAPR}" >> $GITHUB_OUTPUT + - name: Generate Radius version variables + id: gen-radius-version + if: steps.gen-id.outputs.RUN_TEST == 'true' + run: | + RADIUS_VERSION=edge + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + RADIUS_VERSION=${{ github.event.inputs.version }} + elif [[ "${{ github.event_name }}" == "push" ]]; then + # Get the target branch of the push event + TARGET_BRANCH=${{ github.ref }} + if [[ "$TARGET_BRANCH" == "refs/heads/edge" ]]; then + RADIUS_VERSION=edge + elif [[ "$TARGET_BRANCH" =~ ^refs/heads/v[0-9]+\.[0-9]+$ ]]; then + # Example: refs/heads/v0.1 -> 0.1 + RADIUS_VERSION=$(echo ${{ github.ref }} | cut -d '/' -f 3 | cut -d 'v' -f 2) + fi + elif [[ "${{ github.event_name }}" == "pull_request" ]]; then + # Get the target branch of the pull request + TARGET_BRANCH=${{ github.event.pull_request.base.ref }} + if [[ "$TARGET_BRANCH" == "edge" ]]; then + RADIUS_VERSION=edge + elif [[ "$TARGET_BRANCH" =~ ^refs/pull/v[0-9]+\.[0-9]+/merge$ ]]; then + # Example: refs/pull/v0.1/merge -> 0.1 + RADIUS_VERSION=$(echo ${{ github.ref }} | cut -d '/' -f 3 | cut -d 'v' -f 2) + fi + elif [[ "${{ github.event_name }}" == "schedule" ]]; then + # Get the branch of the schedule event + TARGET_BRANCH=${{ github.ref }} + if [[ "$TARGET_BRANCH" == "refs/heads/edge" ]]; then + RADIUS_VERSION=edge + elif [[ "$TARGET_BRANCH" =~ ^refs/heads/v[0-9]+\.[0-9]+$ ]]; then + # Example: refs/heads/v0.1 -> 0.1 + RADIUS_VERSION=$(echo ${{ github.ref }} | cut -d '/' -f 3 | cut -d 'v' -f 2) + else + echo "Invalid branch name: $TARGET_BRANCH" + exit 1 + fi + else + echo "Invalid event name: ${{ github.event_name }}" + exit 1 + fi + + echo "RADIUS_VERSION=$RADIUS_VERSION" >> $GITHUB_OUTPUT - name: Checkout code if: steps.gen-id.outputs.RUN_TEST == 'true' uses: actions/checkout@v4 @@ -213,11 +254,7 @@ jobs: - name: Download rad CLI if: steps.gen-id.outputs.RUN_TEST == 'true' run: | - RADIUS_VERSION="${{ inputs.version }}" - if [[ -z "${{ inputs.version }}" ]]; then - RADIUS_VERSION=edge - fi - ./.github/scripts/install-radius.sh $RADIUS_VERSION + ./.github/scripts/install-radius.sh ${{ steps.gen-radius-version.outputs.RADIUS_VERSION }} - name: Initialize default environment if: steps.gen-id.outputs.RUN_TEST == 'true' run: | @@ -231,10 +268,10 @@ jobs: rad group switch default rad env create default rad env switch default - rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/rediscaches:latest --resource-type Applications.Datastores/redisCaches - rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/mongodatabases:latest --resource-type Applications.Datastores/mongoDatabases - rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/sqldatabases:latest --resource-type Applications.Datastores/sqlDatabases - rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/rabbitmqqueues:latest --resource-type Applications.Messaging/rabbitMQQueues + rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/rediscaches:${{ steps.gen-radius-version.outputs.RADIUS_VERSION }} --resource-type Applications.Datastores/redisCaches + rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/mongodatabases:${{ steps.gen-radius-version.outputs.RADIUS_VERSION }} --resource-type Applications.Datastores/mongoDatabases + rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/sqldatabases:${{ steps.gen-radius-version.outputs.RADIUS_VERSION }} --resource-type Applications.Datastores/sqlDatabases + rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/rabbitmqqueues:${{ steps.gen-radius-version.outputs.RADIUS_VERSION }} --resource-type Applications.Messaging/rabbitMQQueues - name: Configure cloud credentials if: steps.gen-id.outputs.RUN_TEST == 'true' && ( matrix.credential == 'azure' || matrix.credential == 'aws') run: |