|
| 1 | +name: Publish CI |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +jobs: |
| 8 | + publish-to-npm: |
| 9 | + runs-on: ubuntu-18.04 |
| 10 | + steps: |
| 11 | + - name: Checkout |
| 12 | + uses: actions/checkout@v3 |
| 13 | + |
| 14 | + - name: Use Node.js 16.x |
| 15 | + uses: actions/setup-node@v3 |
| 16 | + with: |
| 17 | + node-version: 16.x |
| 18 | + cache: 'yarn' |
| 19 | + |
| 20 | + - name: Install dependencies |
| 21 | + run: yarn install --frozen-lockfile |
| 22 | + |
| 23 | + - name: Build package |
| 24 | + run: yarn build |
| 25 | + |
| 26 | + - name: Extract version from release |
| 27 | + id: version |
| 28 | + uses: olegtarasov/[email protected] |
| 29 | + with: |
| 30 | + tagRegex: 'v(.*)' |
| 31 | + |
| 32 | + - name: Set version from release |
| 33 | + |
| 34 | + with: |
| 35 | + version: ${{ steps.version.outputs.tag }} |
| 36 | + git-tag-version: 'false' |
| 37 | + |
| 38 | + - name: Create NPM config |
| 39 | + run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN |
| 40 | + env: |
| 41 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 42 | + |
| 43 | + - name: Check for NEXT tag |
| 44 | + id: next |
| 45 | + uses: actions-ecosystem/action-regex-match@v2 |
| 46 | + with: |
| 47 | + text: ${{ steps.version.outputs.tag }} |
| 48 | + regex: '-next' |
| 49 | + |
| 50 | + - name: Check for RC tag |
| 51 | + id: rc |
| 52 | + uses: actions-ecosystem/action-regex-match@v2 |
| 53 | + with: |
| 54 | + text: ${{ steps.version.outputs.tag }} |
| 55 | + regex: '-rc' |
| 56 | + |
| 57 | + - name: Publish atomic-router-react@${{ steps.version.outputs.tag }} with NEXT tag |
| 58 | + if: ${{ steps.next.outputs.match != '' }} |
| 59 | + run: npm publish --tag next |
| 60 | + |
| 61 | + - name: Publish atomic-router-react@${{ steps.version.outputs.tag }} with RC tag |
| 62 | + if: ${{ steps.rc.outputs.match != '' }} |
| 63 | + run: npm publish --tag rc |
| 64 | + |
| 65 | + - name: Publish atomic-router-react@${{ steps.version.outputs.tag }} to latest |
| 66 | + if: ${{ steps.next.outputs.match == '' }} |
| 67 | + run: npm publish |
0 commit comments