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 #69 from jamshale/release
Release Workflows
- Loading branch information
Showing
6 changed files
with
2,961 additions
and
13 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 |
---|---|---|
@@ -0,0 +1,200 @@ | ||
name: Create Release PR | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
re_release: | ||
description: 'Re-Release same version with fixes' | ||
required: false | ||
type: boolean | ||
schedule: | ||
- cron: "0 0 * * *" | ||
|
||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
|
||
checks: | ||
name: "Create Release PR" | ||
permissions: write-all | ||
runs-on: ubuntu-latest | ||
outputs: | ||
current_available_version: ${{ steps.current_available_version.outputs.version }} | ||
current_global_version: ${{ steps.current_global_version.outputs.version }} | ||
upgrade_available: ${{ steps.current_global_version.outputs.available }} | ||
lint_plugins: ${{ steps.lint_plugins.outputs.lint_plugins }} | ||
unit_test_plugins: ${{ steps.unit_test_plugins.outputs.unit_test_plugins }} | ||
integration_test_plugins: ${{ steps.integration_test_plugins.outputs.integration_test_plugins }} | ||
defaults: | ||
run: | ||
working-directory: . | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: Install poetry | ||
run: pipx install poetry | ||
id: setup-poetry | ||
|
||
- name: Get latest aries-cloudagent version | ||
id: current_available_version | ||
run: | | ||
remote_version=$(pip index versions aries-cloudagent) | ||
version=$(grep -oP '(?<=Available versions: ).*?(?=,)' <<< "$remote_version") | ||
echo current_available_version=$version >> $GITHUB_OUTPUT | ||
echo "Remote version = $version" | ||
- name: Get global aries-cloudagent version from plugins repo | ||
id: current_global_version | ||
run: | | ||
cd plugin_globals | ||
lock_version=$(grep -A1 'name = "aries-cloudagent"' poetry.lock | grep -v 'name = "aries-cloudagent"') | ||
version=$(grep -oP '(?<=").*?(?=")' <<< "$lock_version") | ||
echo current_global_version=$version >> $GITHUB_OUTPUT | ||
echo "Global version = $version" | ||
- name: Check if aries-cloudagent upgrade available | ||
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" | ||
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..." | ||
fi | ||
- name: Update global acapy version | ||
run: | | ||
python repo_manager.py 2 | ||
echo "Update global acapy version" | ||
- name: Run global updates | ||
run: | | ||
python repo_manager.py 3 | ||
echo "Upgrade all plugins" | ||
- name: Lint plugins | ||
id: lint_plugins | ||
continue-on-error: true | ||
run: | | ||
declare -a failed_plugins=() | ||
for dir in ./*/; do | ||
current_folder=$(basename "$dir") | ||
if [[ $current_folder == "plugin_globals" ]]; then | ||
continue | ||
fi | ||
cd $current_folder | ||
poetry install --no-interaction --no-root --extras "aca-py" | ||
if poetry run ruff check .; then | ||
echo "plugin $current_folder passed lint check" | ||
else | ||
echo "plugin $current_folder failed lint check" | ||
failed_plugins+=("$current_folder") | ||
fi | ||
cd .. | ||
done | ||
echo lint_plugins=${failed_plugins[*]} >> $GITHUB_OUTPUT | ||
- name: Unit Test Plugins | ||
id: unit_test_plugins | ||
continue-on-error: true | ||
run: | | ||
declare -a failed_plugins=() | ||
for dir in ./*/; do | ||
current_folder=$(basename "$dir") | ||
if [[ $current_folder == "plugin_globals" ]]; then | ||
continue | ||
fi | ||
cd $current_folder | ||
poetry install --no-interaction --no-root --extras "aca-py" | ||
if poetry run pytest; then | ||
echo "plugin $current_folder passed unit test check" | ||
else | ||
echo "plugin $current_folder failed unit test check" | ||
failed_plugins+=("$current_folder") | ||
fi | ||
cd .. | ||
done | ||
echo unit_test_plugins=${failed_plugins[*]} >> $GITHUB_OUTPUT | ||
# - name: Initialize Docker Compose | ||
# uses: isbang/[email protected] | ||
# - name: Integration Test Plugins | ||
# id: integration_test_plugins | ||
# continue-on-error: true | ||
# run: | | ||
# declare -a failed_plugins=() | ||
# for dir in ./*/; do | ||
# current_folder=$(basename "$dir") | ||
# if [[ $current_folder == "plugin_globals" ]]; then | ||
# continue | ||
# fi | ||
# cd $current_folder/integration | ||
# docker compose down --remove-orphans | ||
# docker compose build | ||
# if docker compose run tests; then | ||
# echo "plugin $current_folder passed integration test check" | ||
# else | ||
# echo "plugin $current_folder failed integration test check" | ||
# failed_plugins+=("$current_folder") | ||
# fi | ||
# cd ../.. | ||
# done | ||
# echo integration_test_plugins=${failed_plugins[*]} >> $GITHUB_OUTPUT | ||
- name: Create Pull Request | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
echo "Merging failed plugins" | ||
failed_plugins=() | ||
lint_plugins=(${{steps.lint_plugins.outputs.lint_plugins}}) | ||
unit_test_plugins=(${{steps.unit_test_plugins.outputs.unit_test_plugins}}) | ||
for plugin in "${lint_plugins[@]}"; do | ||
if [[ ! " ${failed_plugins[@]} " =~ " $plugin " ]]; then | ||
failed_plugins+=("$plugin") | ||
fi | ||
done | ||
for plugin in "${unit_test_plugins[@]}"; do | ||
if [[ ! " ${failed_plugins[@]} " =~ " $plugin " ]]; then | ||
failed_plugins+=("$plugin") | ||
fi | ||
done | ||
echo "Failed plugins: ${failed_plugins[*]}" | ||
release_version="${{steps.current_available_version.outputs.current_available_version}}" | ||
echo "Remote version = $release_version" | ||
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/jamshale/aries-acapy-plugins | ||
git fetch --all | ||
git push origin -d "release-v$release_version" | ||
git checkout -b "release-v$release_version" | ||
git add . | ||
for plugin in "${failed_plugins[@]}"; do | ||
git restore --staged $plugin | ||
git checkout -- $plugin | ||
done | ||
body=$(python repo_manager.py 4) | ||
git add ./*pyproject.toml | ||
git commit -s -m "Pre-Release Upgrades" | ||
git push --set-upstream origin "release-v$release_version" | ||
title="Release for aries-cloudagent v$release_version" | ||
gh pr create --title "$title" --body "$body" --base main --head "release-v$release_version" |
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 |
---|---|---|
@@ -0,0 +1,103 @@ | ||
name: Create Release | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- "main" | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
|
||
checks: | ||
|
||
name: "Create Release" | ||
permissions: write-all | ||
runs-on: ubuntu-latest | ||
outputs: | ||
current_available_version: ${{ steps.current_available_version.outputs.version }} | ||
should_create_release: ${{ steps.should_create_release.outputs.should_create_release }} | ||
defaults: | ||
run: | ||
working-directory: . | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Get latest aries-cloudagent version | ||
id: current_available_version | ||
run: | | ||
remote_version=$(pip index versions aries-cloudagent) | ||
version=$(grep -oP '(?<=Available versions: ).*?(?=,)' <<< "$remote_version") | ||
echo current_available_version=$version >> $GITHUB_OUTPUT | ||
echo "Remote version = $version" | ||
- name: Check If Release Should Be Created | ||
run: | | ||
found_upgrade=false | ||
get_changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }}) | ||
echo "${get_changed_files}" | ||
for file in ${get_changed_files}; do | ||
if [[ $file == *"/poetry.lock"* ] && [ $file != *"integration/poetry.lock"* ]]; then | ||
echo "poetry.lock file found in $file" | ||
lock_version=$(grep -A1 'name = "aries-cloudagent"' $file | grep -v 'name = "aries-cloudagent"') | ||
version=$(grep -oP '(?<=").*?(?=")' <<< "$lock_version") | ||
echo "Current version in $current_folder = $version" | ||
if [ "$version" == "${{ steps.current_available_version.outputs.current_available_version }}" ] | ||
then | ||
found_upgrade=true | ||
fi | ||
fi | ||
done | ||
if [ "$found_upgrade" = true ] | ||
then | ||
echo "Upgrade Detected. Creating Release" | ||
echo should_create_release=true >> $GITHUB_OUTPUT | ||
else | ||
echo "No Upgrade Detected. Skipping Release Creation." | ||
echo should_create_release=false >> $GITHUB_OUTPUT | ||
fi | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.9' | ||
- name: Create Release | ||
if: ${{ steps.should_create_release.outputs.should_create_release }} == 'true' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
echo "Creating release" | ||
remote_version=$(pip index versions aries-cloudagent) | ||
version=$(grep -oP '(?<=Available versions: ).*?(?=,)' <<< "$remote_version") | ||
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/jamshale/aries-acapy-plugins | ||
git fetch --tags | ||
get_tags_output=$(git tag -n0 "*$version*") | ||
echo "Tag output:" | ||
echo "${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 | ||
release_tag=$version | ||
else | ||
release_tag="$version.$tags_num" | ||
fi | ||
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 "Release $release_tag" | ||
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
Oops, something went wrong.