-
Notifications
You must be signed in to change notification settings - Fork 4
99 lines (86 loc) · 3.81 KB
/
manifest_updateVersions.createPR.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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-v3-lts
required: true
type: choice
options:
- zowe-v2-lts
- zowe-v3-lts
permissions:
contents: write
pull-requests: write
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-v2-lts" ]]; then
echo "defaultBranch=v2.x/rc" >> $GITHUB_ENV
else
echo "defaultBranch=v3.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@v4
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]=cics-for-zowe-client
repoAndComponent[db2-for-zowe-cli]=zowe-cli-db2-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-v[12]-lts$ ]]; then
repoAndComponent[ims-for-zowe-cli]=zowe-cli-ims-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 }}