Skip to content

Commit

Permalink
Merge pull request #198 from IQSS/196-github-action-fix
Browse files Browse the repository at this point in the history
deploy_alpha.yml fix
  • Loading branch information
GPortas authored Oct 3, 2024
2 parents b994225 + 4267138 commit b202fb0
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions .github/workflows/deploy_alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ jobs:
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -69,32 +68,26 @@ jobs:

- name: Update package version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Fetch or initialize the version counter
if [ ! -f .alpha_version ]; then
echo "1" > .alpha_version
fi
INCREMENTAL_NUMBER=$(cat .alpha_version)
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
# Increment version number
NEW_INCREMENTAL_NUMBER=$((INCREMENTAL_NUMBER+1))
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)
# Save the new incremental number to the file
echo "${NEW_INCREMENTAL_NUMBER}" > .alpha_version
if [ -z "$LATEST_VERSION" ]; then
NEW_INCREMENTAL_NUMBER=1
else
CURRENT_INCREMENTAL_NUMBER=$(echo $LATEST_VERSION | sed 's/2.0.0-alpha.//')
NEW_INCREMENTAL_NUMBER=$((CURRENT_INCREMENTAL_NUMBER + 1))
fi
# Update package version with 2.0.0-alpha.<incremental_number>
NEW_VERSION="2.0.0-alpha.${INCREMENTAL_NUMBER}"
npm version "${NEW_VERSION}" --no-git-tag-version
NEW_VERSION="2.0.0-alpha.${NEW_INCREMENTAL_NUMBER}"
# Commit the version update and incremental number
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
git add package.json .alpha_version
git commit -m "Update version to ${NEW_VERSION}"
echo "Latest version: $LATEST_VERSION"
echo "New version: $NEW_VERSION"
# Push the changes to the repository
git push origin "${{ github.ref_name }}"
echo "Setting package version to: ${NEW_VERSION}"
npm version "${NEW_VERSION}" --no-git-tag-version
- name: Publish package
run: |
Expand Down

0 comments on commit b202fb0

Please sign in to comment.