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

Use Zowe robot token in updateVersions workflows #237

Merged
merged 5 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/manifest_updateVersions.createPR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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 .github/workflows/zowe-versions_updateVersions_createPR.yml
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"
Loading
Loading