From 3f556bc1ee0395b16cd323446224c3f65f980a42 Mon Sep 17 00:00:00 2001 From: syadav3 Date: Thu, 10 Aug 2023 00:33:12 +0530 Subject: [PATCH 01/16] Added Merge Check for Changelog file Signed-off-by: Himani1519 --- .github/workflows/build_test.yml | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 629f4c8..6ccafea 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -33,6 +33,50 @@ jobs: github-repo: ${{ github.repository }} github-token: ${{ secrets.GITHUB_TOKEN }} + check_changelog: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + path: copy-repo + fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }} + + - name: Get changed files + id: changed-files + run: | + cd copy-repo + if ${{ github.event_name == 'pull_request' }}; then + echo "changed_files=$(git diff --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT + else + echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT + fi + + - name: List changed files + id: set-flag + run: | + cd copy-repo + for file in ${{ steps.changed-files.outputs.changed_files }}; do + echo "$file was changed" + if [[ $file == "CHANGELOG.md" ]] + then + echo "file-flag=true" >> $GITHUB_OUTPUT + break; + else + echo "file-flag=false" >> $GITHUB_OUTPUT + fi + done + + - name: Check if CHANGELOG is Updated and Abort if not updated + if: steps.set-flag.outputs.file-flag != 'true' + run: | + echo "CHANGELOG.md not updated, please update CHANGELOG.md with the changes made in the pull request" + exit 1 + + - name: Remove copy-repo + if: always() + run: rm -r copy-repo + build: runs-on: ubuntu-latest needs: check-permission From b118cbf08e16bce5e7f51bcedc4978594bf60e8a Mon Sep 17 00:00:00 2001 From: Himani1519 Date: Wed, 23 Aug 2023 15:17:33 +0530 Subject: [PATCH 02/16] Automate changelog note Signed-off-by: Himani1519 --- .github/workflows/build_test.yml | 121 +++++++++++++++++++++---------- 1 file changed, 84 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 6ccafea..9840c48 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -9,7 +9,7 @@ on: types: [opened, reopened, synchronize] workflow_dispatch: - inputs: + inputs: BRANCH_NAME: description: 'Specify branch name or PR (e.g. PR-41)' required: false @@ -20,7 +20,7 @@ on: type: boolean description: 'Perform release, Defauls is false' required: false - + jobs: check-permission: runs-on: ubuntu-latest @@ -33,49 +33,96 @@ jobs: github-repo: ${{ github.repository }} github-token: ${{ secrets.GITHUB_TOKEN }} - check_changelog: + update-changelog: runs-on: ubuntu-latest + outputs: + was_updated: ${{ steps.check-change.outputs.change_detected }} + check_commit: ${{ steps.check-changelog.outputs.check_commit }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v2 with: - path: copy-repo - fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }} + ref: ${{ github.head_ref }} + fetch-depth: 0 - - name: Get changed files - id: changed-files + - name: Check for updated CHANGELOG.md using git + id: check-changelog + run: | + if git diff --name-only origin/${{ github.base_ref }} | grep -q "^CHANGELOG.md$"; then + echo "CHANGELOG.md has been updated." + echo "::set-output name=check_commit::true" + else + echo "ERROR: CHANGELOG.md has not been updated." + echo "::set-output name=check_commit::false" + fi + - name: Extract changelog info + if: steps.check-changelog.outputs.check_commit == 'false' + id: extract-changelog + 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." + exit 1 + fi + - name: Check PR body against changelog + if: steps.check-changelog.outputs.check_commit == 'false' run: | - cd copy-repo - if ${{ github.event_name == 'pull_request' }}; then - echo "changed_files=$(git diff --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT + 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 - echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT + # Append new version and PR description + ANCHOR_LINE=$(awk '/All notable changes to the sample angular app 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 - - - name: List changed files - id: set-flag + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add CHANGELOG.md + git commit -m "Update changelog with PR #${{ github.event.pull_request.number }} description" + git push + fi + - name: check for changes + id: check-change run: | - cd copy-repo - for file in ${{ steps.changed-files.outputs.changed_files }}; do - echo "$file was changed" - if [[ $file == "CHANGELOG.md" ]] - then - echo "file-flag=true" >> $GITHUB_OUTPUT - break; - else - echo "file-flag=false" >> $GITHUB_OUTPUT - fi - done - - - name: Check if CHANGELOG is Updated and Abort if not updated - if: steps.set-flag.outputs.file-flag != 'true' - run: | - echo "CHANGELOG.md not updated, please update CHANGELOG.md with the changes made in the pull request" - exit 1 + if git diff --name-only HEAD^ HEAD | grep 'changelog.md'; then + echo "No Changes detected, setting flag to false" + echo "::set-output name=change_detected::false" + else + echo "::set-output name=change_detected::true" + fi - - name: Remove copy-repo - if: always() - run: rm -r copy-repo + check_changelog: + needs: update-changelog + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Verify Changelog update + run: | + if [ "${{ needs.update-changelog.outputs.was_updated }}" != "true" ]; then + echo "CHANGELOG.md not updated, please update CHANGELOG.md with the changes made in the pull request" + exit 1 + else + echo "changelog was updated successfully." + fi build: runs-on: ubuntu-latest @@ -142,11 +189,11 @@ jobs: publish-registry-email: ${{ secrets.NPM_PRIVATE_REGISTRY_EMAIL }} publish-registry-username: ${{ secrets.NPM_PRIVATE_REGISTRY_USERNAME }} publish-registry-password: ${{ secrets.NPM_PRIVATE_REGISTRY_PASSWORD }} - + - name: '[Prep 11] Bump Staging Version ' if: ${{ github.event.inputs.PERFORM_RELEASE == 'true' && env.RELEASE == 'true' }} uses: zowe-actions/zlux-builds/plugins/bump-version@v2.x/main - env: + env: GITHUB_TOKEN: ${{ secrets.ZOWE_ROBOT_TOKEN }} - name: '[Prep 10] Publish NPM Package ' From c144fa3e5efdecfa79830194c63ee06a19b21b0e Mon Sep 17 00:00:00 2001 From: Himani1519 Date: Tue, 29 Aug 2023 19:55:33 +0530 Subject: [PATCH 03/16] minor change Signed-off-by: Himani1519 --- .github/workflows/build_test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 9840c48..c5f9ac5 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -92,10 +92,10 @@ jobs: sed -i "$ANCHOR_LINE a\\ \n## $VERSION\n- $ESCAPED_CHANGELOG (#${{ github.event.pull_request.number }})\n" CHANGELOG.md fi - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" + git config --global user.email "zowe-robot@users.noreply.github.com" + git config --global user.name "Zowe Robot" git add CHANGELOG.md - git commit -m "Update changelog with PR #${{ github.event.pull_request.number }} description" + git commit -s -m "Update changelog with PR #${{ github.event.pull_request.number }} description" git push fi - name: check for changes From 1201aa25efdb4b61576fa387b98ebbcd87b1c205 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 23 Aug 2023 09:48:40 +0000 Subject: [PATCH 04/16] Update changelog with PR #116 description Signed-off-by: Himani1519 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30beb35..cb707a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to the sample angular app will be documented in this file. ## 2.0.1 +- This action making a CHANGELOG note via special syntax from the GitHub PR commit message, like it could automatically update CHANGELOG.md with the message. First job checks if PR body has changelog note or not if it's not there then it asked them to add it and second job is to check if changelog note has been added in changelog.md file or not. (#116) - Bugfix: Schema file was not included, preventing installation as a component - Bugfix: Manifest build content template was never resolved, so it has been removed. From c780c75261563eef846785ef4049fc98925b4ca8 Mon Sep 17 00:00:00 2001 From: Himani1519 Date: Tue, 5 Sep 2023 20:52:16 +0530 Subject: [PATCH 05/16] update changelog.md Signed-off-by: Himani1519 --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb707a1..30beb35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,6 @@ All notable changes to the sample angular app will be documented in this file. ## 2.0.1 -- This action making a CHANGELOG note via special syntax from the GitHub PR commit message, like it could automatically update CHANGELOG.md with the message. First job checks if PR body has changelog note or not if it's not there then it asked them to add it and second job is to check if changelog note has been added in changelog.md file or not. (#116) - Bugfix: Schema file was not included, preventing installation as a component - Bugfix: Manifest build content template was never resolved, so it has been removed. From 5220f9c78023e4ac4d17f365b0f8f011476c18ec Mon Sep 17 00:00:00 2001 From: Himani1519 Date: Fri, 8 Sep 2023 11:32:55 +0530 Subject: [PATCH 06/16] update changelog when its PR Signed-off-by: Himani1519 --- .github/workflows/build_test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 15da609..699b87a 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -34,6 +34,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} update-changelog: + if: github.event_name == 'pull_request' runs-on: ubuntu-latest outputs: was_updated: ${{ steps.check-change.outputs.change_detected }} @@ -109,6 +110,7 @@ jobs: fi check_changelog: + if: github.event_name == 'pull_request' needs: update-changelog runs-on: ubuntu-latest steps: From 558f85bfea0f40c4b4d8d9f6b0ed430d08089657 Mon Sep 17 00:00:00 2001 From: Himani1519 Date: Fri, 8 Sep 2023 18:15:50 +0530 Subject: [PATCH 07/16] fixed syntax error Signed-off-by: Himani1519 --- .github/workflows/build_test.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 699b87a..139359d 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -197,15 +197,6 @@ jobs: publish-registry-email: ${{ secrets.NPM_PRIVATE_REGISTRY_EMAIL }} publish-registry-username: ${{ secrets.NPM_PRIVATE_REGISTRY_USERNAME }} publish-registry-password: ${{ secrets.NPM_PRIVATE_REGISTRY_PASSWORD }} -<<<<<<< HEAD - - - name: '[Prep 11] Bump Staging Version ' - if: ${{ github.event.inputs.PERFORM_RELEASE == 'true' && env.RELEASE == 'true' }} - uses: zowe-actions/zlux-builds/plugins/bump-version@v2.x/main - env: - GITHUB_TOKEN: ${{ secrets.ZOWE_ROBOT_TOKEN }} -======= ->>>>>>> b2833837d4f60b4fcbf8bc4b2539f3ccc8761a08 - name: '[Prep 11] Publish NPM Package ' if: ${{ github.event.inputs.PERFORM_RELEASE == 'true' && env.RELEASE == 'true' }} From 27e940dacf72419d0e8afb01a782aee78b39d46d Mon Sep 17 00:00:00 2001 From: Zowe Robot Date: Fri, 8 Sep 2023 12:46:32 +0000 Subject: [PATCH 08/16] Update changelog with PR #116 description Signed-off-by: Zowe Robot --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30beb35..cb707a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to the sample angular app will be documented in this file. ## 2.0.1 +- This action making a CHANGELOG note via special syntax from the GitHub PR commit message, like it could automatically update CHANGELOG.md with the message. First job checks if PR body has changelog note or not if it's not there then it asked them to add it and second job is to check if changelog note has been added in changelog.md file or not. (#116) - Bugfix: Schema file was not included, preventing installation as a component - Bugfix: Manifest build content template was never resolved, so it has been removed. From 0e98cd9615ad7be37ca357b460056f4a1e4e4be8 Mon Sep 17 00:00:00 2001 From: Himani1519 Date: Thu, 5 Oct 2023 14:13:01 +0530 Subject: [PATCH 09/16] seperate steps for template comparsion and extract changelog Signed-off-by: Himani1519 --- .github/workflows/build_test.yml | 39 ++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 139359d..e5b846b 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -56,25 +56,56 @@ jobs: echo "ERROR: CHANGELOG.md has not been updated." echo "::set-output name=check_commit::false" fi + + - name: Compare PR description with template + if: steps.check-changelog.outputs.check_commit == 'false' + run: | + PR_DESCRIPTION="${{ github.event.pull_request.body }}" + echo "$PR_DESCRIPTION" > /tmp/pr_description.txt + echo "PR DESCRIPTION saved to /tmp/pr_description.txt." + cat /tmp/pr_description.txt + + # Save the template content to a file + TEMPLATE_CONTENT=$(sed 's/"//g' .github/pull_request_template.md) + echo "$TEMPLATE_CONTENT" > /tmp/template_content.txt + echo "Template content saved to /tmp/template_content.txt." + cat /tmp/template_content.txt + + # Use diff to compare the two files + if diff -wB /tmp/pr_description.txt /tmp/template_content.txt > /dev/null; then + echo "ERROR: PR description is identical to the template." + exit 1 + else + echo "PR description and template are different." + fi + - name: Extract changelog info if: steps.check-changelog.outputs.check_commit == 'false' id: extract-changelog run: | - PR_DESCRIPTION="${{ github.event.pull_request.body }}" + PR_DESCRIPTION=$(cat /tmp/pr_description.txt) # 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:" + # Extract content after "changelog:" CHANGELOG_TEXT=$(echo $PR_DESCRIPTION | sed -n 's/.*CHANGELOG: \(.*\)/\1/p') + + # Check if extracted CHANGELOG_TEXT is empty or identical to the template content + TEMPLATE_CONTENT=$(cat /tmp/template_content.txt) + if [ -z "$CHANGELOG_TEXT" ] || [ "$CHANGELOG_TEXT" == "$TEMPLATE_CONTENT" ]; then + echo "The changelog information after 'CHANGELOG:' cannot be empty or identical to pull_request_template.md." + exit 1 + fi + # 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." + echo -e "No changelog and version information found in PR description. Please add them.\nExpected Format:\nVERSION:vX.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 PR body against changelog if: steps.check-changelog.outputs.check_commit == 'false' run: | From 84b42ab72dc8f70180a512724d9e1a5ba2f72061 Mon Sep 17 00:00:00 2001 From: Himani1519 Date: Mon, 16 Oct 2023 11:54:14 +0530 Subject: [PATCH 10/16] automation to rely upon JS rather than shell Signed-off-by: Himani1519 --- .github/workflows/build_test.yml | 80 ++++++++---------------------- .github/workflows/set-changelog.js | 59 ++++++++++++++++++++++ CHANGELOG.md | 1 - 3 files changed, 79 insertions(+), 61 deletions(-) create mode 100644 .github/workflows/set-changelog.js diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index e5b846b..796d527 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -56,80 +56,40 @@ jobs: echo "ERROR: CHANGELOG.md has not been updated." echo "::set-output name=check_commit::false" fi - - name: Compare PR description with template if: steps.check-changelog.outputs.check_commit == 'false' + env: + PR_DESCRIPTION: ${{ github.event.pull_request.body }} run: | - PR_DESCRIPTION="${{ github.event.pull_request.body }}" - echo "$PR_DESCRIPTION" > /tmp/pr_description.txt - echo "PR DESCRIPTION saved to /tmp/pr_description.txt." - cat /tmp/pr_description.txt - - # Save the template content to a file - TEMPLATE_CONTENT=$(sed 's/"//g' .github/pull_request_template.md) - echo "$TEMPLATE_CONTENT" > /tmp/template_content.txt - echo "Template content saved to /tmp/template_content.txt." - cat /tmp/template_content.txt - - # Use diff to compare the two files - if diff -wB /tmp/pr_description.txt /tmp/template_content.txt > /dev/null; then - echo "ERROR: PR description is identical to the template." - exit 1 - else - echo "PR description and template are different." - fi - - - name: Extract changelog info - if: steps.check-changelog.outputs.check_commit == 'false' - id: extract-changelog - run: | - PR_DESCRIPTION=$(cat /tmp/pr_description.txt) - # Check if "changelog:" exists in PR description - if echo "$PR_DESCRIPTION" | grep -q "VERSION:" && echo "$PR_DESCRIPTION" | grep -q "CHANGELOG:"; then - # Extract content after "changelog:" - CHANGELOG_TEXT=$(echo $PR_DESCRIPTION | sed -n 's/.*CHANGELOG: \(.*\)/\1/p') - - # Check if extracted CHANGELOG_TEXT is empty or identical to the template content - TEMPLATE_CONTENT=$(cat /tmp/template_content.txt) - if [ -z "$CHANGELOG_TEXT" ] || [ "$CHANGELOG_TEXT" == "$TEMPLATE_CONTENT" ]; then - echo "The changelog information after 'CHANGELOG:' cannot be empty or identical to pull_request_template.md." - exit 1 - fi - - # 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.\nExpected Format:\nVERSION:vX.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." + # 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 sample angular app 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 id: check-change run: | @@ -138,7 +98,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' diff --git a/.github/workflows/set-changelog.js b/.github/workflows/set-changelog.js new file mode 100644 index 0000000..83dba7c --- /dev/null +++ b/.github/workflows/set-changelog.js @@ -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 sample angular app 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'); +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index cb707a1..30beb35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,6 @@ All notable changes to the sample angular app will be documented in this file. ## 2.0.1 -- This action making a CHANGELOG note via special syntax from the GitHub PR commit message, like it could automatically update CHANGELOG.md with the message. First job checks if PR body has changelog note or not if it's not there then it asked them to add it and second job is to check if changelog note has been added in changelog.md file or not. (#116) - Bugfix: Schema file was not included, preventing installation as a component - Bugfix: Manifest build content template was never resolved, so it has been removed. From 8dccf6d49e2ab3a3fefc8ee8057e38e275a4b53c Mon Sep 17 00:00:00 2001 From: Zowe Robot Date: Mon, 16 Oct 2023 06:25:05 +0000 Subject: [PATCH 11/16] Update changelog with PR #116 description Signed-off-by: Zowe Robot --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30beb35..877513d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to the sample angular app will be documented in this file. ## 2.0.1 +- This action making a CHANGELOG note via special syntax from the GitHub PR commit message, like it could automatically update CHANGELOG.md with the message. First job checks if PR body has changelog note or not if it's not there then it asked them to add it and second job is to check if changelog note has been added in changelog.md file or not. (#116) - Bugfix: Schema file was not included, preventing installation as a component - Bugfix: Manifest build content template was never resolved, so it has been removed. From 9190f6d690dd5af3851a5b8537c47b5341eb031c Mon Sep 17 00:00:00 2001 From: Himani1519 Date: Mon, 16 Oct 2023 12:02:30 +0530 Subject: [PATCH 12/16] update changelog.md Signed-off-by: Himani1519 --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 877513d..30beb35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,6 @@ All notable changes to the sample angular app will be documented in this file. ## 2.0.1 -- This action making a CHANGELOG note via special syntax from the GitHub PR commit message, like it could automatically update CHANGELOG.md with the message. First job checks if PR body has changelog note or not if it's not there then it asked them to add it and second job is to check if changelog note has been added in changelog.md file or not. (#116) - Bugfix: Schema file was not included, preventing installation as a component - Bugfix: Manifest build content template was never resolved, so it has been removed. From db64ebfa301b0be44cf335b6b63a50c6b62ee944 Mon Sep 17 00:00:00 2001 From: Zowe Robot Date: Mon, 16 Oct 2023 06:32:50 +0000 Subject: [PATCH 13/16] Update changelog with PR #116 description Signed-off-by: Zowe Robot --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30beb35..877513d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to the sample angular app will be documented in this file. ## 2.0.1 +- This action making a CHANGELOG note via special syntax from the GitHub PR commit message, like it could automatically update CHANGELOG.md with the message. First job checks if PR body has changelog note or not if it's not there then it asked them to add it and second job is to check if changelog note has been added in changelog.md file or not. (#116) - Bugfix: Schema file was not included, preventing installation as a component - Bugfix: Manifest build content template was never resolved, so it has been removed. From 50a2ec5c5ca8109743de319228b6452aa50b6775 Mon Sep 17 00:00:00 2001 From: Himani1519 Date: Mon, 16 Oct 2023 12:13:38 +0530 Subject: [PATCH 14/16] update changelog.md Signed-off-by: Himani1519 --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 877513d..e5f5b22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,6 @@ All notable changes to the sample angular app will be documented in this file. ## 2.0.1 - -- This action making a CHANGELOG note via special syntax from the GitHub PR commit message, like it could automatically update CHANGELOG.md with the message. First job checks if PR body has changelog note or not if it's not there then it asked them to add it and second job is to check if changelog note has been added in changelog.md file or not. (#116) - Bugfix: Schema file was not included, preventing installation as a component - Bugfix: Manifest build content template was never resolved, so it has been removed. From 5b5075a3db6fb0acc7a5c80afe12ca677430be78 Mon Sep 17 00:00:00 2001 From: zowe-robot Date: Fri, 3 Nov 2023 21:15:34 +0000 Subject: [PATCH 15/16] v2.13.0 Signed-off-by: zowe-robot --- manifest.yaml | 2 +- pluginDefinition.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.yaml b/manifest.yaml index 9fd8eff..dcec421 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -2,7 +2,7 @@ name: angular-sample id: org.zowe.zlux.sample.angular # Without the v -version: 2.12.0 +version: 2.13.0 # Human readable component name title: Angular Sample # Human readable component description diff --git a/pluginDefinition.json b/pluginDefinition.json index 6c12cd0..dc8f4de 100644 --- a/pluginDefinition.json +++ b/pluginDefinition.json @@ -1,7 +1,7 @@ { "identifier": "org.zowe.zlux.sample.angular", "apiVersion": "2.0.0", - "pluginVersion": "2.12.0", + "pluginVersion": "2.13.0", "pluginType": "application", "license": "EPL-2.0", "author": "Zowe", From 33958add0eb1fb0f38f0d05a62e3db222765e04e Mon Sep 17 00:00:00 2001 From: zowe-robot Date: Mon, 18 Dec 2023 15:39:25 +0000 Subject: [PATCH 16/16] v2.14.0 Signed-off-by: zowe-robot --- manifest.yaml | 2 +- pluginDefinition.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.yaml b/manifest.yaml index dcec421..5ed3358 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -2,7 +2,7 @@ name: angular-sample id: org.zowe.zlux.sample.angular # Without the v -version: 2.13.0 +version: 2.14.0 # Human readable component name title: Angular Sample # Human readable component description diff --git a/pluginDefinition.json b/pluginDefinition.json index dc8f4de..fe1a892 100644 --- a/pluginDefinition.json +++ b/pluginDefinition.json @@ -1,7 +1,7 @@ { "identifier": "org.zowe.zlux.sample.angular", "apiVersion": "2.0.0", - "pluginVersion": "2.13.0", + "pluginVersion": "2.14.0", "pluginType": "application", "license": "EPL-2.0", "author": "Zowe",