|
| 1 | +name: 'deploy_alpha' |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - develop |
| 7 | + |
| 8 | +jobs: |
| 9 | + test-unit: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v3 |
| 13 | + - uses: actions/setup-node@v3 |
| 14 | + with: |
| 15 | + node-version: 19 |
| 16 | + |
| 17 | + - name: Install npm dependencies |
| 18 | + run: npm ci |
| 19 | + |
| 20 | + - name: Run unit tests |
| 21 | + run: npm run test:unit |
| 22 | + |
| 23 | + test-integration: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v3 |
| 27 | + - uses: actions/setup-node@v3 |
| 28 | + with: |
| 29 | + node-version: 19 |
| 30 | + |
| 31 | + - name: Install npm dependencies |
| 32 | + run: npm ci |
| 33 | + |
| 34 | + - name: Run integration tests |
| 35 | + run: npm run test:integration |
| 36 | + |
| 37 | + test-functional: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v3 |
| 41 | + - uses: actions/setup-node@v3 |
| 42 | + with: |
| 43 | + node-version: 19 |
| 44 | + |
| 45 | + - name: Install npm dependencies |
| 46 | + run: npm ci |
| 47 | + |
| 48 | + - name: Run functional tests |
| 49 | + run: npm run test:functional |
| 50 | + |
| 51 | + publish-gpr: |
| 52 | + needs: [test-unit, test-integration, test-functional] |
| 53 | + runs-on: ubuntu-latest |
| 54 | + permissions: |
| 55 | + packages: write |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v3 |
| 58 | + - uses: actions/setup-node@v3 |
| 59 | + with: |
| 60 | + node-version: 19 |
| 61 | + registry-url: https://npm.pkg.github.com/ |
| 62 | + |
| 63 | + - name: Install npm dependencies |
| 64 | + run: npm ci |
| 65 | + |
| 66 | + - name: Build package |
| 67 | + run: npm run build |
| 68 | + |
| 69 | + - name: Update package version |
| 70 | + env: |
| 71 | + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + run: | |
| 73 | + echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc |
| 74 | +
|
| 75 | + 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) |
| 76 | +
|
| 77 | + if [ -z "$LATEST_VERSION" ]; then |
| 78 | + NEW_INCREMENTAL_NUMBER=1 |
| 79 | + else |
| 80 | + CURRENT_INCREMENTAL_NUMBER=$(echo $LATEST_VERSION | sed 's/2.0.0-alpha.//') |
| 81 | + NEW_INCREMENTAL_NUMBER=$((CURRENT_INCREMENTAL_NUMBER + 1)) |
| 82 | + fi |
| 83 | +
|
| 84 | + NEW_VERSION="2.0.0-alpha.${NEW_INCREMENTAL_NUMBER}" |
| 85 | +
|
| 86 | + echo "Latest version: $LATEST_VERSION" |
| 87 | + echo "New version: $NEW_VERSION" |
| 88 | +
|
| 89 | + echo "Setting package version to: ${NEW_VERSION}" |
| 90 | + npm version "${NEW_VERSION}" --no-git-tag-version |
| 91 | +
|
| 92 | + - name: Publish package |
| 93 | + run: | |
| 94 | + echo "$(jq '.publishConfig.registry = "https://npm.pkg.github.com"' package.json)" > package.json |
| 95 | + echo "$( jq '.name = "@IQSS/dataverse-client-javascript"' package.json )" > package.json |
| 96 | + npm publish --@IQSS:registry=https://npm.pkg.github.com |
| 97 | + env: |
| 98 | + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments