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
@@ -67,35 +66,26 @@ jobs:
6766 - name : Build package
6867 run : npm run build
6968
70- - name : Update package version
71- env :
72- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
69+ - name : Fetch latest alpha version
7370 run : |
74- # Fetch or initialize the version counter
75- if [ ! -f .alpha_version ]; then
76- echo "1" > .alpha_version
71+ LATEST_VERSION=$(npm show @IQSS/dataverse-client-javascript versions --json | jq -r '.[]' | grep "^2.0.0-alpha." | sort -V | tail -n 1)
72+
73+ if [ -z "$LATEST_VERSION" ]; then
74+ NEW_INCREMENTAL_NUMBER=1
75+ else
76+ CURRENT_INCREMENTAL_NUMBER=$(echo $LATEST_VERSION | sed 's/2.0.0-alpha.//')
77+ NEW_INCREMENTAL_NUMBER=$((CURRENT_INCREMENTAL_NUMBER + 1))
7778 fi
78- INCREMENTAL_NUMBER=$(cat .alpha_version)
7979
80- # Increment version number
81- NEW_INCREMENTAL_NUMBER=$((INCREMENTAL_NUMBER+1))
80+ NEW_VERSION="2.0.0-alpha.${NEW_INCREMENTAL_NUMBER}"
8281
83- # Save the new incremental number to the file
84- echo "${NEW_INCREMENTAL_NUMBER}" > .alpha_version
82+ echo "Latest version: $LATEST_VERSION"
83+ echo "New version: $NEW_VERSION"
8584
86- # Update package version with 2.0.0-alpha.<incremental_number>
87- NEW_VERSION="2.0.0-alpha.${INCREMENTAL_NUMBER}"
85+ - name : Update package version
86+ run : |
8887 npm version "${NEW_VERSION}" --no-git-tag-version
8988
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}"
95-
96- # Push the changes to the repository
97- git push origin "${{ github.ref_name }}"
98-
9989 - name : Publish package
10090 run : |
10191 echo "$(jq '.publishConfig.registry = "https://npm.pkg.github.com"' package.json)" > package.json
0 commit comments