Skip to content

Commit

Permalink
chore: extracts release script to separate file (#850)
Browse files Browse the repository at this point in the history
  • Loading branch information
stalniy authored Nov 21, 2023
1 parent e1646ef commit 880ecae
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 24 deletions.
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

0 comments on commit 880ecae

Please sign in to comment.