Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/deploy_alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,19 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
CURRENT_PACKAGE_VERSION=$(jq -r '.version' package.json)
BASE_VERSION=${CURRENT_PACKAGE_VERSION%%-alpha.*}

LATEST_VERSION=$(npm show @IQSS/dataverse-client-javascript versions --registry=https://npm.pkg.github.com/ --json | jq -r '.[]' | grep "^2.0.0-alpha." | sort -V | tail -n 1)
LATEST_VERSION=$(npm show @iqss/dataverse-client-javascript versions --registry=https://npm.pkg.github.com/ --json | jq -r '.[]' | grep "^${BASE_VERSION}-alpha\\." | sort -V | tail -n 1)
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm show ... versions --json can return either an array or a single string when only one version exists. Using jq -r '.[]' will error on the string case and fail the workflow. Make the jq filter handle both array and string outputs so first-time/low-version packages don’t break alpha publishing.

Suggested change
LATEST_VERSION=$(npm show @iqss/dataverse-client-javascript versions --registry=https://npm.pkg.github.com/ --json | jq -r '.[]' | grep "^${BASE_VERSION}-alpha\\." | sort -V | tail -n 1)
LATEST_VERSION=$(npm show @iqss/dataverse-client-javascript versions --registry=https://npm.pkg.github.com/ --json | jq -r 'if type=="array" then .[] else . end' | grep "^${BASE_VERSION}-alpha\\." | sort -V | tail -n 1)

Copilot uses AI. Check for mistakes.

if [ -z "$LATEST_VERSION" ]; then
NEW_INCREMENTAL_NUMBER=1
else
CURRENT_INCREMENTAL_NUMBER=$(echo $LATEST_VERSION | sed 's/2.0.0-alpha.//')
CURRENT_INCREMENTAL_NUMBER=$(echo "$LATEST_VERSION" | sed "s/^${BASE_VERSION}-alpha\\.//")
NEW_INCREMENTAL_NUMBER=$((CURRENT_INCREMENTAL_NUMBER + 1))
Comment on lines +75 to 83
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BASE_VERSION is interpolated into grep/sed regexes, but it contains dots (e.g. 2.1.0) which are regex metacharacters. This can cause incorrect matches/extractions. Escape BASE_VERSION for regex use (or use fixed-string matching) before using it in the grep and sed patterns.

Copilot uses AI. Check for mistakes.
fi

NEW_VERSION="2.0.0-alpha.${NEW_INCREMENTAL_NUMBER}"
NEW_VERSION="${BASE_VERSION}-alpha.${NEW_INCREMENTAL_NUMBER}"

echo "Latest version: $LATEST_VERSION"
echo "New version: $NEW_VERSION"
Expand All @@ -92,7 +94,6 @@ jobs:
- name: Publish package
run: |
echo "$(jq '.publishConfig.registry = "https://npm.pkg.github.com"' package.json)" > package.json
echo "$( jq '.name = "@IQSS/dataverse-client-javascript"' package.json )" > package.json
npm publish --@IQSS:registry=https://npm.pkg.github.com
npm publish --@iqss:registry=https://npm.pkg.github.com
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 1 addition & 2 deletions .github/workflows/deploy_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ jobs:
- name: Publish package
run: |
echo "$(jq '.publishConfig.registry = "https://npm.pkg.github.com"' package.json)" > package.json
echo "$( jq '.name = "@IQSS/dataverse-client-javascript"' package.json )" > package.json
npm publish --@IQSS:registry=https://npm.pkg.github.com
npm publish --@iqss:registry=https://npm.pkg.github.com
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"ts-node": "^10.9.2"
},
"dependencies": {
"@iqss/dataverse-client-javascript": "^2.1.0",
"@types/node": "^18.15.11",
"@types/turndown": "^5.0.1",
"axios": "^1.12.2",
Expand Down
Loading