Skip to content

Commit

Permalink
Add support for custom npmrc_path
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorzkrukowski committed Feb 24, 2025
1 parent 6590fbc commit 12234f8
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 40 deletions.
2 changes: 1 addition & 1 deletion git-commit/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ runs:
using: "composite"
steps:
- name: Setup GIT
uses: raycast/github-actions/setup-git@v1.16.0
uses: raycast/github-actions/setup-git@v1.17.0
- name: Commit
shell: bash
working-directory: ${{ inputs.repo_dir }}
Expand Down
2 changes: 1 addition & 1 deletion git-post-store-urls-to-pr/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ runs:
using: "composite"
steps:
- name: Setup GIT
uses: raycast/github-actions/setup-git@v1.16.0
uses: raycast/github-actions/setup-git@v1.17.0
- name: Check message
id: check_message
shell: bash
Expand Down
11 changes: 7 additions & 4 deletions ray-cli/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ inputs:
access_token:
description: "Raycast Access Token"
required: false
npm_token:
description: "NPM token"
required: false
extension_schema:
description: "Extension schema"
required: false
allow_owners_only_for_extensions:
description: "Whitelist extensions allowed to have owners - each extension in new line. If not set or empty, all extensions are allowe to have it."
required: false
npmrc_path:
description: "Path to npmrc file to access private npm packages"
required: false
raycast_api_alpha_npm_token:
description: "NPM token for alpha version of @raycast/api"
required: false
outputs:
store_urls:
description: "Store URLs for published extensions"
Expand All @@ -35,4 +38,4 @@ runs:
GITHUB_WORKSPACE: $GITHUB_WORKSPACE
run: |
set -e -o noglob
${{ github.action_path }}/ray_cli.sh "${{ inputs.command }}" "${{ inputs.paths }}" "${{ inputs.access_token }}" "${{ inputs.npm_token }}" "${{ inputs.extension_schema }}" "${{ inputs.allow_owners_only_for_extensions }}"
${{ github.action_path }}/ray_cli.sh "${{ inputs.command }}" "${{ inputs.paths }}" "${{ inputs.access_token }}" "${{ inputs.extension_schema }}" "${{ inputs.allow_owners_only_for_extensions }}" "${{ inputs.npmrc_path }}" "${{ inputs.raycast_api_alpha_npm_token }}"
47 changes: 29 additions & 18 deletions ray-cli/ray_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,26 @@ if [ ! -z "$3" ]; then
fi

if [ ! -z "$4" ]; then
npm_token=$4
fi

if [ ! -z "$5" ]; then
extension_schema=$5
extension_schema=$4
else
extension_schema="https://www.raycast.com/schemas/extension.json"
fi

if [ ! -z "$6" ]; then
if [ ! -z "$5" ]; then
SAVEIFS=$IFS
IFS=$'\n'
allow_owners_only_for_extensions=($6)
allow_owners_only_for_extensions=($5)
IFS=$SAVEIFS
fi

if [ ! -z "$6" ]; then
npmrc_path=$6
fi

if [ ! -z "$7" ]; then
raycast_api_alpha_npm_token=$7
fi

function ray_command_from_string() {
case $1 in
build)
Expand Down Expand Up @@ -110,17 +114,24 @@ for dir in "${paths[@]}" ; do

### Create .npmrc if needed
cleanup_npmrc=false
api_version=$(jq '.dependencies."@raycast/api"' package.json)
if [[ "$api_version" == *"alpha"* ]]; then
if [ -z "$npm_token" ]; then
echo "::error::Private npm used without npm_token parameter"
exit_code=1
continue
else
echo "//npm.pkg.github.com/:_authToken=$npm_token" > .npmrc
echo "@raycast:registry=https://npm.pkg.github.com" >> .npmrc
echo "legacy-peer-deps=true" >> .npmrc
cleanup_npmrc=true
if [ ! -z "$npmrc_path" ]; then
echo "Using npmrc from $npmrc_path"
cp $npmrc_path .npmrc
cleanup_npmrc=true
else
api_version=$(jq '.dependencies."@raycast/api"' package.json)
if [[ "$api_version" == *"alpha"* ]]; then
if [ -z "$raycast_api_alpha_npm_token" ]; then
echo "::error::Alpha version of @raycast/api used without raycast_api_alpha_npm_token parameter"
exit_code=1
continue
else
echo "Generating .npmrc for alpha version of @raycast/api"
echo "//npm.pkg.github.com/:_authToken=$raycast_api_alpha_npm_token" > .npmrc
echo "@raycast:registry=https://npm.pkg.github.com" >> .npmrc
echo "legacy-peer-deps=true" >> .npmrc
cleanup_npmrc=true
fi
fi
fi

Expand Down
22 changes: 13 additions & 9 deletions ray/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ inputs:
cli_version:
description: "CLI Version"
required: false
npm_token:
description: "NPM token"
required: false
extension_schema:
description: "Extension schema"
required: false
allow_owners_only_for_extensions:
description: "Whitelist extensions allowed to have owners - each extension in new line. If not set or empty, all extensions are allowe to have it."
required: false
npmrc_path:
description: "Path to npmrc file to access private npm packages"
required: false
raycast_api_alpha_npm_token:
description: "NPM token for alpha version of @raycast/api"
required: false
outputs:
command:
description: "Ray CLI command executed"
Expand All @@ -42,29 +45,30 @@ runs:
with:
node-version: 20.15.1
- name: Setup CLI
uses: raycast/github-actions/setup-cli@v1.16.0
uses: raycast/github-actions/setup-cli@v1.17.0
with:
version: ${{ inputs.cli_version || '1.91.1' }}
npm_token: ${{ inputs.npm_token }}
raycast_api_alpha_npm_token: ${{ inputs.raycast_api_alpha_npm_token }}
- name: Get command
id: get_command
uses: raycast/github-actions/get-command@v1.16.0
uses: raycast/github-actions/get-command@v1.17.0
with:
custom_command: ${{ inputs.command }}
github_event_name: ${{ github.event_name }}
- name: Get changed extensions
id: get_changed_extensions
uses: raycast/github-actions/get-changed-extensions@v1.16.0
uses: raycast/github-actions/get-changed-extensions@v1.17.0
with:
custom_paths: ${{ inputs.paths }}
github_event_name: ${{ github.event_name }}
- name: Ray CLI
id: ray_cli
uses: raycast/github-actions/ray-cli@v1.16.0
uses: raycast/github-actions/ray-cli@v1.17.0
with:
paths: ${{ steps.get_changed_extensions.outputs.paths }}
command: ${{ steps.get_command.outputs.command }}
access_token: ${{ inputs.access_token }}
npm_token: ${{ inputs.npm_token }}
extension_schema: ${{ inputs.extension_schema }}
allow_owners_only_for_extensions: ${{ inputs.allow_owners_only_for_extensions }}
npmrc_path: ${{ inputs.npmrc_path }}
raycast_api_alpha_npm_token: ${{ inputs.raycast_api_alpha_npm_token }}
6 changes: 3 additions & 3 deletions setup-cli/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ inputs:
version:
description: "CLI version (format: 1.0.0)"
required: true
npm_token:
description: "NPM token"
raycast_api_alpha_npm_token:
description: "NPM token for alpha version of @raycast/api"
required: false
runs:
using: "composite"
steps:
- name: Setup CLI
shell: bash
run: |
${{ github.action_path }}/setup_cli.sh "${{ inputs.version }}" "${{ inputs.npm_token }}"
${{ github.action_path }}/setup_cli.sh "${{ inputs.version }}" "${{ inputs.raycast_api_alpha_npm_token }}"
8 changes: 4 additions & 4 deletions setup-cli/setup_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
set -e

version=$1
npm_token=$2
raycast_api_alpha_npm_token=$2

if [[ "$version" == *"alpha"* ]]; then
if [ -z "$npm_token" ]; then
echo "::error::Private api used without npm_token parameter"
if [ -z "$raycast_api_alpha_npm_token" ]; then
echo "::error::Alpha version of @raycast/api used without raycast_api_alpha_npm_token parameter"
exit 1
else
echo "//npm.pkg.github.com/:_authToken=$npm_token" > ~/.npmrc
echo "//npm.pkg.github.com/:_authToken=$raycast_api_alpha_npm_token" > ~/.npmrc
echo "@raycast:registry=https://npm.pkg.github.com" >> ~/.npmrc
echo "legacy-peer-deps=true" >> ~/.npmrc
cleanup_npmrc=true
Expand Down

0 comments on commit 12234f8

Please sign in to comment.