|
| 1 | +name: 🧪 Test and 🚀 Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - beta |
| 8 | + pull_request: {} |
| 9 | + |
| 10 | +jobs: |
| 11 | + test-and-release: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + if: "!contains(github.event.head_commit.message, '[skip ci]')" |
| 14 | + |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + node-version: [12.x, 14.x, 16.x] |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: 🛑 Cancel Previous Runs |
| 21 | + uses: styfle/cancel-workflow-action@a40b8845c0683271d9f53dfcb887a7e181d3918b # [email protected] |
| 22 | + - name: ⬇️ Checkout repo |
| 23 | + uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # pin@v2 |
| 24 | + - name: ⎔ Setup node ${{ matrix.node-version }} |
| 25 | + uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # pin@v2 |
| 26 | + with: |
| 27 | + node-version: ${{ matrix.node-version }} |
| 28 | + registry-url: "https://npm.pkg.github.com" |
| 29 | + cache: "npm" |
| 30 | + - name: 🗄 Cache node_modules |
| 31 | + id: cache-node_modules |
| 32 | + uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed # pin@v2 |
| 33 | + with: |
| 34 | + path: "**/node_modules" |
| 35 | + key: node_modules-${{ runner.os }}-node-${{ matrix.node-version }}-${{ |
| 36 | + hashFiles('**/package-lock.json') }} |
| 37 | + - name: 🗄 Cache .eslintcache |
| 38 | + uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed # pin@v2 |
| 39 | + with: |
| 40 | + path: .eslintcache |
| 41 | + key: eslintcache-${{ runner.os }}-node-${{ matrix.node-version }}-${{ |
| 42 | + hashFiles('**/package-lock.json') }} |
| 43 | + - name: 📥 Install dependencies |
| 44 | + if: steps.cache-node_modules.outputs.cache-hit != 'true' |
| 45 | + run: | |
| 46 | + npm ci --ignore-scripts |
| 47 | + - name: 🧪 Test |
| 48 | + run: | |
| 49 | + npm test |
| 50 | + env: |
| 51 | + CI: true |
| 52 | + - name: 🚀 Release on GitHub |
| 53 | + if: "contains(' refs/heads/main refs/heads/beta ', github.ref) && |
| 54 | + matrix.node-version == '16.x'" |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 58 | + run: | |
| 59 | + npm run release |
0 commit comments