Skip to content

Update Versions and Create PR (manifest) #4

Update Versions and Create PR (manifest)

Update Versions and Create PR (manifest) #4

name: Update Versions and Create PR (manifest)
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: Set Default Branch Environment Variable
run: |
if [[ "${{ github.event.inputs.zowe_version }}" == "zowe-v1-lts" ]]; then
echo "defaultBranch=v1.x/rc" >> $GITHUB_ENV
else
echo "defaultBranch=v2.x/rc" >> $GITHUB_ENV
fi
- name: Checkout zowe-install-packaging
uses: actions/checkout@v4
with:
repository: 'zowe/zowe-install-packaging'
ref: ${{ env.defaultBranch }}
token: ${{ secrets.ZOWE_ROBOT_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Create Branch
run: |
branch_name="v${{ github.event.inputs.version }}/cli/rc"
git checkout -b "$branch_name"
- name: Get and Change Component Versions
id: get_versions
run: |
declare -A repoAndComponent
repoAndComponent[cli]=zowe-cli
repoAndComponent[cics-for-zowe-cli]=zowe-cli-cics-plugin
repoAndComponent[db2-for-zowe-cli]=zowe-cli-db2-plugin
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
zowe_version=${{ github.event.inputs.zowe_version }}
if [[ "$zowe_version" == "zowe-v1-lts" ]]; then
repoAndComponent[secure-credential-store-for-zowe-cli]=zowe-cli-scs-plugin
fi
echo "This PR updates the following package versions in manifest.json.template for \`$zowe_version\`" >> description.txt
echo "| Updated Package | Old Version | New Version |" >> description.txt
echo "| --- | --- | --- |" >> description.txt
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" --@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 "/\"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 ${{ secrets.ZOWE_ROBOT_USER }}
git config --global user.email ${{ secrets.ZOWE_ROBOT_EMAIL }}
git add "manifest.json.template"
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 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 ojcelis,MarkAckert
echo "Pull Request created successfully"
env:
GH_TOKEN: ${{ secrets.ZOWE_ROBOT_TOKEN }}