Skip to content

Commit c7f3d09

Browse files
authored
fix(deps): fixes @casl/ability peer dep for @casl/mongoose (#925)
1 parent cd572cd commit c7f3d09

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

.github/workflows/release.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ on:
1111
jobs:
1212
release:
1313
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') }}
1515
steps:
1616
- name: Check out code
1717
uses: actions/checkout@v3
18+
with:
19+
ref: ${{ github.head_ref }}
1820
- uses: pnpm/action-setup@v2
1921
with:
2022
version: 8.4.0
@@ -44,16 +46,32 @@ jobs:
4446
GH_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
4547
NPM_TOKEN: ${{ secrets.RELEASE_NPM_TOKEN }}
4648
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) }}
4752
run: |
4853
if [[ "${TRACE:-false}" == true || "${ACTIONS_STEP_DEBUG:-false}" == true ]]; then
4954
set -o xtrace # Trace the execution of the script (debug)
5055
fi
56+
unset GITHUB_ACTIONS
5157
. ./packages/dx/bin/release-packages.sh
5258
5359
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"
5662
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
5977
fi

packages/casl-mongoose/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [7.3.1](https://github.com/stalniy/casl/compare/@casl/mongoose@7.3.0...@casl/mongoose@7.3.1) (2024-03-27)
5+
## [8.0.1](https://github.com/stalniy/casl/compare/@casl/mongoose@8.0.0...@casl/mongoose@8.0.1) (2024-03-27)
66

77

88
### Bug Fixes
@@ -19,7 +19,7 @@ All notable changes to this project will be documented in this file.
1919

2020
### Features
2121

22-
* adds accessibleBy and accessibleFieldsBy to casl-mongoose ([#880](https://github.com/stalniy/casl/issues/880)) ([42745d6](https://github.com/stalniy/casl/commit/42745d65fc6a4c1752ded2599ab37246292b1c84))
22+
* adds `accessibleBy` and `accessibleFieldsBy` to casl-mongoose ([#880](https://github.com/stalniy/casl/issues/880)) ([42745d6](https://github.com/stalniy/casl/commit/42745d65fc6a4c1752ded2599ab37246292b1c84))
2323

2424
## [7.2.2](https://github.com/stalniy/casl/compare/@casl/[email protected]...@casl/[email protected]) (2024-01-31)
2525

packages/casl-mongoose/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@casl/mongoose",
3-
"version": "7.3.1",
3+
"version": "8.0.1",
44
"description": "Allows to query accessible records from MongoDB based on CASL rules",
55
"main": "dist/es6c/index.js",
66
"es2015": "dist/es6m/index.mjs",
@@ -40,7 +40,7 @@
4040
"author": "Sergii Stotskyi <[email protected]>",
4141
"license": "MIT",
4242
"peerDependencies": {
43-
"@casl/ability": "^6.3.2",
43+
"@casl/ability": "^6.7.0",
4444
"mongoose": "^6.0.13 || ^7.0.0 || ^8.0.0"
4545
},
4646
"devDependencies": {

packages/dx/bin/release-packages.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
release_packages() {
44
changed_paths=$1;
5+
preview_branch=$2;
6+
7+
echo "Releasing packages with the next args (branch: ${preview_branch:-master}): $changed_paths"
58

69
if [ "$changed_paths" = "" ];then
7-
echo <<<______HERE__
10+
echo <<<______HERE__
811
Usage:
912
release-packages "packages/casl-ability"
1013
release-packages '
@@ -28,8 +31,12 @@ ______HERE__;
2831
pnpm_options="${pnpm_options} --filter ./${path}"
2932
done
3033

31-
echo "running: pnpm run -r $pnpm_options release" >> $GITHUB_STEP_SUMMARY
32-
pnpm run -r $pnpm_options release
34+
release_options=""
35+
if [ "$preview_branch" != "" ]; then
36+
release_options=" --dry-run --no-ci --branches master,$preview_branch"
37+
fi
38+
echo "running: pnpm run -r $pnpm_options release $release_options" >> $GITHUB_STEP_SUMMARY
39+
pnpm run -r $pnpm_options release $release_options
3340
}
3441

3542
extract_package_versions() {

0 commit comments

Comments
 (0)