|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' # Toutes les branches |
| 7 | + tags: |
| 8 | + - '*' |
| 9 | + pull_request: |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + node-version: [18, 20] |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Use Node.js ${{ matrix.node-version }} |
| 22 | + uses: actions/setup-node@v4 |
| 23 | + with: |
| 24 | + node-version: ${{ matrix.node-version }} |
| 25 | + cache: 'yarn' |
| 26 | + |
| 27 | + - name: Install dependencies |
| 28 | + run: yarn install |
| 29 | + |
| 30 | + - name: Lint |
| 31 | + run: yarn run lint |
| 32 | + |
| 33 | + - name: Test with coverage |
| 34 | + run: yarn run test --coverage |
| 35 | + |
| 36 | + - name: Build |
| 37 | + run: yarn build |
| 38 | + |
| 39 | + deploy: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + needs: build |
| 42 | + if: startsWith(github.ref, 'refs/tags/') |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + |
| 46 | + - name: Use Node.js 20 |
| 47 | + uses: actions/setup-node@v4 |
| 48 | + with: |
| 49 | + node-version: 20 |
| 50 | + registry-url: 'https://registry.npmjs.org' |
| 51 | + |
| 52 | + - name: Install dependencies |
| 53 | + run: yarn install |
| 54 | + |
| 55 | + - name: Detect tag type (RELEASE or BETA) |
| 56 | + id: tag_check |
| 57 | + run: | |
| 58 | + TAG_NAME="${GITHUB_REF##*/}" |
| 59 | +
|
| 60 | + if [[ "$TAG_NAME" == *"-BETA"* ]]; then |
| 61 | + echo "Detected BETA release" |
| 62 | + echo "tag_type=BETA" >> $GITHUB_OUTPUT |
| 63 | + else |
| 64 | + echo "Detected RELEASE" |
| 65 | + echo "tag_type=RELEASE" >> $GITHUB_OUTPUT |
| 66 | + fi |
| 67 | +
|
| 68 | + - name: Publish RELEASE |
| 69 | + if: steps.tag_check.outputs.tag_type == 'RELEASE' |
| 70 | + run: npm publish |
| 71 | + env: |
| 72 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 73 | + |
| 74 | + - name: Publish BETA |
| 75 | + if: steps.tag_check.outputs.tag_type == 'BETA' |
| 76 | + run: npm publish --tag next |
| 77 | + env: |
| 78 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 79 | + |
0 commit comments