|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +defaults: |
| 8 | + run: |
| 9 | + shell: bash -l {0} |
| 10 | + |
| 11 | +env: |
| 12 | + CACHE_NAME: node-modules-cache |
| 13 | + |
| 14 | +jobs: |
| 15 | + Create-NPM-Cache: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v3 |
| 19 | + |
| 20 | + - uses: actions/setup-node@v3 |
| 21 | + with: |
| 22 | + node-version-file: '.nvmrc' |
| 23 | + registry-url: 'https://registry.npmjs.org' |
| 24 | + |
| 25 | + - name: Upload to Cache |
| 26 | + uses: actions/cache@v3.3.1 |
| 27 | + id: npm-cache |
| 28 | + with: |
| 29 | + path: | |
| 30 | + node_modules/ |
| 31 | + key: ${{ env.CACHE_NAME }}-${{ hashFiles('package-lock.json') }} |
| 32 | + |
| 33 | + - name: Install dependencies |
| 34 | + if: ${{ steps.npm-cache.outputs.cache-hit != 'true' }} |
| 35 | + run: npm ci |
| 36 | + |
| 37 | + Run-Tests: |
| 38 | + permissions: |
| 39 | + statuses: write |
| 40 | + pull-requests: write |
| 41 | + needs: [Create-NPM-Cache] |
| 42 | + uses: ./.github/workflows/_test.yml |
| 43 | + |
| 44 | + Release: |
| 45 | + name: Release @skyscanner/eslint-plugin-backpack to NPM |
| 46 | + runs-on: ubuntu-latest |
| 47 | + environment: Publishing |
| 48 | + needs: [Create-NPM-Cache, Run-Tests] |
| 49 | + steps: |
| 50 | + - name: Checkout source code |
| 51 | + uses: actions/checkout@v3 |
| 52 | + with: |
| 53 | + ref: main |
| 54 | + |
| 55 | + - uses: actions/setup-node@v3 |
| 56 | + with: |
| 57 | + node-version-file: '.nvmrc' |
| 58 | + registry-url: 'https://registry.npmjs.org' |
| 59 | + |
| 60 | + - name: Restore Cache |
| 61 | + uses: actions/cache/restore@v3.3.1 |
| 62 | + id: npm-cache |
| 63 | + with: |
| 64 | + path: | |
| 65 | + node_modules/ |
| 66 | + key: ${{ env.CACHE_NAME }}-${{ hashFiles('package-lock.json') }} |
| 67 | + |
| 68 | + - name: Publish NPM package |
| 69 | + run: | |
| 70 | + npm version $RELEASE_VERSION --no-git-tag-version |
| 71 | + npm publish |
| 72 | + env: |
| 73 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 74 | + RELEASE_VERSION: ${{ github.event.release.tag_name }} |
0 commit comments