Skip to content

Commit

Permalink
chore: updates release gha to let me know what is going to be release…
Browse files Browse the repository at this point in the history
…d after merge
  • Loading branch information
stalniy committed Jun 16, 2024
1 parent 40915f8 commit b638ab1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
release:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request || github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'released') }}
if: ${{ contains(github.event.pull_request.labels.*.name, 'released') }}
steps:
- name: Check out code
uses: actions/checkout@v3
Expand Down Expand Up @@ -44,16 +44,21 @@ jobs:
GH_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.RELEASE_NPM_TOKEN }}
ACTIONS_STEP_DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }}
RELEASE_PREVIEW: ${{ github.event.pull_request.merged == false && 'true' || 'false' }}
run: |
if [[ "${TRACE:-false}" == true || "${ACTIONS_STEP_DEBUG:-false}" == true ]]; then
set -o xtrace # Trace the execution of the script (debug)
fi
. ./packages/dx/bin/release-packages.sh
changed_paths="$(gh pr view --json files --jq '.files.[].path' "${{ github.event.pull_request.number }}" | cut -d / -f 1,2 | uniq)";
release_packages "$changed_paths"
release_packages "$changed_paths" "$RELEASE_PREVIEW"
released_packages=$(extract_package_versions "$changed_paths");
if [[ "${{github.event.pull_request.number}}" != "" && "$released_packages" != "" ]]; then
gh pr comment "${{ github.event.pull_request.number }}" --body "🚀 Released in ${released_packages}"
body="After merging this PR, changes will be released in ${released_packages}"
if [ "$RELEASE_PREVIEW" = "false" ]; then
body="🚀 This PR changes was released in ${released_packages}"
fi
gh pr comment "${{ github.event.pull_request.number }}" --body
fi
9 changes: 7 additions & 2 deletions packages/dx/bin/release-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

release_packages() {
changed_paths=$1;
is_preview=$2;

if [ "$changed_paths" = "" ];then
echo <<<______HERE__
Expand All @@ -28,8 +29,12 @@ ______HERE__;
pnpm_options="${pnpm_options} --filter ./${path}"
done

echo "running: pnpm run -r $pnpm_options release" >> $GITHUB_STEP_SUMMARY
pnpm run -r $pnpm_options release
release_options=""
if [ "$is_preview" = "true" ]; then
relase_options=" -d"
fi
echo "running: pnpm run -r $pnpm_options release $release_options" >> $GITHUB_STEP_SUMMARY
pnpm run -r $pnpm_options release $release_options
}

extract_package_versions() {
Expand Down

0 comments on commit b638ab1

Please sign in to comment.