Skip to content

Commit

Permalink
Refactor CI workflow, add publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jgarber623 committed Oct 15, 2023
1 parent 8ed061d commit eebbf2b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 4 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: CI

on: push
on:
pull_request:
workflow_call:
workflow_dispatch:

jobs:
lint:
name: Lint files
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
Expand All @@ -16,12 +19,15 @@ jobs:
- run: npm run lint
test:
name: Test files
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
version: [18, 20]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
node-version: ${{ matrix.version }}
cache: npm
- run: npm ci
- run: npm test
50 changes: 50 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish

on:
release:
types: [published]

jobs:
ci:
name: CI
uses: ./.github/workflows/ci.yml
publish-to-npm:
name: Publish to npm
permissions:
contents: read
id-token: write
needs: ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: npm
registry-url: https://registry.npmjs.org
- run: npm ci
- run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-to-github-packages:
name: Publish to GitHub Packages
permissions:
contents: read
packages: write
needs: ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Change package scope
run: |
sed -i -E "s/@.+(\/stylelint-config)/@${{ github.repository_owner }}\1/" package.json
cat package.json
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: npm
registry-url: https://npm.pkg.github.com
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit eebbf2b

Please sign in to comment.