-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #283 from HumairAK/automated_release
Automated release
- Loading branch information
Showing
22 changed files
with
715 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
echo "Create a tag release for ${TARGET_VERSION_TAG} in ${REPOSITORY}" | ||
|
||
RELEASE_REPO_DIR=$(dirname ${WORKING_DIR})/repo_dir | ||
git clone \ | ||
--depth=1 \ | ||
--branch=${RELEASE_BRANCH} \ | ||
https://${GH_USER_NAME}:${GH_TOKEN}@github.com/${REPOSITORY} \ | ||
${RELEASE_REPO_DIR} | ||
cd ${RELEASE_REPO_DIR} | ||
|
||
gh release create ${TARGET_VERSION_TAG} --target ${RELEASE_BRANCH} --generate-notes --notes-start-tag ${PREVIOUS_VERSION_TAG} | ||
|
||
cat <<EOF >> /tmp/release-notes.md | ||
This is a release comprising of multiple repos: | ||
* DSP component for ${TARGET_VERSION_TAG} can be found [here](https://github.com/${GH_ORG}/data-science-pipelines/releases/tag/${TARGET_VERSION_TAG}) | ||
* DSPO component for ${TARGET_VERSION_TAG} can be found [here](https://github.com/${GH_ORG}/data-science-pipelines-operator/releases/tag/${TARGET_VERSION_TAG}) | ||
Version Table for components can be found [here](https://github.com/${GH_ORG}/data-science-pipelines-operator/blob/main/docs/release/compatibility.md) | ||
EOF | ||
|
||
echo "$(gh release view ${TARGET_VERSION_TAG} --json body --jq .body)" >> /tmp/release-notes.md | ||
|
||
echo "Release notes to be created:" | ||
cat /tmp/release-notes.md | ||
|
||
gh release edit ${TARGET_VERSION_TAG} --notes-file /tmp/release-notes.md | ||
rm /tmp/release-notes.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
cat <<EOF >> /tmp/body-file.txt | ||
Release created successfully: | ||
https://github.com/${GH_ORG}/data-science-pipelines-operator/releases/tag/${TARGET_VERSION_TAG} | ||
https://github.com/${GH_ORG}/data-science-pipelines/releases/tag/${TARGET_VERSION_TAG} | ||
EOF | ||
|
||
gh pr comment ${PR_NUMBER} --body-file /tmp/body-file.txt | ||
|
||
echo "::notice:: DSPO Release: https://github.com/${GH_ORG}/data-science-pipelines-operator/releases/tag/${TARGET_VERSION_TAG}" | ||
echo "::notice:: DSP Release: https://github.com/${GH_ORG}/data-science-pipelines/releases/tag/${TARGET_VERSION_TAG}" | ||
echo "::notice:: Feedback sent to PR." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
echo "::notice:: Performing Release PR Validation for: ${PR_NUMBER}" | ||
|
||
# Retrive PR Author: | ||
PR_AUTHOR=$(gh pr view ${PR_NUMBER} --json author -q .author.login) | ||
|
||
echo "Current OWNERS:" | ||
cat ./OWNERS | ||
|
||
echo "::notice:: Checking if PR author ${PR_AUTHOR} is DSPO Owner..." | ||
|
||
is_owner=$(cat ./OWNERS | var=${PR_AUTHOR} yq '[.approvers] | contains([env(var)])') | ||
if [[ $is_owner == "false" ]]; then | ||
echo "::error:: PR author ${PR_AUTHOR} is not an approver in OWNERS file. Only approvers can create releases." | ||
exit 1 | ||
fi | ||
|
||
echo "::notice:: PR author ${PR_AUTHOR} is an approver in DSPO OWNERS." | ||
|
||
echo "::notice:: Validation successful." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
cat ./config.yaml | ||
target_version_tag=$(yq .target_version_tag ./config.yaml) | ||
previous_version_tag=$(yq .previous_release_tag ./config.yaml) | ||
release_branch=$(yq .release_branch ./config.yaml) | ||
odh_org=$(yq .odh_org ./config.yaml) | ||
pr_number=$(cat ./pr_number) | ||
|
||
echo "pr_number=${pr_number}" >> $GITHUB_OUTPUT | ||
echo "target_version_tag=${target_version_tag}" >> $GITHUB_OUTPUT | ||
echo "previous_version_tag=${previous_version_tag}" >> $GITHUB_OUTPUT | ||
echo "release_branch=${release_branch}" >> $GITHUB_OUTPUT | ||
echo "odh_org=${odh_org}" >> $GITHUB_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
echo "Cut branch ${MINOR_RELEASE_BRANCH} from main/master" | ||
|
||
echo "Current branches in ${DSPO_REPOSITORY_FULL}" | ||
git branch -r | ||
|
||
git checkout -B ${MINOR_RELEASE_BRANCH} | ||
git push origin ${MINOR_RELEASE_BRANCH} | ||
echo "::notice:: Created DSPO ${MINOR_RELEASE_BRANCH} branch" | ||
|
||
echo "Current branches in ${DSP_REPOSITORY_FULL}" | ||
DSP_DIR=$(dirname ${WORKING_DIR})/data-science-pipelines | ||
git clone \ | ||
--depth=1 \ | ||
--branch=master \ | ||
https://${GH_USER_NAME}:${GH_TOKEN}@github.com/${DSP_REPOSITORY_FULL} \ | ||
${DSP_DIR} | ||
cd ${DSP_DIR} | ||
git checkout -B ${MINOR_RELEASE_BRANCH} | ||
git push origin ${MINOR_RELEASE_BRANCH} | ||
echo "::notice:: Created DSP ${MINOR_RELEASE_BRANCH} branch" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Note: The yaml in the body of the PR is used to feed inputs into the release workflow | ||
# since there's no easy way to communicate information between the pr closing, and then triggering the | ||
# release creation workflow. | ||
# Therefore, take extra care when adding new code blocks in the PR body, or updating the existing one. | ||
# Ensure any changes are compatible with the release_create workflow. | ||
|
||
set -ex | ||
set -o pipefail | ||
|
||
echo "Retrieve the sha images from the resulting workflow (check quay.io for the digests)." | ||
echo "Using [release-tools] generate a params.env and submit a new pr to vx.y+1.**x** branch." | ||
echo "For images pulled from registry, ensure latest images are upto date" | ||
|
||
BRANCH_NAME="release-${TARGET_RELEASE}" | ||
git config --global user.email "${GH_USER_EMAIL}" | ||
git config --global user.name "${GH_USER_NAME}" | ||
git remote add ${GH_USER_NAME} https://${GH_USER_NAME}:${GH_TOKEN}@github.com/${GH_USER_NAME}/${DSPO_REPOSITORY}.git | ||
git checkout -B ${BRANCH_NAME} | ||
|
||
echo "Created branch: ${BRANCH_NAME}" | ||
|
||
python ./scripts/release/release.py params --quay_org ${QUAY_ORG} --tag ${MINOR_RELEASE_TAG} --out_file ./config/base/params.env \ | ||
--override="IMAGES_OAUTHPROXY=registry.redhat.io/openshift4/ose-oauth-proxy@sha256:ab112105ac37352a2a4916a39d6736f5db6ab4c29bad4467de8d613e80e9bb33" | ||
|
||
git add . | ||
git commit -m "Generate params for ${TARGET_RELEASE}" | ||
git push ${GH_USER_NAME} $BRANCH_NAME -f | ||
|
||
# Used to feed inputs to release creation workflow. | ||
# target_version is used as the GH TAG | ||
tmp_config="/tmp/body-config.txt" | ||
body_txt="/tmp/body-text.txt" | ||
cp $CONFIG_TEMPLATE $tmp_config | ||
|
||
var=${GH_ORG} yq -i '.odh_org=env(var)' $tmp_config | ||
var=${MINOR_RELEASE_BRANCH} yq -i '.release_branch=env(var)' $tmp_config | ||
var=${MINOR_RELEASE_TAG} yq -i '.target_version_tag=env(var)' $tmp_config | ||
var=${PREVIOUS_RELEASE_TAG} yq -i '.previous_release_tag=env(var)' $tmp_config | ||
|
||
cat <<"EOF" > $body_txt | ||
This is an automated PR to prep Data Science Pipelines Operator for release. | ||
```yaml | ||
<CONFIG_HERE> | ||
``` | ||
EOF | ||
|
||
sed -i "/<CONFIG_HERE>/{ | ||
s/<CONFIG_HERE>//g | ||
r ${tmp_config} | ||
}" $body_txt | ||
|
||
pr_url=$(gh pr create \ | ||
--repo https://github.com/${DSPO_REPOSITORY_FULL} \ | ||
--body-file $body_txt \ | ||
--title "Release ${MINOR_RELEASE_TAG}" \ | ||
--head "${GH_USER_NAME}:$BRANCH_NAME" \ | ||
--label "release-automation" \ | ||
--base "${MINOR_RELEASE_BRANCH}") | ||
|
||
echo "::notice:: PR successfully created: ${pr_url}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
check_branch_exists(){ | ||
branch_exists=$(git ls-remote --heads https://github.com/${1}.git refs/heads/${2}) | ||
echo "Checking for existence of branch ${2} in GH Repo ${1}" | ||
if [[ $branch_exists ]]; then | ||
echo "::error:: Branch ${2} already exist in GH Repo ${1}" | ||
exit 1 | ||
fi | ||
echo "::notice:: Confirmed Branch ${2} does not exist in GH Repo ${1}" | ||
} | ||
|
||
check_branch_exists ${DSPO_REPOSITORY_FULL} ${MINOR_RELEASE_BRANCH} | ||
check_branch_exists ${DSP_REPOSITORY_FULL} ${MINOR_RELEASE_BRANCH} | ||
|
||
echo "Ensure compatibility.yaml is upto date, and generate a new compatibility.md. Use [release-tools] to accomplish this" | ||
|
||
BRANCH_NAME="compatibility-doc-generate-${TARGET_RELEASE}" | ||
|
||
git config --global user.email "${GH_USER_EMAIL}" | ||
git config --global user.name "${GH_USER_NAME}" | ||
git remote add ${GH_USER_NAME} https://${GH_USER_NAME}:${GH_TOKEN}@github.com/${GH_USER_NAME}/${DSPO_REPOSITORY}.git | ||
git checkout -B ${BRANCH_NAME} | ||
|
||
echo "Created branch: ${BRANCH_NAME}" | ||
echo "Checking if compatibility.yaml contains ${TARGET_RELEASE} release...." | ||
|
||
contains_rel=$(cat docs/release/compatibility.yaml | rel=${MINOR_RELEASE_WILDCARD} yq '[.[].dsp] | contains([env(rel)])') | ||
|
||
if [[ "$contains_rel" == "false" ]]; then | ||
|
||
cat <<EOF >> /tmp/error.txt | ||
compatibility.yaml has NOT been updated with target release. | ||
Please add ${MINOR_RELEASE_WILDCARD} dsp row in compatibility.yaml, | ||
then regenerate the compatibility.md by following the instructions here: | ||
https://github.com/opendatahub-io/data-science-pipelines-operator/tree/main/scripts/release#compatibility-doc-generation | ||
EOF | ||
|
||
echo ::error::$(cat /tmp/error.txt) | ||
exit 1 | ||
|
||
fi | ||
|
||
echo "::notice:: Confirmed existence of ${MINOR_RELEASE_BRANCH} in compatibility.yaml." | ||
|
||
echo "Confirming that compatibility.md is upto date." | ||
python ./scripts/release/release.py version_doc --input_file docs/release/compatibility.yaml --out_file docs/release/compatibility.md | ||
|
||
git status | ||
|
||
prereqs_successful=true | ||
|
||
if [[ `git status --porcelain` ]]; then | ||
echo "::notice:: Compatibility.md is not up to date with Compatibility.yaml, creating pr to synchronize." | ||
|
||
git add . | ||
git commit -m "Update DSPO to $TARGET_RELEASE" | ||
git push ${GH_USER_NAME} $BRANCH_NAME -f | ||
gh pr create \ | ||
--repo https://github.com/${DSPO_REPOSITORY_FULL} \ | ||
--body "This is an automated PR to update Data Science Pipelines Operator version compatibility doc." \ | ||
--title "Update DSP version compatibility doc." \ | ||
--head "${GH_USER_NAME}:$BRANCH_NAME" \ | ||
--base "main" | ||
|
||
echo "::notice:: PR to update compatibility doc has been created, please re-run this workflow once this PR is merged." | ||
prereqs_successful=false | ||
else | ||
echo "::notice:: Compatibility.md doc is up to date with Compatibility.yaml, continuing with workflow..." | ||
fi | ||
|
||
# Save step outputs | ||
echo "prereqs_successful=${prereqs_successful}" | ||
echo "prereqs_successful=${prereqs_successful}" >> $GITHUB_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
odh_org: placeholder | ||
release_branch: placeholder | ||
target_version_tag: placeholder | ||
previous_release_tag: placeholder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
set -o pipefail | ||
|
||
mkdir -p ./pr | ||
|
||
cat <<EOF >> /tmp/body-file-raw.txt | ||
${PR_BODY} | ||
EOF | ||
|
||
sed -n '/^```yaml/,/^```/ p' < /tmp/body-file-raw.txt | sed '/^```/ d' > ./pr/config.yaml | ||
echo Parsed config from PR body: | ||
yq ./pr/config.yaml | ||
|
||
# Also store pr details | ||
echo ${PR_NUMBER} >> ./pr/pr_number | ||
echo ${PR_STATE} >> ./pr/pr_state | ||
echo ${PR_HEAD_SHA} >> ./pr/head_sha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
echo "Perform any tests on the branch, confirm stability. If issues are found, they should be corrected in `main/master` and be cherry-picked into this branch." |
Oops, something went wrong.