diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..251b7c9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: +- package-ecosystem: npm + directory: "/" + schedule: + interval: weekly + time: "10:00" + open-pull-requests-limit: 10 + versioning-strategy: increase diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..45a16bb --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,29 @@ +name-template: '$RESOLVED_VERSION' +tag-template: '$RESOLVED_VERSION' +categories: + - title: 'Breaking' + label: 'major' + - title: 'Added' + label: 'minor' + - title: 'Fixed' + label: 'patch' + - title: 'Dependency updates' + label: 'dependencies' +exclude-labels: + - 'skip-changelog' + - 'github_actions' +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + - 'dependencies' + default: patch +template: | + ## What’s Changed + $CHANGES diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml new file mode 100644 index 0000000..7a6c81d --- /dev/null +++ b/.github/workflows/_test.yml @@ -0,0 +1,33 @@ +name: Test + +on: + workflow_call: + +defaults: + run: + shell: bash -l {0} + +env: + CACHE_NAME: node-modules-cache + +jobs: + Test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org' + + - name: Restore Cache + uses: actions/cache/restore@v3.3.1 + id: npm-cache + with: + path: | + node_modules/ + key: ${{ env.CACHE_NAME }}-${{ hashFiles('package-lock.json') }} + + - name: Test + run: npm test diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index d66d009..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: CI - -on: - push: - branches: [main] - pull_request: - branches: [main] - -defaults: - run: - shell: bash -l {0} - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - name: nvm install - run: nvm install - - - name: Install - run: npm ci - - - name: Test - run: | - nvm use - npm test diff --git a/.github/workflows/label-check.yml b/.github/workflows/label-check.yml new file mode 100644 index 0000000..a1af912 --- /dev/null +++ b/.github/workflows/label-check.yml @@ -0,0 +1,15 @@ +name: label-check + +on: + pull_request_target: + types: [opened, labeled, unlabeled, synchronize] + +jobs: + label-check: + runs-on: ubuntu-latest + + steps: + - uses: docker://agilepathway/pull-request-label-checker:latest + with: + one_of: major,minor,patch,dependencies,skip-changelog + repo_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..b755cc0 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,57 @@ +name: Main + +on: + push: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +defaults: + run: + shell: bash -l {0} + +env: + CACHE_NAME: node-modules-cache + +jobs: + Create-NPM-Cache: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org' + + - name: Upload to Cache + uses: actions/cache@v3.3.1 + id: npm-cache + with: + path: | + node_modules/ + key: ${{ env.CACHE_NAME }}-${{ hashFiles('package-lock.json') }} + + - name: Install dependencies + if: ${{ steps.npm-cache.outputs.cache-hit != 'true' }} + run: npm ci + + Run-Tests: + permissions: + statuses: write + pull-requests: write + needs: [Create-NPM-Cache] + uses: ./.github/workflows/_test.yml + + ReleaseDraft: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: read + steps: + - name: Draft release notes + uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..ae76db2 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,46 @@ +name: PR + +on: + pull_request: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +defaults: + run: + shell: bash -l {0} + +env: + CACHE_NAME: node-modules-cache + +jobs: + Create-NPM-Cache: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org' + + - name: Upload to Cache + uses: actions/cache@v3.3.1 + id: npm-cache + with: + path: | + node_modules/ + key: ${{ env.CACHE_NAME }}-${{ hashFiles('package-lock.json') }} + + - name: Install dependencies + if: ${{ steps.npm-cache.outputs.cache-hit != 'true' }} + run: npm ci + + Run-Tests: + permissions: + statuses: write + pull-requests: write + needs: [Create-NPM-Cache] + uses: ./.github/workflows/_test.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d8f150c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,74 @@ +name: release + +on: + release: + types: [published] + +defaults: + run: + shell: bash -l {0} + +env: + CACHE_NAME: node-modules-cache + +jobs: + Create-NPM-Cache: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org' + + - name: Upload to Cache + uses: actions/cache@v3.3.1 + id: npm-cache + with: + path: | + node_modules/ + key: ${{ env.CACHE_NAME }}-${{ hashFiles('package-lock.json') }} + + - name: Install dependencies + if: ${{ steps.npm-cache.outputs.cache-hit != 'true' }} + run: npm ci + + Run-Tests: + permissions: + statuses: write + pull-requests: write + needs: [Create-NPM-Cache] + uses: ./.github/workflows/_test.yml + + Release: + name: Release @skyscanner/eslint-plugin-backpack to NPM + runs-on: ubuntu-latest + environment: Publishing + needs: [Create-NPM-Cache, Run-Tests] + steps: + - name: Checkout source code + uses: actions/checkout@v3 + with: + ref: main + + - uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org' + + - name: Restore Cache + uses: actions/cache/restore@v3.3.1 + id: npm-cache + with: + path: | + node_modules/ + key: ${{ env.CACHE_NAME }}-${{ hashFiles('package-lock.json') }} + + - name: Publish NPM package + run: | + npm version $RELEASE_VERSION --no-git-tag-version + npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + RELEASE_VERSION: ${{ github.event.release.tag_name }}