From 89c6b8f54911598fa8f1294a0079ac086b0b586e Mon Sep 17 00:00:00 2001 From: Tiphaine Date: Mon, 22 Jul 2024 07:58:58 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Add=20github=20packages=20possib?= =?UTF-8?q?ility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f00753a..b01f71e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,16 @@ name: Release on: - push: - branches: - - master - - main + workflow_dispatch: + inputs: + target: + description: 'Select the target registry (npm or github)' + required: true + default: 'npm' + type: choice + options: + - npm + - github concurrency: ${{ github.workflow }}-${{ github.ref }} @@ -41,25 +47,32 @@ jobs: echo "GITHUB_TOKEN is not set" exit 1 fi - if [ -z "${{ secrets.NPM_TOKEN }}" ]; then + if [ "${{ github.event.inputs.target }}" == "npm" ] && [ -z "${{ secrets.NPM_TOKEN }}" ]; then echo "NPM_TOKEN is not set" exit 1 fi - name: Create .npmrc run: | - cat << EOF > "$HOME/.npmrc" - //registry.npmjs.org/:_authToken=$NPM_TOKEN - EOF + if [ "${{ github.event.inputs.target }}" == "npm" ]; then + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > "$HOME/.npmrc" + else + echo "//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN" > "$HOME/.npmrc" + fi env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create Release Pull Request and Publish to npm + - name: Create Release Pull Request and Publish id: changesets-production uses: changesets/action@v1 with: - publish: pnpm release + publish: | + if [ "${{ github.event.inputs.target }}" == "npm" ]; then + pnpm release + else + pnpm release --registry=https://npm.pkg.github.com/ + fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}