From 34a9facb260596ab087c2b5fcd21ca1ee7cedfa0 Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Mon, 21 Aug 2023 13:21:02 -0700 Subject: [PATCH 1/8] Adding samples release automation --- .github/scripts/release-samples.sh | 42 ++++++++++++++++++++++++++++ .github/workflows/release.yaml | 44 ++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100755 .github/scripts/release-samples.sh create mode 100644 .github/workflows/release.yaml diff --git a/.github/scripts/release-samples.sh b/.github/scripts/release-samples.sh new file mode 100755 index 00000000..9c6d7764 --- /dev/null +++ b/.github/scripts/release-samples.sh @@ -0,0 +1,42 @@ +# ------------------------------------------------------------ +# 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. +# ------------------------------------------------------------ + +set -xe + +VERSION_NUMBER=$1 # (e.g. 0.1.0) +REPOSITORY="samples" + +if [[ -z "$VERSION_NUMBER" ]]; then + echo "Error: VERSION_NUMBER is not set." + exit 1 +fi + +# CHANNEL is the major and minor version of the VERSION_NUMBER (e.g. 0.1) +CHANNEL="$(echo $VERSION_NUMBER | cut -d '.' -f 1,2)" + +# CHANNEL_VERSION is the version with the 'v' prefix (e.g. v0.1) +CHANNEL_VERSION="v${CHANNEL}" + +echo "Version number: ${VERSION_NUMBER}" +echo "Channel: ${CHANNEL}" +echo "Channel version: ${CHANNEL_VERSION}" + +echo "Creating release branch for ${REPOSITORY}..." + +pushd $REPOSITORY +git checkout -B "${CHANNEL_VERSION}" +git push origin "${CHANNEL_VERSION}" +popd diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..8798b134 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,44 @@ +name: Release samples + +on: + workflow_dispatch: + inputs: + version: + description: 'Radius version number to use (e.g. 0.22.0, 0.23.0-rc1)' + required: true + default: '' + type: string + +jobs: + upmerge: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.GH_RAD_CI_BOT_PAT }} + ref: edge + path: docs + - name: Configure git + run: | + git config --global user.email "radiuscoreteam@service.microsoft.com" + git config --global user.name "Radius CI Bot" + - name: Ensure inputs.version is valid semver + run: | + python ./.github/scripts/validate_semver.py ${{ inputs.version }} + - name: Parse release channel + id: parse_release_channel + run: | + # CHANNEL is the major and minor version of the VERSION_NUMBER (e.g. 0.1) + CHANNEL="$(echo ${{ inputs.version }} | cut -d '.' -f 1,2)" + echo "channel=$CHANNEL" >> $GITHUB_OUTPUT + - name: Release samples + run: | + ./docs/.github/scripts/release-samples.sh ${{ inputs.version }} + - name: Change the default branch + run: | + gh api \ + --method PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/project-radius/radius \ + -f default_branch='v${{ steps.parse_release_channel.outputs.channel }}' From 7d3a3fe94823626f563cf37fa9219ebefdc356bc Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Mon, 21 Aug 2023 13:21:49 -0700 Subject: [PATCH 2/8] bug --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8798b134..026b5bb4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -40,5 +40,5 @@ jobs: --method PATCH \ -H "Accept: application/vnd.github+json" \ -H "X-GitHub-Api-Version: 2022-11-28" \ - /repos/project-radius/radius \ + /repos/project-radius/samples \ -f default_branch='v${{ steps.parse_release_channel.outputs.channel }}' From fc37fef75e1d0ca0268c47091e62316dc63c7a4a Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Mon, 21 Aug 2023 13:23:09 -0700 Subject: [PATCH 3/8] nit --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 026b5bb4..c5f981ff 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -24,7 +24,7 @@ jobs: git config --global user.name "Radius CI Bot" - name: Ensure inputs.version is valid semver run: | - python ./.github/scripts/validate_semver.py ${{ inputs.version }} + python ./docs/.github/scripts/validate_semver.py ${{ inputs.version }} - name: Parse release channel id: parse_release_channel run: | From be8122f16cc92f15ff59ca1b046a18a0236d584d Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Mon, 21 Aug 2023 13:23:45 -0700 Subject: [PATCH 4/8] nit --- .github/workflows/release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c5f981ff..60675b36 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -17,14 +17,14 @@ jobs: with: token: ${{ secrets.GH_RAD_CI_BOT_PAT }} ref: edge - path: docs + path: samples - name: Configure git run: | git config --global user.email "radiuscoreteam@service.microsoft.com" git config --global user.name "Radius CI Bot" - name: Ensure inputs.version is valid semver run: | - python ./docs/.github/scripts/validate_semver.py ${{ inputs.version }} + python ./samples/.github/scripts/validate_semver.py ${{ inputs.version }} - name: Parse release channel id: parse_release_channel run: | From 662ffc33c582e272fe8d2fc0c636954777c95cec Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Mon, 21 Aug 2023 14:12:15 -0700 Subject: [PATCH 5/8] nit --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 60675b36..928a6659 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -33,7 +33,7 @@ jobs: echo "channel=$CHANNEL" >> $GITHUB_OUTPUT - name: Release samples run: | - ./docs/.github/scripts/release-samples.sh ${{ inputs.version }} + ./samples/.github/scripts/release-samples.sh ${{ inputs.version }} - name: Change the default branch run: | gh api \ From bcc02dcc763eeee8461a03dd46e4951e71c59fe8 Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Tue, 22 Aug 2023 14:25:45 -0700 Subject: [PATCH 6/8] PR --- .github/workflows/release.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 928a6659..526b67d2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,6 +9,9 @@ on: default: '' type: string +env: + GITHUB_TOKEN: ${{ secrets.GH_RAD_CI_BOT_PAT }} + jobs: upmerge: runs-on: ubuntu-latest From c56065ca0c9738c5db2df8920567d09d02738a50 Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Tue, 22 Aug 2023 14:25:50 -0700 Subject: [PATCH 7/8] PR --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 526b67d2..3ef1f6d4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -13,7 +13,7 @@ env: GITHUB_TOKEN: ${{ secrets.GH_RAD_CI_BOT_PAT }} jobs: - upmerge: + release-samples: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From b1e177f74357b305fcb34b5301b09209f1d1375b Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Wed, 23 Aug 2023 16:07:16 -0700 Subject: [PATCH 8/8] PR --- .github/workflows/release.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3ef1f6d4..714a1e58 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -11,6 +11,8 @@ on: env: GITHUB_TOKEN: ${{ secrets.GH_RAD_CI_BOT_PAT }} + GITHUB_EMAIL: 'radiuscoreteam@service.microsoft.com' + GITHUB_USER: 'Radius CI Bot' jobs: release-samples: @@ -23,8 +25,8 @@ jobs: path: samples - name: Configure git run: | - git config --global user.email "radiuscoreteam@service.microsoft.com" - git config --global user.name "Radius CI Bot" + git config --global user.email "${{ env.GITHUB_EMAIL }}" + git config --global user.name "${{ env.GITHUB_USER }}" - name: Ensure inputs.version is valid semver run: | python ./samples/.github/scripts/validate_semver.py ${{ inputs.version }}