Skip to content

Commit

Permalink
add wf script to ./scripts, update wf
Browse files Browse the repository at this point in the history
  • Loading branch information
dskvr committed Jan 22, 2024
1 parent d5d51e4 commit 41de524
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
16 changes: 1 addition & 15 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,7 @@ jobs:
- name: Find Package
id: find_package
run: |
# Get the raw JSON output from 'yarn workspaces info --json'
WORKSPACES_JSON=$(yarn workspaces info --json)
# Extract only the JSON part using grep and sed
CLEANED_JSON=$(echo "$WORKSPACES_JSON" | grep -v 'yarn workspaces v' | grep -v 'Done in' | sed -n '/^{/,/^}/p')
# Process the JSON with jq to extract the package path
PKG_PATH=$(echo "$CLEANED_JSON" | jq -r '.["@nostrwatch/'"${{ matrix.package }}"'"].location')
# Check if the location is not null (valid JSON)
if [[ ! -z "$PKG_PATH" && "$PKG_PATH" != "null" ]]; then
echo "PKG_PATH: $PKG_PATH"
else
echo "Error: Unable to extract valid JSON data."
fi
PKG_PATH=$(./scripts/wf/get-path-package.sh "${{ matrix.package }}")
echo "the_path=$PKG_PATH" >> "$GITHUB_OUTPUT"
- name: Install Package
Expand Down
15 changes: 15 additions & 0 deletions scripts/wf/get-path-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
PKG_NAME=$1

# Get the raw JSON output from 'yarn workspaces info --json'
WORKSPACES_JSON=$(yarn workspaces info --json)

# Extract only the JSON part using grep and sed
CLEANED_JSON=$(echo "$WORKSPACES_JSON" | grep -v 'yarn workspaces v' | grep -v 'Done in' | sed -n '/^{/,/^}/p')

# Process the JSON with jq to extract the package path
PKG_PATH=$(echo "$CLEANED_JSON" | jq -r '.["@nostrwatch/'"$PKG_NAME"'"].location')

echo $PKG_PATH

# echo "the_path=$PKG_PATH" >> "$GITHUB_OUTPUT"

0 comments on commit 41de524

Please sign in to comment.