|
11 | 11 | jobs: |
12 | 12 | release: |
13 | 13 | runs-on: ubuntu-latest |
14 | | - if: ${{ !github.event.pull_request || github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'released') }} |
| 14 | + if: ${{ contains(github.event.pull_request.labels.*.name, 'released') }} |
15 | 15 | steps: |
16 | 16 | - name: Check out code |
17 | 17 | uses: actions/checkout@v3 |
| 18 | + with: |
| 19 | + ref: ${{ github.head_ref }} |
18 | 20 | - uses: pnpm/action-setup@v2 |
19 | 21 | with: |
20 | 22 | version: 8.4.0 |
@@ -44,16 +46,32 @@ jobs: |
44 | 46 | GH_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} |
45 | 47 | NPM_TOKEN: ${{ secrets.RELEASE_NPM_TOKEN }} |
46 | 48 | ACTIONS_STEP_DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }} |
| 49 | + PREVIEW_BRANCH: ${{ github.event.pull_request.merged != true && github.head_ref }} |
| 50 | + GITHUB_REF: ${{ github.head_ref }} |
| 51 | + # GITHUB_CONTEXT: ${{ toJson(github) }} |
47 | 52 | run: | |
48 | 53 | if [[ "${TRACE:-false}" == true || "${ACTIONS_STEP_DEBUG:-false}" == true ]]; then |
49 | 54 | set -o xtrace # Trace the execution of the script (debug) |
50 | 55 | fi |
| 56 | + unset GITHUB_ACTIONS |
51 | 57 | . ./packages/dx/bin/release-packages.sh |
52 | 58 |
|
53 | 59 | changed_paths="$(gh pr view --json files --jq '.files.[].path' "${{ github.event.pull_request.number }}" | cut -d / -f 1,2 | uniq)"; |
54 | | - release_packages "$changed_paths" |
55 | | - released_packages=$(extract_package_versions "$changed_paths"); |
| 60 | + release_notes=$(release_packages "$changed_paths" "$PREVIEW_BRANCH") |
| 61 | + echo "$release_notes" |
56 | 62 |
|
57 | | - if [[ "${{github.event.pull_request.number}}" != "" && "$released_packages" != "" ]]; then |
58 | | - gh pr comment "${{ github.event.pull_request.number }}" --body "🚀 Released in ${released_packages}" |
| 63 | + if [ "${{github.event.pull_request.number}}" != "" ]; then |
| 64 | + if [ "$PREVIEW_BRANCH" = "" ]; then |
| 65 | + released_packages=$(extract_package_versions "$changed_paths"); |
| 66 | + if [ "$released_packages" != "" ]; then |
| 67 | + gh pr comment "${{ github.event.pull_request.number }}" --body "🚀 This PR changes was released in ${released_packages}" |
| 68 | + else |
| 69 | + gh pr comment "${{ github.event.pull_request.number }}" --body "No packages to release" |
| 70 | + fi |
| 71 | + else |
| 72 | + echo -e "# Release notes for packages that will be published after merge\n\n" > release_notes.txt |
| 73 | + echo "$release_notes" | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' | sed '/^##/,$!d' >> release_notes.txt |
| 74 | + gh pr comment "${{ github.event.pull_request.number }}" --body-file ./release_notes.txt |
| 75 | + rm -f release_notes.txt |
| 76 | + fi |
59 | 77 | fi |
0 commit comments