From d6bc65f0d8b68e8f3889b0e99568aa1250026d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Thu, 4 May 2023 23:25:29 +0200 Subject: [PATCH] chore: support release any package as experimental --- .github/version-pr/index.js | 4 ++-- .github/workflows/release.yml | 33 +++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.github/version-pr/index.js b/.github/version-pr/index.js index 4ce04da117..66d2a8e257 100644 --- a/.github/version-pr/index.js +++ b/.github/version-pr/index.js @@ -5,12 +5,12 @@ const core = require("@actions/core") try { const packageJSONPath = path.join( process.cwd(), - "packages/next-auth/package.json" + `packages/${process.env.PACKAGE_PATH || "next-auth"}/package.json` ) const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, "utf8")) const sha8 = process.env.GITHUB_SHA.substring(0, 8) - const prNumber = process.env.PR_NUMBER + const prNumber = process.env.PR_NUMBER || "manual" const packageVersion = `0.0.0-pr.${prNumber}.${sha8}` packageJSON.version = packageVersion diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ea43448a97..4f2e454b7c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,24 @@ on: - next - 3.x pull_request: + # TODO: Support latest releases + workflow_dispatch: + inputs: + name: + type: choice + description: Package name (npm) + options: + - "@auth/nextjs" + - "@auth/core" + - "next-auth" + # TODO: Infer from package name + path: + type: choice + description: Directory name (packages/*) + options: + - "frameworks-nextjs" + - "core" + - "next-auth" jobs: test: @@ -86,7 +104,7 @@ jobs: name: Publish PR runs-on: ubuntu-latest needs: test - if: ${{ github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} environment: Preview steps: - name: Init @@ -103,22 +121,25 @@ jobs: uses: ./.github/version-pr id: determine-version env: + PACKAGE_PATH: ${{ github.event.inputs.path }} PR_NUMBER: ${{ github.event.number }} - name: Publish to npm run: | - cd packages/core + cd $PACKAGE_PATH echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc pnpm publish --no-git-checks --access public --tag experimental env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + PACKAGE_PATH: ${{ github.event.inputs.path }} - name: Comment version on PR + if: ${{ github.event_name == 'pull_request'}} uses: NejcZdovc/comment-pr@v2 with: message: - "🎉 Experimental release [published 📦️ on npm](https://npmjs.com/package/@auth/core/v/${{ env.VERSION }})!\n \ - ```sh\npnpm add @auth/core@${{ env.VERSION }}\n```\n \ - ```sh\nyarn add @auth/core@${{ env.VERSION }}\n```\n \ - ```sh\nnpm i @auth/core@${{ env.VERSION }}\n```" + "🎉 Experimental release [published 📦️ on npm](https://npmjs.com/package/${{ github.event.inputs.name }}/v/${{ env.VERSION }})!\n \ + ```sh\npnpm add ${{ github.event.inputs.name }}@${{ env.VERSION }}\n```\n \ + ```sh\nyarn add ${{ github.event.inputs.name }}@${{ env.VERSION }}\n```\n \ + ```sh\nnpm i ${{ github.event.inputs.name }}@${{ env.VERSION }}\n```" env: VERSION: ${{ steps.determine-version.outputs.version }} GITHUB_TOKEN: ${{ secrets.GH_PAT }}