Skip to content

Commit

Permalink
👷 Add github packages possibility
Browse files Browse the repository at this point in the history
  • Loading branch information
tidurand committed Jul 22, 2024
1 parent 7c951ab commit 89c6b8f
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}

Expand Down Expand Up @@ -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 }}

0 comments on commit 89c6b8f

Please sign in to comment.