Skip to content

Commit b202fb0

Browse files
authored
Merge pull request #198 from IQSS/196-github-action-fix
deploy_alpha.yml fix
2 parents b994225 + 4267138 commit b202fb0

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

.github/workflows/deploy_alpha.yml

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ jobs:
5353
runs-on: ubuntu-latest
5454
permissions:
5555
packages: write
56-
contents: write
5756
steps:
5857
- uses: actions/checkout@v3
5958
- uses: actions/setup-node@v3
@@ -69,32 +68,26 @@ jobs:
6968

7069
- name: Update package version
7170
env:
72-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7372
run: |
74-
# Fetch or initialize the version counter
75-
if [ ! -f .alpha_version ]; then
76-
echo "1" > .alpha_version
77-
fi
78-
INCREMENTAL_NUMBER=$(cat .alpha_version)
73+
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
7974
80-
# Increment version number
81-
NEW_INCREMENTAL_NUMBER=$((INCREMENTAL_NUMBER+1))
75+
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)
8276
83-
# Save the new incremental number to the file
84-
echo "${NEW_INCREMENTAL_NUMBER}" > .alpha_version
77+
if [ -z "$LATEST_VERSION" ]; then
78+
NEW_INCREMENTAL_NUMBER=1
79+
else
80+
CURRENT_INCREMENTAL_NUMBER=$(echo $LATEST_VERSION | sed 's/2.0.0-alpha.//')
81+
NEW_INCREMENTAL_NUMBER=$((CURRENT_INCREMENTAL_NUMBER + 1))
82+
fi
8583
86-
# Update package version with 2.0.0-alpha.<incremental_number>
87-
NEW_VERSION="2.0.0-alpha.${INCREMENTAL_NUMBER}"
88-
npm version "${NEW_VERSION}" --no-git-tag-version
84+
NEW_VERSION="2.0.0-alpha.${NEW_INCREMENTAL_NUMBER}"
8985
90-
# Commit the version update and incremental number
91-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
92-
git config --global user.name "GitHub Actions"
93-
git add package.json .alpha_version
94-
git commit -m "Update version to ${NEW_VERSION}"
86+
echo "Latest version: $LATEST_VERSION"
87+
echo "New version: $NEW_VERSION"
9588
96-
# Push the changes to the repository
97-
git push origin "${{ github.ref_name }}"
89+
echo "Setting package version to: ${NEW_VERSION}"
90+
npm version "${NEW_VERSION}" --no-git-tag-version
9891
9992
- name: Publish package
10093
run: |

0 commit comments

Comments
 (0)