Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: extracts release script to separate file #850

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 2 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,8 @@ jobs:
fi

changed_paths="$(gh pr view --json files --jq '.files.[].path' "${{ github.event.pull_request.number }}" | cut -d / -f 1,2 | uniq)";
changed_packages="$(echo "$changed_paths" | grep 'packages/')";

if [ "$changed_packages" = "" ]; then
echo -e "No packages to release:\n ${changed_paths}" >> $GITHUB_STEP_SUMMARY
exit 0;
fi

pnpm_options=''
for path in $changed_packages; do
pnpm_options="${pnpm_options} --filter ./${path}"
done

echo "running: pnpm run -r $pnpm_options release" >> $GITHUB_STEP_SUMMARY
pnpm run -r $pnpm_options release

released_packages=()
for path in $changed_packages; do
package_name=$(grep '"name":' $path/package.json | cut -d : -f 2 | cut -d '"' -f 2)
package_version=$(grep '"version":' $path/package.json | cut -d : -f 2 | cut -d '"' -f 2)
released_packages[${#released_packages[@]}]="${package_name}@${package_version}"
done
./packages/dx/bin/release-packages.sh "$changed_paths";

if [ "${{github.event.pull_request.number}}" != "" ]; then
gh pr comment "${{ github.event.pull_request.number }}" --body "🚀 Released in ${released_packages[@]}"
gh pr comment "${{ github.event.pull_request.number }}" --body "🚀 Released in ${released_packages[@]}"
fi

echo "🚀 Released in ${released_packages[@]}" >> $GITHUB_STEP_SUMMARY
37 changes: 37 additions & 0 deletions packages/dx/bin/release-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

changed_paths=$1;

if [ "$changed_paths" = "" ];then
echo '
Usage:
./release-packages.sh "packages/casl-ability"
./release-packages.sh "packages/casl-ability packages/casl-angular"
';
exit;
fi

changed_packages="$(echo "$changed_paths" | grep 'packages/')";

if [ "$changed_packages" = "" ]; then
echo "No packages to release" >> $GITHUB_STEP_SUMMARY;
echo "Changed files:\n${changed_paths}" >> $GITHUB_STEP_SUMMARY
exit 0;
fi

pnpm_options=''
for path in $changed_packages; do
pnpm_options="${pnpm_options} --filter ./${path}"
done

echo "running: pnpm run -r $pnpm_options release" >> $GITHUB_STEP_SUMMARY
pnpm run -r $pnpm_options release

released_packages=();
for path in $changed_packages; do
package_name=$(grep '"name":' $path/package.json | cut -d : -f 2 | cut -d '"' -f 2);
package_version=$(grep '"version":' $path/package.json | cut -d : -f 2 | cut -d '"' -f 2);
released_packages[${#released_packages[@]}]="${package_name}@${package_version}";
done

echo "🚀 Released in ${released_packages[@]}" >> $GITHUB_STEP_SUMMARY