Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy_alpha.yml fix #198

Merged
merged 8 commits into from
Oct 3, 2024
Merged
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
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
Loading