feat(react): add @monocloud/auth-react SDK (provider, hooks, components, docs, CI) #84
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - ".changeset/**" | |
| issue_comment: | |
| types: [created] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event_name == 'issue_comment' && format('issue-{0}-{1}', github.event.issue.number, github.actor) || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| release: | |
| name: Release | |
| if: github.event_name == 'push' && github.repository == 'monocloud/auth-js' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.BOT_TOKEN }} | |
| - name: Install PNPM | |
| uses: pnpm/action-setup@v6 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: pnpm | |
| - name: Install Dependencies | |
| run: pnpm install | |
| - name: Release build | |
| run: pnpm build | |
| - name: Create Release PR | |
| uses: changesets/action@v1 | |
| with: | |
| commit: "Version Packages" | |
| title: "Version Packages" | |
| version: pnpm changeset:version | |
| publish: pnpm changeset:publish | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} | |
| NPM_CONFIG_PROVENANCE: true | |
| snapshot: | |
| if: github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '!snapshot') && github.repository == 'monocloud/auth-js' | |
| name: Create Snapshot Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| issues: write | |
| pull-requests: write | |
| steps: | |
| - name: Limit to users with write access | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| try { | |
| const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| username: context.actor, | |
| }); | |
| if (!['admin', 'write', 'maintain'].includes(data.permission)) { | |
| core.setFailed(`@${context.actor} lacks write access to this repository`); | |
| } | |
| } catch (e) { | |
| core.setFailed(`@${context.actor} lacks write access to this repository`); | |
| } | |
| - name: Get PR Info | |
| uses: actions/github-script@v8 | |
| id: pr_info | |
| with: | |
| script: | | |
| const { data: pr } = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number, | |
| }); | |
| core.setOutput('head_ref', pr.head.ref); | |
| - name: Checkout Repo | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ steps.pr_info.outputs.head_ref }} | |
| fetch-depth: 0 | |
| - name: Install PNPM | |
| uses: pnpm/action-setup@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: pnpm | |
| - name: Install Dependencies | |
| run: pnpm install | |
| - name: Build Packages | |
| run: pnpm build | |
| - name: Force Patch Snapshot Changeset | |
| run: | | |
| echo "Clearing existing changesets to force patch snapshot..." | |
| find .changeset -name "*.md" ! -name "README.md" -delete | |
| echo "Creating temporary patch changeset." | |
| cat <<EOF > .changeset/temp-snapshot.md | |
| --- | |
| '@monocloud/auth-core': patch | |
| '@monocloud/auth-node-core': patch | |
| '@monocloud/auth-web-js': patch | |
| '@monocloud/auth-nextjs': patch | |
| '@monocloud/backend-node': patch | |
| --- | |
| Snapshot release. | |
| EOF | |
| - name: Create Snapshot Version | |
| run: pnpm changeset version --snapshot canary | |
| - name: Publish NPM Packages as Canary | |
| run: pnpm changeset publish --tag canary --no-git-tag | |
| env: | |
| NPM_CONFIG_PROVENANCE: true | |
| - name: Comment on PR with version | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const packagesDir = path.join(path.resolve(path.dirname('')), 'packages'); | |
| const IGNORED_DIRS = new Set(['test-utils']); | |
| const packageDirs = fs.readdirSync(packagesDir).filter(item => { | |
| if (IGNORED_DIRS.has(item)) { | |
| return false; | |
| } | |
| const fullPath = path.join(packagesDir, item); | |
| return fs.statSync(fullPath).isDirectory(); | |
| }); | |
| const packages = packageDirs | |
| .map(dir => { | |
| const packageJsonPath = path.join(packagesDir, dir, 'package.json'); | |
| try { | |
| const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); | |
| if (packageJson.private) { | |
| return null; | |
| } | |
| return { | |
| name: packageJson.name || dir, | |
| version: packageJson.version || 'unknown', | |
| }; | |
| } catch (err) { | |
| return null; | |
| } | |
| }) | |
| .filter(pkg => pkg !== null); | |
| let markdown = '# SDK Information\n\n'; | |
| markdown += '## Snapshot Versions\n\n'; | |
| markdown += '| SDK | Version |\n'; | |
| markdown += '|-----|--------|\n'; | |
| packages.forEach(pkg => { | |
| markdown += `| ${pkg.name} | ${pkg.version} |\n`; | |
| }); | |
| markdown += '\n## NPM Installation \n\n'; | |
| packages.forEach(pkg => { | |
| markdown += `### ${pkg.name}\n\n`; | |
| markdown += `\`\`\`\nnpm i ${pkg.name}@${pkg.version}\n\`\`\`\n\n`; | |
| }); | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: `Snapshot published! \n\n${markdown}` | |
| }) |