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 9f52aa1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ 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
with:
ref: ${{ github.head_ref }}
- uses: pnpm/action-setup@v2
with:
version: 8.4.0
Expand Down Expand Up @@ -44,16 +46,24 @@ jobs:
GH_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.RELEASE_NPM_TOKEN }}
ACTIONS_STEP_DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }}
PREVIEW_BRANCH: ${{ github.event.pull_request.merged != true && github.head_ref }}
GITHUB_CONTEXT: ${{ toJson(github) }}
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
echo $GITHUB_CONTEXT
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" "$PREVIEW_BRANCH"
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 [ "$PREVIEW_BRANCH" = "" ]; then
body="🚀 This PR changes was released in ${released_packages}"
fi
gh pr comment "${{ github.event.pull_request.number }}" --body "$body"
fi
14 changes: 11 additions & 3 deletions packages/dx/bin/release-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

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

echo "Releasing packages with the next args (branch: ${preview_branch:-master}): $changed_paths"

if [ "$changed_paths" = "" ];then
echo <<<______HERE__
echo <<<______HERE__
Usage:
release-packages "packages/casl-ability"
release-packages '
Expand All @@ -28,8 +31,13 @@ ______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 [ "$preview_branch" != "" ]; then
release_options=" --dry-run --no-ci --branches master,$preview_branch"
fi
echo "running: pnpm run -r $pnpm_options release $release_options" >> $GITHUB_STEP_SUMMARY
unset GITHUB_ACTIONS
pnpm run -r $pnpm_options release $release_options
}

extract_package_versions() {
Expand Down

0 comments on commit 9f52aa1

Please sign in to comment.