|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - v** |
| 7 | + |
| 8 | +jobs: |
| 9 | + check-lint: |
| 10 | + name: "Check / Lint" |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + - name: Run linting |
| 15 | + run: | |
| 16 | + npm install |
| 17 | + npm run lint |
| 18 | + npm run lint-shell |
| 19 | +
|
| 20 | + check-build: |
| 21 | + name: "Check / Build" |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + - name: Run build |
| 26 | + run: | |
| 27 | + npm install |
| 28 | + npm run build --verbose |
| 29 | +
|
| 30 | + check-matrix: |
| 31 | + name: "Check / Matrix" |
| 32 | + runs-on: ubuntu-latest |
| 33 | + outputs: |
| 34 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v4 |
| 37 | + - id: set-matrix |
| 38 | + run: | |
| 39 | + files=$(find tests/* -maxdepth 0 -type d | sed 's/.*/"&"/' | paste -sd, -) |
| 40 | + files=$files,$(find tests/* -maxdepth 0 -type f | grep -e "/*.test.ts" | sed 's/.*/"&"/' | paste -sd, -) |
| 41 | + if [ -z "$files" ]; then |
| 42 | + echo "matrix={\"shard\":[]}" >> $GITHUB_OUTPUT |
| 43 | + else |
| 44 | + echo "matrix={\"shard\":[$files]}" >> $GITHUB_OUTPUT |
| 45 | + fi |
| 46 | +
|
| 47 | + check-test: |
| 48 | + name: "Check / Test" |
| 49 | + runs-on: ubuntu-latest |
| 50 | + strategy: |
| 51 | + fail-fast: false |
| 52 | + matrix: ${{fromJson(needs.check-matrix.outputs.matrix)}} |
| 53 | + needs: check-matrix |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v4 |
| 56 | + - name: Set artifact name |
| 57 | + run: echo "SLUG=$(echo ${{ matrix.shard }} | sed 's/[/.]/-/g')" >> $GITHUB_ENV |
| 58 | + - name: Run tests |
| 59 | + run: | |
| 60 | + npm install |
| 61 | + npm run test -- \ |
| 62 | + --coverageReporters json \ |
| 63 | + --coverage \ |
| 64 | + "${{ matrix.shard }}" |
| 65 | + mv tmp/coverage/coverage-final.json "tmp/coverage/${{ env.SLUG }}.json" |
| 66 | + - uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: coverage-artifacts-${{ env.SLUG }} |
| 69 | + path: tmp/coverage/ |
| 70 | + |
| 71 | + check-coverage: |
| 72 | + name: "Check / Coverage" |
| 73 | + runs-on: ubuntu-latest |
| 74 | + needs: check-test |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v4 |
| 77 | + - uses: actions/download-artifact@v4 |
| 78 | + with: |
| 79 | + pattern: coverage-artifacts-* |
| 80 | + path: tmp/coverage/ |
| 81 | + merge-multiple: true |
| 82 | + - run: rm .npmrc |
| 83 | + - name: Merge coverage results |
| 84 | + run: npx nyc merge tmp/coverage/ tmp/coverage/cobertura-coverage.json |
| 85 | + - uses: actions/upload-artifact@v4 |
| 86 | + with: |
| 87 | + name: cobertura-coverage |
| 88 | + path: tmp/coverage/cobertura-coverage.json |
| 89 | + |
| 90 | + build-prerelease: |
| 91 | + name: "Build / Pre-release" |
| 92 | + runs-on: ubuntu-latest |
| 93 | + concurrency: |
| 94 | + group: build-prerelease |
| 95 | + cancel-in-progress: false |
| 96 | + needs: |
| 97 | + - check-lint |
| 98 | + - check-build |
| 99 | + - check-test |
| 100 | + if: > |
| 101 | + startsWith(github.ref, 'refs/tags/v') && |
| 102 | + contains(github.ref, '-') |
| 103 | + steps: |
| 104 | + - uses: actions/checkout@v4 |
| 105 | + - name: Run deployment |
| 106 | + run: | |
| 107 | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc |
| 108 | + echo 'Publishing library prerelease' |
| 109 | + npm install |
| 110 | + npm publish --tag prerelease --access public |
| 111 | + rm -f ./.npmrc |
| 112 | +
|
| 113 | + release-distribution: |
| 114 | + name: "Release / Distribution" |
| 115 | + runs-on: ubuntu-latest |
| 116 | + concurrency: |
| 117 | + group: release-distribution |
| 118 | + cancel-in-progress: false |
| 119 | + needs: |
| 120 | + - check-lint |
| 121 | + - check-build |
| 122 | + - check-test |
| 123 | + if: > |
| 124 | + startsWith(github.ref, 'refs/tags/v') && |
| 125 | + !contains(github.ref, '-') |
| 126 | + steps: |
| 127 | + - uses: actions/checkout@v4 |
| 128 | + - name: Publish release |
| 129 | + run: | |
| 130 | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc |
| 131 | + echo 'Publishing library' |
| 132 | + npm install |
| 133 | + npm publish --access public |
| 134 | + rm -f ./.npmrc |
| 135 | +
|
| 136 | +
|
0 commit comments