From 20b616c341964ef8198210225b2f8803923a26a2 Mon Sep 17 00:00:00 2001 From: Michael Gardner Date: Thu, 17 Oct 2024 09:45:59 -0400 Subject: [PATCH] HPCC-30890 Changelogs automation for hpccsystems projects Signed-off-by: Michael Gardner --- .github/workflows/changelogs.yml | 145 +++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 .github/workflows/changelogs.yml diff --git a/.github/workflows/changelogs.yml b/.github/workflows/changelogs.yml new file mode 100644 index 00000000000..4bbd40f1038 --- /dev/null +++ b/.github/workflows/changelogs.yml @@ -0,0 +1,145 @@ +name: Change Logs + +on: + workflow_dispatch: + + push: + tags: + - "*" + - "community_*" + - "!community_8.10.*" + - "!community_8.8.*" + - "!community_8.6.*" + - "!community_8.4.*" + - "!community_8.2.*" + - "!community_8.0.*" + - "!community_7.*" + +jobs: + changelogs: + runs-on: ubuntu-latest + name: Generate Changelogs + outputs: + community_ref: ${{ steps.vars.outputs.community_ref }} + internal_ref: ${{ steps.vars.outputs.internal_ref }} + eclide_ref: ${{ steps.vars.outputs.eclide_ref }} + current_version: ${{ steps.get_version.outputs.current_version }} + previous_rc_version: ${{ steps.get_version.outputs.previous_rc_version }} + previous_gold_version: ${{ steps.get_version.outputs.previous_gold_version }} + folder_platform: ${{ steps.vars.outputs.folder_platform }} + folder_ln: ${{ steps.vars.outputs.folder_ln }} + folder_eclide: ${{ steps.vars.outputs.folder_eclide }} + folder_prettyLogs: ${{ steps.vars.outputs.folder_prettyLogs }} + type: ${{ steps.get_version.outputs.type }} + steps: + - name: Calculate vars + id: vars + shell: bash + run: | + community_ref=${{ github.ref }} + echo "community_ref=$community_ref" >> $GITHUB_OUTPUT + echo "internal_ref=$(echo $community_ref | sed 's/community/internal/')" >> $GITHUB_OUTPUT + echo "eclide_ref=$(echo $community_ref | sed 's/community/eclide/')" >> $GITHUB_OUTPUT + echo "folder_platform=${{ github.workspace }}/HPCC-Platform" >> $GITHUB_OUTPUT + echo "folder_ln=${{ github.workspace }}/LN" >> $GITHUB_OUTPUT + echo "folder_eclide=${{ github.workspace }}/ECLIDE" >> $GITHUB_OUTPUT + echo "folder_prettyLogs=${{ github.workspace }}/PrettyGitLogs" >> $GITHUB_OUTPUT + + - name: Checkout HPCC-Platform + uses: actions/checkout@v4 + with: + ref: ${{ steps.vars.outputs.community_ref }} + submodules: recursive + path: ${{ steps.vars.outputs.folder_platform }} + fetch-tags: true + fetch-depth: 0 + - name: Checkout LN + uses: actions/checkout@v4 + with: + repository: ${{ github.repository_owner }}/LN + token: ${{ secrets.LNB_TOKEN }} + ref: ${{ steps.vars.outputs.internal_ref }} + submodules: recursive + path: ${{ steps.vars.outputs.folder_ln }} + - name: Checkout ECLIDE + uses: actions/checkout@v4 + with: + repository: ${{ github.repository_owner }}/ECLIDE + ref: ${{ steps.vars.outputs.eclide_ref }} + submodules: recursive + path: ${{ steps.vars.outputs.folder_eclide }} + - name: Checkout PrettyGitLogs + uses: actions/checkout@v4 + with: + repository: gfortil/PrettyGitLogs + ref: master + path: ${{ steps.vars.outputs.folder_prettyLogs }} + + - name: Get Previous Versions + id: get_version + shell: bash + working-directory: ${{ steps.vars.outputs.folder_platform }} + run: | + tag=$(git describe --exact-match --tags 2>/dev/null) + version=$(echo $tag | cut -d_ -f2) + major=$(echo $version | cut -d. -f1) + minor=$(echo $version | cut -d. -f2) + point=$(echo $version | cut -d. -f3 | cut -d- -f1) + type=$(echo $version | cut -d- -f2) + if [[ $point -eq 0 ]]; then + if [[ $minor -eq 0 ]]; then + major=$((major - 1)) + previous_rc=$(git tag --create-reflog --sort=-v:refname | grep -E "^community_$major\.[0-9]*\.[0-9]*-rc" | head -n 1) + previous_gold=$(git tag --create-reflog --sort=-v:refname | grep -E "^community_$major\.[0-9]*\.[0-9]*-[0-9]" | head -n 1) + else + minor=$((minor - 2)) + previous_rc=$(git tag --create-reflog --sort=-v:refname | grep -E "^community_$major\.$minor\.[0-9]*-rc" | head -n 1) + previous_gold=$(git tag --create-reflog --sort=-v:refname | grep -E "^community_$major\.$minor\.[0-9]*-[0-9]" | head -n 1) + fi + else + point=$((point - 2)) + previous_rc=$(git tag --create-reflog --sort=-v:refname | grep -E "^community_$major\.$minor\.$point-rc" | head -n 1) + previous_gold=$(git tag --create-reflog --sort=-v:refname | grep -E "^community_$major\.$minor\.$point-[0-9]" | head -n 1) + fi + echo "current_version=$version" >> $GITHUB_OUTPUT + echo "previous_rc_version=$previous_rc" >> $GITHUB_OUTPUT + echo "previous_gold_version=$previous_gold" >> $GITHUB_OUTPUT + echo "type=$type" >> $GITHUB_OUTPUT + + - name: Print vars + run: | + echo "${{ toJSON(steps.vars.outputs) }})" + echo "${{ toJSON(steps.get_version.outputs) }})" + + - name: Generate Changelogs + shell: bash + working-directory: ${{ steps.vars.outputs.folder_prettyLogs }} + run: | + # provide credentials + sed -i -e '/^JIRAUser/c\JIRAUser=${{ secrets.JIRA_USERNAME}}' prettylogs.conf + sed -i -e '/^JIRAPW/c\JIRAPW=${{ secrets.JIRA_TOKEN }}' prettylogs.conf + + # Generate Changelogs + if [[ ! "${{ steps.get_version.outputs.type }}" == *"rc"* ]]; then + perl ./prettyLogs.pl -bt community_${{ steps.get_version.outputs.current_version }} -et community_${{ steps.get_version.outputs.previous_gold_version }} -repo ${{ steps.vars.outputs.folder_platform }} -sort -html community_${{ steps.get_version.outputs.current_version }} + perl ./prettyLogs.pl -bt internal_${{ steps.get_version.outputs.current_version }} -et internal_${{ steps.get_version.outputs.previous_gold_version }} -repo ${{ steps.vars.outputs.folder_internal }} -sort -html internal_${{ steps.get_version.outputs.current_version }} + perl ./prettyLogs.pl -bt eclide_${{ steps.get_version.outputs.current_version }} -et eclide_${{ steps.get_version.outputs.previous_gold_version }} -repo ${{ steps.vars.outputs.folder_eclide }} -sort -html eclide_${{ steps.get_version.outputs.current_version }} + elif [ "${{ steps.get_version.outputs.type }}" == "rc1" ]; then + perl ./prettyLogs.pl -bt community_${{ steps.get_version.outputs.current_version }} -et community_${{ steps.get_version.outputs.previous_gold_version }} -repo ${{ steps.vars.outputs.folder_platform }} -sort -html community_${{ steps.get_version.outputs.current_version }} + perl ./prettyLogs.pl -bt internal_${{ steps.get_version.outputs.current_version }} -et internal_${{ steps.get_version.outputs.previous_gold_version }} -repo ${{ steps.vars.outputs.folder_internal }} -sort -html internal_${{ steps.get_version.outputs.current_version }} + perl ./prettyLogs.pl -bt eclide_${{ steps.get_version.outputs.current_version }} -et eclide_${{ steps.get_version.outputs.previous_gold_version }} -repo ${{ steps.vars.outputs.folder_eclide }} -sort -html eclide_${{ steps.get_version.outputs.current_version }} + else + perl ./prettyLogs.pl -bt community_${{ steps.get_version.outputs.current_version }} -et community_${{ steps.get_version.outputs.previous_rc_version }} -repo ${{ steps.vars.outputs.folder_platform }} -sort -html community_${{ steps.get_version.outputs.current_version }} + perl ./prettyLogs.pl -bt internal_${{ steps.get_version.outputs.current_version }} -et internal_${{ steps.get_version.outputs.previous_rc_version }} -repo ${{ steps.vars.outputs.folder_internal }} -sort -html internal_${{ steps.get_version.outputs.current_version }} + perl ./prettyLogs.pl -bt eclide_${{ steps.get_version.outputs.current_version }} -et eclide_${{ steps.get_version.outputs.previous_rc_version }} -repo ${{ steps.vars.outputs.folder_eclide }} -sort -html eclide_${{ steps.get_version.outputs.current_version }} + fi + - name: Upload Assets + uses: ncipollo/release-action@v1.14.0 + with: + allowUpdates: true + generateReleaseNotes: false + prerelease: ${{ contains(github.ref, '-rc') }} + artifacts: | + community_${{ steps.get_version.outputs.current_version }}.html, + internal_${{ steps.get_version.outputs.current_version }}.html, + eclide_${{ steps.get_version.outputs.current_version }}.html \ No newline at end of file