Skip to content

Commit

Permalink
Zowe Suite v2.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zowe-robot authored Nov 28, 2023
2 parents 5e2b658 + 1c587e2 commit aad0496
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 61 deletions.
55 changes: 22 additions & 33 deletions .github/workflows/build-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,48 +67,38 @@ jobs:
echo "ERROR: CHANGELOG.md has not been updated."
echo "::set-output name=check_commit::false"
fi
- name: Extract changelog info
- name: Compare PR description with template
if: steps.check-changelog.outputs.check_commit == 'false'
id: extract-changelog
env:
PR_DESCRIPTION: ${{ github.event.pull_request.body }}
run: |
PR_DESCRIPTION="${{ github.event.pull_request.body }}"
# Check if "changelog:" exists in PR description
if echo "$PR_DESCRIPTION" | grep -q "VERSION:" && echo "$PR_DESCRIPTION" | grep -q "CHANGELOG:"; then
# Extract text after "changelog:"
CHANGELOG_TEXT=$(echo $PR_DESCRIPTION | sed -n 's/.*CHANGELOG: \(.*\)/\1/p')
# Extract VERSION: from PR description
VERSION=$(echo "$PR_DESCRIPTION" | grep -oP 'VERSION:\s*\K\d+\.\d+\.\d+')
echo "Extracted changelog: $CHANGELOG_TEXT"
echo "::set-output name=changelog::$CHANGELOG_TEXT"
echo "::set-output name=version::$VERSION"
else
echo -e "No changelog and version information found in PR description please add them.\n Expected Format:\n VERSION:X.XX.X\n CHANGELOG:This is changelog note.\n
To re-run the action, just make a push or commit after updating the PR description or updating the changelog via a manual file changing commit."
# Safely print the PR description using Node.js
node -e "const fs=require('fs'); fs.writeFileSync('/tmp/pr_description.txt', process.env.PR_DESCRIPTION);"
# Use diff to compare the two files
if diff -wB /tmp/pr_description.txt .github/pull_request_template.md > /dev/null; then
echo "ERROR: PR description is identical to the template."
exit 1
else
echo "PR description and template are different."
fi
- name: Check PR body against changelog
if: steps.check-changelog.outputs.check_commit == 'false'
id: extract-changelog
run: |
ESCAPED_CHANGELOG="${{ steps.extract-changelog.outputs.changelog }}"
ESCAPED_CHANGELOG=$(echo "$ESCAPED_CHANGELOG" | sed "s/'/\\\\'/g")
VERSION="${{ steps.extract-changelog.outputs.version }}"
if ! grep -Fq "$ESCAPED_CHANGELOG" CHANGELOG.md; then
# Check if version exists in CHANGELOG.md
if grep -q "^## \`$VERSION\`" CHANGELOG.md; then
# Append PR description to existing version
sed -i "/^## \`$VERSION\`/a - $ESCAPED_CHANGELOG (#${{ github.event.pull_request.number }})" CHANGELOG.md
else
# Append new version and PR description
ANCHOR_LINE=$(awk '/All notable changes to the Zlux App Manager will be documented in this file\./ {print NR}' CHANGELOG.md)
sed -i "$ANCHOR_LINE a\\
\n## \`$VERSION\`\n- $ESCAPED_CHANGELOG (#${{ github.event.pull_request.number }})\n" CHANGELOG.md
fi
result=$(node .github/workflows/set-changelog.js ${{ github.event.pull_request.number }})
if [ "$result" = "Success" ]; then
git config --global user.email "zowe-robot@users.noreply.github.com"
git config --global user.name "Zowe Robot"
git add CHANGELOG.md
git commit -s -m "Update changelog with PR #${{ github.event.pull_request.number }} description"
git push
echo "Updated CHANGELOG from description"
else
echo $result
echo -e "No changelog and version information found in PR description. Please add them.\nExpected Format:\nVERSION:X.XX.X\nCHANGELOG:This is changelog note.\nTo re-run the action, just make a push or commit after updating the PR description or updating the changelog via a manual file changing commit."
exit 1
fi
- name: check for changes
Expand All @@ -119,7 +109,7 @@ jobs:
echo "::set-output name=change_detected::false"
else
echo "::set-output name=change_detected::true"
fi
fi
check_changelog:
if: github.event_name == 'pull_request'
Expand All @@ -136,8 +126,7 @@ jobs:
exit 1
else
echo "changelog was updated successfully."
fi
fi
build:
runs-on: ubuntu-latest
needs: check-permission
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/set-changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/

const fs = require('fs');

// Must run with args: PR_NUMBER
const PR_NUMBER = process.argv[2];
const description = fs.readFileSync('/tmp/pr_description.txt', 'utf8');
let changelogMsg, version;

if (description.includes('VERSION:') && description.includes('CHANGELOG:')) {
let lines = description.split('\n');
lines.forEach((line) => {
if (line.startsWith('CHANGELOG:')) {
changelogMsg = line.substring('CHANGELOG:'.length).trim();
} else if (line.startsWith('VERSION:')) {
version = line.substring('VERSION:'.length).trim();
}
});

if (changelogMsg && version) {
let changelog = fs.readFileSync('CHANGELOG.md', 'utf8');
let changelogLines = changelog.split('\n');
let versionIndex = -1;
let anchorIndex = 0;
for (let i = 0; i < changelogLines.length; i++) {
if (changelogLines[i].includes('All notable changes to the Zlux App Manager will be documented in this file.')) {
anchorIndex = i;
} else if (changelogLines[i].startsWith('## ' + version)) { // Removed "v" prefix
versionIndex = i;
break;
}
}
if (versionIndex != -1) {
changelogLines.splice(versionIndex + 2, 0, `- ${changelogMsg} (#${PR_NUMBER})`);
} else {
changelogLines.splice(anchorIndex + 1, 0, `\n## \`${version}\`\n- ${changelogMsg} (#${PR_NUMBER})`);
}
const newChangelog = changelogLines.join('\n');
fs.writeFileSync('CHANGELOG.md', newChangelog);
console.log('Success');
} else {
if (!changelogMsg) {
console.log('Missing CHANGELOG');
}
if (!version) {
console.log('Missing VERSION');
}
}
} else {
console.log('Missing CHANGELOG or VERSION');
}
2 changes: 1 addition & 1 deletion system-apps/admin-notification-app/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ build:
branch: "{{build.branch}}"
number: "{{build.number}}"
commitHash: "{{build.commitHash}}"
timestamp: "{{build.timestamp}}"
timestamp: {{build.timestamp}}
appfwPlugins:
- path: .
2 changes: 1 addition & 1 deletion system-apps/web-browser-app/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ build:
branch: "{{build.branch}}"
number: "{{build.number}}"
commitHash: "{{build.commitHash}}"
timestamp: "{{build.timestamp}}"
timestamp: {{build.timestamp}}
appfwPlugins:
- path: .
68 changes: 42 additions & 26 deletions virtual-desktop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit aad0496

Please sign in to comment.