-
Notifications
You must be signed in to change notification settings - Fork 4
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 #237 from zowe/ci/use-zoweRobot-token
Use Zowe robot token in updateVersions workflows
- Loading branch information
Showing
4 changed files
with
301 additions
and
301 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 |
---|---|---|
|
@@ -33,6 +33,7 @@ jobs: | |
with: | ||
repository: 'zowe/zowe-install-packaging' | ||
ref: ${{ env.defaultBranch }} | ||
token: ${{ secrets.ZOWE_ROBOT_TOKEN }} | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
|
@@ -48,11 +49,10 @@ jobs: | |
id: get_versions | ||
run: | | ||
declare -A repoAndComponent | ||
repoAndComponent[imperative]=imperative | ||
repoAndComponent[cli]=zowe-cli | ||
repoAndComponent[cics-for-zowe-cli]=zowe-cli-cics-plugin | ||
repoAndComponent[db2-for-zowe-cli]=zowe-cli-db2-plugin | ||
repoAndComponent[perf-timing]=perf-timing | ||
repoAndComponent[ims-for-zowe-cli]=zowe-cli-ims-plugin | ||
repoAndComponent[mq-for-zowe-cli]=zowe-cli-mq-plugin | ||
repoAndComponent[zos-ftp-for-zowe-cli]=zowe-cli-ftp-plugin | ||
|
@@ -68,29 +68,29 @@ jobs: | |
for component in "${!repoAndComponent[@]}"; do | ||
repo="${repoAndComponent[$component]}" | ||
current_version=$(grep -A 2 "\"repository\": \"$repo\"" manifest.json.template | awk -F '"' '/"tag":/ {print $4}') | ||
new_version=v$(npm view @zowe/$component "dist-tags.$zowe_version") | ||
new_version=v$(npm view @zowe/$component "dist-tags.$zowe_version" --@zowe:registry=https://zowe.jfrog.io/zowe/api/npm/npm-local-release/) | ||
if [[ "$new_version" != "$current_version" ]]; then | ||
echo "|$component | $current_version | $new_version|" >> description.txt | ||
echo "| $component | $current_version | $new_version |" >> description.txt | ||
# Replaces the version number. If it doesn't match on the first line after the component, it goes to the next line and checks again. | ||
sed -i -E "/\"repository\": \"$repo\"/{n;s/(\"tag\": \").*(\",)/\1$new_version\2/}" manifest.json.template | ||
fi | ||
done | ||
- name: Commit and Push Changes | ||
run: | | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "[email protected]" | ||
git config --global user.name ${{ secrets.ZOWE_ROBOT_USER }} | ||
git config --global user.email ${{ secrets.ZOWE_ROBOT_EMAIL }} | ||
git add "manifest.json.template" | ||
git commit -m "Update component versions" | ||
git commit -sm "Update component versions" | ||
git push origin HEAD | ||
- name: Create Pull Request | ||
run: | | ||
version="${{ github.event.inputs.version }}" | ||
branch_name="v$version/cli/rc" | ||
pr_title="Update versions for $version" | ||
pr_title="Update CLI component versions for $version" | ||
body_file=description.txt | ||
gh pr create --base ${{ env.defaultBranch }} --head "$branch_name" --title "$pr_title" --body-file "$body_file" --reviewer atorrise | ||
gh pr create --base ${{ env.defaultBranch }} --head "$branch_name" --title "$pr_title" --body-file "$body_file" --reviewer ojcelis,MarkAckert | ||
echo "Pull Request created successfully" | ||
env: | ||
GH_TOKEN: ${{ secrets.ZOWE_ROBOT_TOKEN }} |
170 changes: 85 additions & 85 deletions
170
.github/workflows/zowe-versions_updateVersions_createPR.yml
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 |
---|---|---|
@@ -1,85 +1,85 @@ | ||
name: Update Versions and Create PR (zowe-versions) | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Release Version (x.x.x)' | ||
required: true | ||
zowe_version: | ||
description: "Zowe Version Tag" | ||
default: zowe-v2-lts | ||
required: true | ||
type: choice | ||
options: | ||
- zowe-v1-lts | ||
- zowe-v2-lts | ||
|
||
jobs: | ||
update_versions_and_create_pr: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
|
||
- name: Create Branch | ||
run: | | ||
version_name="${{ github.event.inputs.version }}" | ||
branch_name="v$version_name/master" | ||
git checkout -b "$branch_name" | ||
- name: Get and Change Component Versions | ||
id: get_versions | ||
run: | | ||
zowe_version="${{ github.event.inputs.zowe_version }}" | ||
components=$(yq -r ".packages | with_entries(select(.value.\"$zowe_version\")) | keys | .[]" zowe-versions.yaml) | ||
version="${{ github.event.inputs.version }}" | ||
# echoing to txt file to later add this file as the PR description | ||
echo "This PR updates the following package versions in zowe-versions.yaml for \`$zowe_version\`" >> description.txt | ||
echo "| Updated Package | Old Version | New Version |" >> description.txt | ||
echo "| --- | --- | --- |" >> description.txt | ||
for component in $components; do | ||
current_version=$(grep -A 2 "^ $component:" zowe-versions.yaml | grep "$zowe_version" | awk '{print $2}' | tr -d '\r') | ||
new_version=$(npm view @zowe/$component "dist-tags.$zowe_version") | ||
if [[ "$new_version" != "$current_version" ]]; then | ||
echo "|$component | $current_version | $new_version|" >> description.txt | ||
# Replaces the version number. If it doesn't match on the first line after the component, it goes to the next line and checks again. | ||
sed -i -E "/^ $component:/ { n; s/($zowe_version: ).*/\1$new_version/; t; n; s/($zowe_version: ).*/\1$new_version/ }" zowe-versions.yaml | ||
fi | ||
done | ||
# Update zowe-versions.yaml tags section (always sets rc = 1) | ||
sed -i -E "/$zowe_version:/ { n; s/(version: ).*/\1$version/; s/(rc: )[0-9]+/\11/ }" zowe-versions.yaml | ||
- name: Commit and Push Changes | ||
run: | | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "[email protected]" | ||
git add zowe-versions.yaml | ||
git commit -sm "Update component versions" | ||
git push origin HEAD | ||
- name: Create Pull Request | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
version_name="${{ github.event.inputs.version }}" | ||
branch_name="v$version_name/master" | ||
pr_title="Update zowe component versions for $version_name" | ||
body_file=description.txt | ||
pr_url=$(gh pr create --base master --head "$branch_name" --title "$pr_title" --body-file "$body_file") | ||
pr_number=$(echo "$pr_url" | sed 's/.*\/\([0-9]\+\)$/\1/') | ||
curl -X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\ | ||
https://api.github.com/repos/zowe/zowe-cli-standalone-package/pulls/$pr_number/requested_reviewers \ | ||
-d '{"team_reviewers":["zowe-cli-administrators"]}' | ||
echo "Pull Request created successfully" | ||
name: Update Versions and Create PR (zowe-versions) | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Release Version (x.x.x)' | ||
required: true | ||
zowe_version: | ||
description: "Zowe Version Tag" | ||
default: zowe-v2-lts | ||
required: true | ||
type: choice | ||
options: | ||
- zowe-v1-lts | ||
- zowe-v2-lts | ||
|
||
jobs: | ||
update_versions_and_create_pr: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
|
||
- name: Create Branch | ||
run: | | ||
version_name="${{ github.event.inputs.version }}" | ||
branch_name="v$version_name/master" | ||
git checkout -b "$branch_name" | ||
- name: Get and Change Component Versions | ||
id: get_versions | ||
run: | | ||
zowe_version="${{ github.event.inputs.zowe_version }}" | ||
components=$(yq -r ".packages | with_entries(select(.value.\"$zowe_version\")) | keys | .[]" zowe-versions.yaml) | ||
version="${{ github.event.inputs.version }}" | ||
# echoing to txt file to later add this file as the PR description | ||
echo "This PR updates the following package versions in zowe-versions.yaml for \`$zowe_version\`" >> description.txt | ||
echo "| Updated Package | Old Version | New Version |" >> description.txt | ||
echo "| --- | --- | --- |" >> description.txt | ||
for component in $components; do | ||
current_version=$(grep -A 2 "^ $component:" zowe-versions.yaml | grep "$zowe_version" | awk '{print $2}' | tr -d '\r') | ||
new_version=$(npm view @zowe/$component "dist-tags.$zowe_version" --@zowe:registry=https://zowe.jfrog.io/zowe/api/npm/npm-local-release/) | ||
if [[ "$new_version" != "$current_version" ]]; then | ||
echo "| $component | $current_version | $new_version |" >> description.txt | ||
# Replaces the version number. If it doesn't match on the first line after the component, it goes to the next line and checks again. | ||
sed -i -E "/^ $component:/ { n; s/($zowe_version: ).*/\1$new_version/; t; n; s/($zowe_version: ).*/\1$new_version/ }" zowe-versions.yaml | ||
fi | ||
done | ||
# Update zowe-versions.yaml tags section (always sets rc = 1) | ||
sed -i -E "/$zowe_version:/ { n; s/(version: ).*/\1$version/; s/(rc: )[0-9]+/\11/ }" zowe-versions.yaml | ||
- name: Commit and Push Changes | ||
run: | | ||
git config --global user.name ${{ secrets.ZOWE_ROBOT_USER }} | ||
git config --global user.email ${{ secrets.ZOWE_ROBOT_EMAIL }} | ||
git add zowe-versions.yaml | ||
git commit -sm "Update component versions" | ||
git push origin HEAD | ||
- name: Create Pull Request | ||
env: | ||
GH_TOKEN: ${{ secrets.ZOWE_ROBOT_TOKEN }} | ||
run: | | ||
version_name="${{ github.event.inputs.version }}" | ||
branch_name="v$version_name/master" | ||
pr_title="Update zowe component versions for $version_name" | ||
body_file=description.txt | ||
pr_url=$(gh pr create --base master --head "$branch_name" --title "$pr_title" --body-file "$body_file") | ||
pr_number=$(echo "$pr_url" | sed 's/.*\/\([0-9]\+\)$/\1/') | ||
curl -X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.ZOWE_ROBOT_TOKEN }}"\ | ||
https://api.github.com/repos/zowe/zowe-cli-standalone-package/pulls/$pr_number/requested_reviewers \ | ||
-d '{"team_reviewers":["zowe-cli-administrators"]}' | ||
echo "Pull Request created successfully" |
Oops, something went wrong.