diff --git a/.github/workflows/deploy_pr.yml b/.github/workflows/deploy_pr.yml new file mode 100644 index 00000000..35af45c1 --- /dev/null +++ b/.github/workflows/deploy_pr.yml @@ -0,0 +1,54 @@ +name: deploy_pr + +on: + pull_request: + branches: + - develop + +jobs: + test: + 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 + + publish-gpr: + needs: test + 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 }} diff --git a/package.json b/package.json index cdd257d6..9e21ca7a 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ ], "scripts": { "build": "tsc", - "publish": "tsc && npm publish", "test": "jest -c jest.config.js", "test:unit": "jest -c jest.config.unit.js", "test:integration": "jest -c jest.config.integration.js",