forked from openwallet-foundation/acapy-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #195 from jamshale/release-improvements
Workflow Improvements
- Loading branch information
Showing
2 changed files
with
91 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ on: | |
re_release: | ||
description: 'Re-Release same version with fixes' | ||
required: false | ||
default: false | ||
type: boolean | ||
schedule: | ||
- cron: "0 0 * * *" | ||
|
@@ -28,6 +29,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: . | ||
|
@@ -70,29 +72,34 @@ jobs: | |
echo current_global_version=$version >> $GITHUB_OUTPUT | ||
echo "Global version = $version" | ||
#---------------------------------------------- | ||
# Re-Release Check | ||
#---------------------------------------------- | ||
- name: Re-Release Check | ||
if: ${{ github.event.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: ${{ github.event.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 | ||
#---------------------------------------------- | ||
|
@@ -214,20 +221,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 | ||
|
@@ -267,9 +276,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 | ||
|
@@ -288,15 +294,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 | ||
|
@@ -314,15 +315,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 -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" | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 '[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 | ||
|
@@ -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 | ||
|