diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 95e77ff0a..8f33afabc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -44,16 +46,32 @@ 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_REF: ${{ 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 + unset GITHUB_ACTIONS . ./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" - released_packages=$(extract_package_versions "$changed_paths"); + release_notes=$(release_packages "$changed_paths" "$PREVIEW_BRANCH") + echo "$release_notes" - if [[ "${{github.event.pull_request.number}}" != "" && "$released_packages" != "" ]]; then - gh pr comment "${{ github.event.pull_request.number }}" --body "🚀 Released in ${released_packages}" + if [ "${{github.event.pull_request.number}}" != "" ]; then + if [ "$PREVIEW_BRANCH" = "" ]; then + released_packages=$(extract_package_versions "$changed_paths"); + if [ "$released_packages" != "" ]; then + gh pr comment "${{ github.event.pull_request.number }}" --body "🚀 This PR changes was released in ${released_packages}" + else + gh pr comment "${{ github.event.pull_request.number }}" --body "No packages to release" + fi + else + echo -e "# Release notes for packages that will be published after merge\n\n" > release_notes.txt + echo "$release_notes" | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' | sed '/^##/,$!d' >> release_notes.txt + gh pr comment "${{ github.event.pull_request.number }}" --body-file ./release_notes.txt + rm -f release_notes.txt + fi fi diff --git a/packages/casl-mongoose/CHANGELOG.md b/packages/casl-mongoose/CHANGELOG.md index 30baf20de..ad3e264d5 100644 --- a/packages/casl-mongoose/CHANGELOG.md +++ b/packages/casl-mongoose/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. -## [7.3.1](https://github.com/stalniy/casl/compare/@casl/mongoose@7.3.0...@casl/mongoose@7.3.1) (2024-03-27) +## [8.0.1](https://github.com/stalniy/casl/compare/@casl/mongoose@8.0.0...@casl/mongoose@8.0.1) (2024-03-27) ### Bug Fixes @@ -19,7 +19,7 @@ All notable changes to this project will be documented in this file. ### Features -* adds accessibleBy and accessibleFieldsBy to casl-mongoose ([#880](https://github.com/stalniy/casl/issues/880)) ([42745d6](https://github.com/stalniy/casl/commit/42745d65fc6a4c1752ded2599ab37246292b1c84)) +* adds `accessibleBy` and `accessibleFieldsBy` to casl-mongoose ([#880](https://github.com/stalniy/casl/issues/880)) ([42745d6](https://github.com/stalniy/casl/commit/42745d65fc6a4c1752ded2599ab37246292b1c84)) ## [7.2.2](https://github.com/stalniy/casl/compare/@casl/mongoose@7.2.1...@casl/mongoose@7.2.2) (2024-01-31) diff --git a/packages/casl-mongoose/package.json b/packages/casl-mongoose/package.json index 5ba632546..dc6801ac7 100644 --- a/packages/casl-mongoose/package.json +++ b/packages/casl-mongoose/package.json @@ -1,6 +1,6 @@ { "name": "@casl/mongoose", - "version": "7.3.1", + "version": "8.0.1", "description": "Allows to query accessible records from MongoDB based on CASL rules", "main": "dist/es6c/index.js", "es2015": "dist/es6m/index.mjs", @@ -40,7 +40,7 @@ "author": "Sergii Stotskyi ", "license": "MIT", "peerDependencies": { - "@casl/ability": "^6.3.2", + "@casl/ability": "^6.7.0", "mongoose": "^6.0.13 || ^7.0.0 || ^8.0.0" }, "devDependencies": { diff --git a/packages/dx/bin/release-packages.sh b/packages/dx/bin/release-packages.sh index 93f4ce653..e8f5d303a 100755 --- a/packages/dx/bin/release-packages.sh +++ b/packages/dx/bin/release-packages.sh @@ -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 ' @@ -28,8 +31,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 [ "$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 + pnpm run -r $pnpm_options release $release_options } extract_package_versions() {