Skip to content

Commit

Permalink
Merge pull request #250 from jamshale/release-improvements
Browse files Browse the repository at this point in the history
Release improvements
  • Loading branch information
jamshale authored May 2, 2024
2 parents 2de7352 + c7b5510 commit 622b324
Show file tree
Hide file tree
Showing 22 changed files with 214 additions and 212 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ReleaseWorkflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ title: Create Release Workflow
flowchart TB
Start[Create Release] --> OnPushMain[On Push to Main]
OnPushMain --> CheckChangeSet{Check ACAPY Version in Change Set}
CheckChangeSet --> |No updated lock files| End
CheckChangeSet --> |Updated lock files| ConfigureGit[Configure Git]
OnPushMain --> ChangedPoetryFiles{Changed poetry.lock Files?}
ChangedPoetryFiles --> |No| End
ChangedPoetryFiles --> |Yes| ConfigureGit[Configure Git]
ConfigureGit --> GetReleaseTags[Get Release Tags - Based on ACA-PY Version]
GetReleaseTags --> TagsExist{Tags Exist}
TagsExist --> |Yes| IncrementPatch[Increment Patch]
TagsExist --> |Yes| IncrementPatch[Increment Patch Version. Ex: 1.0.0 -> 1.0.0.1 or 1.0.0.1 -> 1.0.0.2]
TagsExist --> |No| CreateTagOnACAPYVersion[Create Tag on ACA-PY Version]
IncrementPatch --> GetReleaseNotes[Get Release Notes and Plugins That Updated]
CreateTagOnACAPYVersion --> GetReleaseNotes
GetReleaseNotes --> CreateReleaseBranch[Create Release Branch]
GetReleaseNotes --> CreateRelease[Create Release]
```
68 changes: 41 additions & 27 deletions .github/workflows/create-release-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
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 }}
tag_version: ${{ steps.prepare_pr.outputs.tag_version }}
defaults:
run:
working-directory: .
Expand Down Expand Up @@ -97,7 +98,7 @@ jobs:
if [ $(sem_version $current_global_version) -ge $(sem_version $current_available_version) ]; then
echo "Version of aries-cloudagent is up to date"
exit 1
exit 0
fi
echo "Detected aries-cloudagent upgrade available..."
#----------------------------------------------
Expand Down Expand Up @@ -239,7 +240,6 @@ jobs:
failed_plugins=()
# Merge all failed plugins
potential_upgrades=(${{ steps.all_potential_upgrades.outputs.all_potential_upgrades }})
echo "All potential upgrades: ${{ steps.all_potential_upgrades.outputs.all_potential_upgrades }}"
Expand Down Expand Up @@ -268,36 +268,44 @@ jobs:
echo "Failed plugins: ${failed_plugins[*]}"
# Get release for the branch name and docs
release_version="${{steps.current_available_version.outputs.current_available_version}}"
echo "Remote version = $release_version"
# Configure the git bot
git config --global user.name 'Release Bot'
git config --global user.email 'release-bot@users.noreply.github.com'
# Add all the changed files and then remove the failed plugins
git add .
for plugin in "${failed_plugins[@]}"; do
git restore --staged $plugin
git checkout -- $plugin
done
# Get the release notes and update the plugin decription with acapy version
body=$(python repo_manager.py 4)
# Update the RELEASES.md file with the release notes
# Determine the release version via tags
get_tags_output=$(git tag -n0 "*$release_version*")
echo "Tag output: ${get_tags_output}"
tags_num=0
for item in ${get_tags_output}; do
tags_num=$((tags_num+1))
done
tag_version=""
if [ $tags_num -eq 0 ]
then
tag_version=$release_version
else
tag_version="$release_version.$tags_num"
fi
# Update the RELEASES.md file with the release notes
echo "$body" | cat - RELEASES.md > temp && mv temp RELEASES.md
# Check if there are any upgrades
upgraded_plugins=$(python repo_manager.py 5)
upgraded_plugins=($(python repo_manager.py 5))
has_upgrades=false
for plugin in ${potential_upgrades[@]}; do
for upgrade in ${upgraded_plugins[@]}; do
if [[ $plugin == *"$upgrade"* ]]; then
Expand All @@ -306,7 +314,6 @@ jobs:
fi
done
done
if [ "$has_upgrades" = true ]
then
echo "Upgrades detected. Committing the changes"
Expand All @@ -315,29 +322,36 @@ jobs:
exit 1
fi
# Update the release notes with the upgraded plugins
details="Plugins upgraded this release: "
for plugin in ${upgraded_plugins}; do
details="$details $plugin"
# Update the release notes with the upgraded plugins.
# For replacing with the sed command we need to double escape the newline and tab characters.
details=$(printf '#### Plugins upgraded this release: \n\t - ')
double_escape_details=$(printf '#### Plugins upgraded this release: \\n\\t - ')
# For replacing the first occurence of ' - ' with the details
count=${#upgraded_plugins[*]}
for i in $(seq 0 "$(("$count" - 2))" );
do
details=$(printf '%s %s \n\t - ' "$details" "${upgraded_plugins[$i]}")
double_escape_details=$(printf '%s %s \\n\\t - ' "$double_escape_details" "${upgraded_plugins[$i]}")
done
details=$(printf '%s %s \n' "$details" "${upgraded_plugins[$count - 1]}")
double_escape_details=$(printf '%s %s \n' "$double_escape_details" "${upgraded_plugins[$count - 1]}")
# Replace the first occurence of ' - ' with the details
sed -i "0,/\s\-\s/s// - $(printf '%s ' ${double_escape_details})/" RELEASES.md
sed -i "0,/\s\-\s/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"
# Replace the release version with the release tag
sed -i "0,/v$release_version/{s/v$release_version/v$tag_version/}" RELEASES.md
body=${body/v$release_version/v$tag_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
# Set the tag version output
echo tag_version=$tag_version >> $GITHUB_OUTPUT
#----------------------------------------------
# Create Release PR
#----------------------------------------------
Expand All @@ -347,10 +361,10 @@ jobs:
author: Release Bot <release-bot@users.noreply.github.com>
committer: Release Bot <release-bot@users.noreply.github.com>
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 }}"
commit-message: "Release v${{ steps.prepare_pr.outputs.tag_version }} Upgrades"
title: "Release for aries-cloudagent v${{ steps.prepare_pr.outputs.tag_version }}"
body: "${{ steps.prepare_pr.outputs.pr_body }}"
branch: "release-v${{ steps.current_available_version.outputs.current_available_version }}"
branch: "release-v${{ steps.prepare_pr.outputs.tag_version }}"
base: "main"
draft: false
signoff: true
Expand Down
71 changes: 15 additions & 56 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Create Release

on:
push:
branches:
- "main"
branches: ['main']
paths: ['*/poetry.lock']

permissions:
contents: write
Expand All @@ -15,7 +15,6 @@ jobs:
permissions: write-all
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:
Expand All @@ -32,69 +31,30 @@ jobs:
with:
python-version: '3.9'
# ----------------------------------------------
# Check if a release should be created
# ----------------------------------------------
- name: Check If Release Should Be Created
id: should_create_release
run: |
found_upgrade=false
get_changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})
echo "${get_changed_files}"
upgraded_plugins=$(python repo_manager.py 5)
echo "${upgraded_plugins}"
# Check if any of the changed files are poetry.lock files
# and if they not match the global poetry.lock file
for file in ${get_changed_files}; do
if [[ $file == *"/poetry.lock"* ]] && [[ $file != *"integration/poetry.lock"* ]]; then
for plugin in ${upgraded_plugins}; do
if [[ $file == *"$plugin"* ]]; then
echo "Upgrade Detected for $plugin in file $file"
found_upgrade=true
fi
done
fi
done
if [ "$found_upgrade" = true ]
then
echo "Upgrade Detected. Creating Release"
else
echo "No Upgrade Detected. Skipping Release Creation."
fi
echo should_create_release=$found_upgrade >> $GITHUB_OUTPUT
# ----------------------------------------------
# Prepare Release
# ----------------------------------------------
- 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 }}
# Get the latest version
remote_version=$(pip index versions aries-cloudagent)
version=$(grep -oP '(?<=Available versions: ).*?(?=,)' <<< "$remote_version")
# Set the git config
git config --global user.name 'Release Bot'
git config --global user.email 'release-bot@users.noreply.github.com'
git fetch --tags
# Determine the release tag
get_tags_output=$(git tag -n0 "*$version*")
echo "Tag output:"
echo "${get_tags_output}"
echo "Tag output: ${get_tags_output}"
tags_num=0
for item in ${get_tags_output}; do
tags_num=$((tags_num+1))
done
echo "Number of matched tags: $tags_num"
release_tag=""
if [ $tags_num -eq 0 ]
then
Expand All @@ -104,19 +64,19 @@ jobs:
fi
# Get the release notes
body=$(python repo_manager.py 4)
details="Plugins upgraded this release: "
upgraded_plugins=$(python repo_manager.py 5)
for plugin in ${upgraded_plugins}; do
details="$details $plugin"
body=${body/v$version/v$release_tag}
upgraded_plugins=($(python repo_manager.py 5))
details=$(printf '#### Plugins upgraded this release: \n\t - ')
count=${#upgraded_plugins[*]}
for i in $(seq 0 "$(("$count" - 2))" );
do
details=$(printf '%s %s \n\t - ' "$details" "${upgraded_plugins[$i]}")
done
details=$(printf '%s %s \n' "$details" "${upgraded_plugins[$count - 1]}")
# 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
Expand All @@ -126,12 +86,11 @@ jobs:
# 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 }}
body: ${{ steps.prepare_release.outputs.release_body }}
tag_name: ${{ steps.prepare_release.outputs.tag }}
prerelease: false

15 changes: 14 additions & 1 deletion basicmessage_storage/poetry.lock

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

1 change: 1 addition & 0 deletions basicmessage_storage/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ indy-credx = { version = "~1.1.1" }
indy-vdr = { version = "~0.4.1" }
ursa-bbs-signatures = { version = "~1.0.1" }
python3-indy = { version = "^1.11.1" }
anoncreds = { version = "0.2.0" }

[tool.ruff]
line-length = 90
Expand Down
15 changes: 14 additions & 1 deletion connection_update/poetry.lock

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

1 change: 1 addition & 0 deletions connection_update/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ indy-credx = { version = "~1.1.1" }
indy-vdr = { version = "~0.4.1" }
ursa-bbs-signatures = { version = "~1.0.1" }
python3-indy = { version = "^1.11.1" }
anoncreds = { version = "0.2.0" }

[tool.ruff]
line-length = 90
Expand Down
Loading

0 comments on commit 622b324

Please sign in to comment.