Skip to content

Commit

Permalink
Merge pull request #188 from jamshale/release-improvements
Browse files Browse the repository at this point in the history
Workflow Improvements
  • Loading branch information
jamshale authored Apr 24, 2024
2 parents 0f7d205 + c231331 commit 2f3c643
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 44 deletions.
98 changes: 63 additions & 35 deletions .github/workflows/create-release-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
Expand Down Expand Up @@ -70,29 +71,34 @@ jobs:
echo current_global_version=$version >> $GITHUB_OUTPUT
echo "Global version = $version"
#----------------------------------------------
# Re-Release Check
#----------------------------------------------
- name: Re-Release Check
if: ${{ inputs.re_release }} == "true"
run: |
echo "Re-Release manually requested. Skipping upgrade available check."
#----------------------------------------------
# Check if aries-cloudagent upgrade available
# If the global version is greater than or equal to the remote version, exit
# If re-release is requested, skip this step
#----------------------------------------------
- name: Check if aries-cloudagent upgrade available
if: ${{ inputs.re_release }} != "true"
run: |
current_available_version="${{steps.current_available_version.outputs.current_available_version}}"
echo "Remote version = $current_available_version"
current_global_version="${{steps.current_global_version.outputs.current_global_version}}"
echo "Global version = $current_global_version"
# Compare versions
sem_version () {
echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }';
}
echo "Input re-release = ${{ inputs.re_release }}"
if [ ${{ inputs.re_release }} == "true" ]; then
echo "Re-Release requested"
else
if [ $(sem_version $current_global_version) -ge $(sem_version $current_available_version) ]; then
echo "Version of aries-cloudagent is up to date"
exit 1
fi
echo "Detected aries-cloudagent upgrade available..."
if [ $(sem_version $current_global_version) -ge $(sem_version $current_available_version) ]; then
echo "Version of aries-cloudagent is up to date"
exit 1
fi
echo "Detected aries-cloudagent upgrade available..."
#----------------------------------------------
# Update global aries-cloudagent version in lock file
#----------------------------------------------
Expand Down Expand Up @@ -214,20 +220,22 @@ jobs:
cd ../..
done
echo integration_test_plugins=${failed_plugins[*]} >> $GITHUB_OUTPUT
- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#----------------------------------------------
# Integration Test Failure Check
#----------------------------------------------
- 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
Expand Down Expand Up @@ -267,9 +275,6 @@ jobs:
git config --global user.name 'Release Bot'
git config --global user.email '[email protected]'
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
Expand All @@ -288,15 +293,10 @@ jobs:
echo "$body" | cat - RELEASES.md > temp && mv temp RELEASES.md
# Add the updated pyproject.toml and RELEASES.md files
git add ./*pyproject.toml
git add ./RELEASES.md
# Check if there are any upgrades
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
Expand All @@ -314,15 +314,43 @@ jobs:
exit 1
fi
git commit -s -m "Release v$release_version Upgrades"
git push --set-upstream origin "release-v$release_version"
# Create the PR
# Update the release notes with the upgraded plugins
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"
# Replace the first occurence of ' - ' with the details
sed '0,/ - /{s// ${details}/}'' RELEASES.md
# Add the updated pyproject.toml and RELEASES.md files
git add ./*pyproject.toml
git add ./RELEASES.md
git commit -s -m "Release v$release_version Upgrades"
# 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 <[email protected]>
committer: Release Bot <[email protected]>
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: "${{ 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
36 changes: 27 additions & 9 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
Expand Down Expand Up @@ -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 }}
Expand All @@ -79,7 +80,6 @@ jobs:
git config --global user.name 'Release Bot'
git config --global user.email '[email protected]'
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
Expand Down Expand Up @@ -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 }}
name: ${{ steps.prepare_release.outputs.tag }}
body: ${{ steps.prepare_release.outputs.body }}
tag_name: ${{ steps.prepare_release.outputs.tag }}
prerelease: false

0 comments on commit 2f3c643

Please sign in to comment.