Skip to content

Commit

Permalink
ARGG-945 Setup publishing (#2)
Browse files Browse the repository at this point in the history
* Add actions

* Add .nvmrc
  • Loading branch information
soulcheck authored Jan 19, 2024
1 parent 1c8b2e3 commit 00ec723
Show file tree
Hide file tree
Showing 8 changed files with 270 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: npm
directory: '/'
schedule:
interval: weekly
time: '10:00'
open-pull-requests-limit: 10
versioning-strategy: increase
ignore:
- dependency-name: '*'
update-types: ['version-update:semver-patch']
29 changes: 29 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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/[email protected]
id: npm-cache
with:
path: |
node_modules/
key: ${{ env.CACHE_NAME }}-${{ hashFiles('package-lock.json') }}

- name: Run linters
run: npm run lint

- name: Test
run: npm test
15 changes: 15 additions & 0 deletions .github/workflows/label-check.yml
Original file line number Diff line number Diff line change
@@ -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,skip-changelog
repo_token: ${{ secrets.GITHUB_TOKEN }}
57 changes: 57 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 }}
46 changes: 46 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
74 changes: 74 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
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 }}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/hydrogen

0 comments on commit 00ec723

Please sign in to comment.