From c44438d4d5707ba0a0f4ac7dd57cf9ea33aa35af Mon Sep 17 00:00:00 2001 From: jamshale Date: Tue, 23 Apr 2024 11:15:22 -0700 Subject: [PATCH 1/2] Creating PR Improvements Signed-off-by: jamshale --- .github/workflows/create-release-pr.yaml | 58 +++++++++++++++--------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/.github/workflows/create-release-pr.yaml b/.github/workflows/create-release-pr.yaml index 85f1e2cf7..e07ccbcc3 100644 --- a/.github/workflows/create-release-pr.yaml +++ b/.github/workflows/create-release-pr.yaml @@ -28,6 +28,7 @@ jobs: integration_test_plugins: ${{ steps.integration_test_plugins.outputs.integration_test_plugins }} integration_test_exit_code: ${{ steps.integration_test_plugins.outputs.integration_test_exit_code }} all_potential_upgrades: ${{ steps.all_potential_upgrades.outputs.all_potential_upgrades }} + pr_body: ${{ steps.prepare_pr.outputs.pr_body }} defaults: run: working-directory: . @@ -214,20 +215,22 @@ jobs: cd ../.. done echo integration_test_plugins=${failed_plugins[*]} >> $GITHUB_OUTPUT - - name: Create Pull Request - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + #---------------------------------------------- + # Prepare Pull Request + #---------------------------------------------- + - name: Integration Test Failure Check + if: ${{ steps.integration_test_plugins.outputs.integration_test_exit_code }} == 17 + run: | + echo "Integration tests failed with exit code 17. Skipping commit and release" + echo integration_test_exit_code=17 >> $GITHUB_OUTPUT + # ---------------------------------------------- + # Prepare Pull Request + # ---------------------------------------------- + - name: Prepare Pull Request + id: prepare_pr run: | echo "Merging failed plugins" failed_plugins=() - - integration_test_exit_code="${{ steps.integration_test_plugins.outputs.integration_test_exit_code }}" - echo "Integration test exit code: $integration_test_exit_code" - - if [[ $integration_test_exit_code == "17" ]]; then - echo "Integration tests failed with exit code 17. Skipping commit and release" - exit 1 - fi # Merge all failed plugins @@ -267,9 +270,6 @@ jobs: git config --global user.name 'Release Bot' git config --global user.email 'release-bot@users.noreply.github.com' - git remote set-url --push origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/hyperledger/aries-acapy-plugins - git fetch --all - git checkout -b "release-v$release_version" # Add all the changed files and then remove the failed plugins @@ -296,7 +296,6 @@ jobs: upgraded_plugins=$(python repo_manager.py 5) has_upgrades=false - echo for plugin in ${potential_upgrades[@]}; do for upgrade in ${upgraded_plugins[@]}; do if [[ $plugin == *"$upgrade"* ]]; then @@ -315,14 +314,31 @@ jobs: fi git commit -s -m "Release v$release_version Upgrades" - git push --set-upstream origin "release-v$release_version" - - # Create the PR - details="Plugins upgraded this release: " for plugin in ${upgraded_plugins}; do details="$details $plugin" done - title="Release for aries-cloudagent v$release_version" - gh pr create --title "$title" --body "$body $details" --base main --head "release-v$release_version" + # Prepare the PR body + + EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) + echo "pr_body<<$EOF" >> $GITHUB_OUTPUT + echo "$body $details" >> $GITHUB_OUTPUT + echo "$EOF" >> $GITHUB_OUTPUT + #---------------------------------------------- + # Create Release PR + #---------------------------------------------- + - name: Create PR + uses: peter-evans/create-pull-request@v6 + with: + author: Release Bot + committer: Release Bot + token: ${{ secrets.BOT_PR_PAT }} + commit-message: "Release v${{ steps.current_available_version.outputs.current_available_version }}" + title: "Release for aries-cloudagent v${{ steps.current_available_version.outputs.current_available_version }}" + body: "Release v${{ steps.prepare_pr.outputs.pr_body }}" + branch: "release-v${{ steps.current_available_version.outputs.current_available_version }}" + base: "main" + draft: false + signoff: true + delete-branch: true From 92bd3838dbab53baae1353975f106f756135439f Mon Sep 17 00:00:00 2001 From: jamshale Date: Tue, 23 Apr 2024 16:10:24 -0700 Subject: [PATCH 2/2] Creating Release --- .github/workflows/create-release.yaml | 36 ++++++++++++++++++++------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 150aafb28..5fc4f2c90 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -16,6 +16,8 @@ jobs: runs-on: ubuntu-latest outputs: should_create_release: ${{ steps.should_create_release.outputs.should_create_release }} + body: ${{ steps.prepare_release.outputs.body }} + tag: ${{ steps.prepare_release.outputs.tag }} defaults: run: working-directory: . @@ -65,12 +67,11 @@ jobs: fi echo should_create_release=$found_upgrade >> $GITHUB_OUTPUT # ---------------------------------------------- - # Create Release + # Prepare Release # ---------------------------------------------- - - name: Create Release - if: steps.should_create_release.outputs.should_create_release == 'true' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Prepare Release + id: prepare_release + if: steps.should_create_release.outputs.should_create_release == 'true' run: | echo "Creating release" echo ${{ steps.should_create_release.outputs.should_create_release }} @@ -79,7 +80,6 @@ jobs: git config --global user.name 'Release Bot' git config --global user.email 'release-bot@users.noreply.github.com' - git remote set-url --push origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/hyperledger/aries-acapy-plugins git fetch --tags # Determine the release tag @@ -113,7 +113,25 @@ jobs: details="$details $plugin" done - git tag -a $release_tag -m "Release $tag" - git push origin $release_tag - gh release create $release_tag --title "Release for aries-cloudagent v$version" --notes "$body $details" + # Set the outputs + + echo tag=$release_tag >> $GITHUB_OUTPUT + + EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) + echo "release_body<<$EOF" >> $GITHUB_OUTPUT + echo "$body $details" >> $GITHUB_OUTPUT + echo "$EOF" >> $GITHUB_OUTPUT + + # ---------------------------------------------- + # Create Release + # ---------------------------------------------- + - name: Create Release + if: steps.should_create_release.outputs.should_create_release == 'true' + uses: softprops/action-gh-release@v2 + with: + token: ${{ secrets.BOT_PR_PAT }} + release_name: ${{ steps.prepare_release.outputs.tag }} + body: ${{ steps.prepare_release.outputs.body }} + tag_name: ${{ steps.prepare_release.outputs.tag }} + prerelease: false