Support publish dataset with update current version #375
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: deploy_pr | |
on: pull_request | |
jobs: | |
test-unit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 19 | |
- name: Install npm dependencies | |
run: npm ci | |
- name: Run unit tests | |
run: npm run test:unit | |
test-integration: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 19 | |
- name: Install npm dependencies | |
run: npm ci | |
- name: Run integration tests | |
run: npm run test:integration | |
test-functional: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 19 | |
- name: Install npm dependencies | |
run: npm ci | |
- name: Run functional tests | |
run: npm run test:functional | |
publish-gpr: | |
needs: [test-unit, test-integration, test-functional] | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 19 | |
registry-url: https://npm.pkg.github.com/ | |
- name: Install npm dependencies | |
run: npm ci | |
- name: Build package | |
run: npm run build | |
- name: Update package version | |
run: | | |
SHORT_SHA=$(git rev-parse --short "${{ github.event.pull_request.head.sha }}") | |
CURRENT_PACKAGE_VERSION=$(cat package.json | jq -r '.version') | |
npm version "${CURRENT_PACKAGE_VERSION}-pr${{ github.event.number }}.${SHORT_SHA}" --no-git-tag-version | |
- 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 | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |