Skip to content

Commit

Permalink
fix(deps): fixes @casl/ability peer dep for @casl/mongoose (#925)
Browse files Browse the repository at this point in the history
  • Loading branch information
stalniy authored Jun 16, 2024
1 parent cd572cd commit c7f3d09
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
28 changes: 23 additions & 5 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,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
4 changes: 2 additions & 2 deletions packages/casl-mongoose/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/[email protected]...@casl/[email protected]) (2024-01-31)

Expand Down
4 changes: 2 additions & 2 deletions packages/casl-mongoose/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -40,7 +40,7 @@
"author": "Sergii Stotskyi <[email protected]>",
"license": "MIT",
"peerDependencies": {
"@casl/ability": "^6.3.2",
"@casl/ability": "^6.7.0",
"mongoose": "^6.0.13 || ^7.0.0 || ^8.0.0"
},
"devDependencies": {
Expand Down
13 changes: 10 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,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() {
Expand Down

0 comments on commit c7f3d09

Please sign in to comment.