Skip to content

Commit

Permalink
chore(CI): add automatic release (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey authored Oct 14, 2022
1 parent 577e221 commit 1cc30ef
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 30 deletions.
86 changes: 70 additions & 16 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
name: CI
on:
push:
branches: [main]
branches:
# default semantic-release branches
- +([0-9])?(.{+([0-9]),x}).x
- main
- next
- next-major
- beta
- alpha
pull_request:
schedule:
- cron: 0 0 * * 0

jobs:
lint:
name: ⬣ Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]

- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: Install Node
- name: ⎔ Setup Node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install Packages
- name: 📥 Install dependencies
run: npm install

- name: Lint
- name: ▶️ Run lint script
run: npm run lint

test:
name: Test (Node@${{ matrix.node }} - ESLint@${{ matrix.eslint }} - ${{ matrix.os }})
name:
🧪 Test (Node@${{ matrix.node }} - ESLint@${{ matrix.eslint }} - ${{
matrix.os }})
strategy:
matrix:
eslint: [6]
Expand All @@ -45,24 +58,65 @@ jobs:
os: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]

- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: Install Node@${{ matrix.node }}
- name: ⎔ Setup Node v${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install Packages
- name: 📥 Install dependencies
run: npm install

# - name: Install ESLint@${{ matrix.eslint }}
# run: npm install eslint@${{ matrix.eslint }}
# - name: 📥 Install ESLint v${{ matrix.eslint }}
# run: npm install --save-dev eslint@${{ matrix.eslint }}

- name: Test
- name: ▶️ Run test script
run: npm run test

# - name: Send Coverage
# run: npm run -s codecov
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: ⬆️ Upload coverage report
uses: codecov/codecov-action@v3

release:
name: 🚀 Release
needs: [lint, test]
runs-on: ubuntu-latest
if:
github.repository == 'eslint-community/eslint-plugin-mysticatea' &&
contains('refs/heads/main,refs/heads/next,refs/heads/beta,refs/heads/alpha',
github.ref) && github.event_name == 'push'
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]

- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: 18

- name: 📥 Install dependencies
run: npm install

- name: 🚀 Release
uses: cycjimmy/semantic-release-action@v3
with:
semantic_version: 19
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'main',
'next',
'next-major',
{name: 'beta', prerelease: true},
{name: 'alpha', prerelease: true}
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion lib/rules/arrow-parens.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = {
category: "Stylistic Issues",
recommended: false,
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/v13.0.0/docs/rules/arrow-parens.md",
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/arrow-parens.md",
},
fixable: "code",
schema: [],
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/block-scoped-var.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ module.exports = {
category: "Possible Errors",
recommended: false,
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/v13.0.0/docs/rules/block-scoped-var.md",
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/block-scoped-var.md",
},
fixable: null,
schema: [],
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-instanceof-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
description: "disallow 'instanceof' for Array",
category: "Best Practices",
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/v13.0.0/docs/rules/no-instanceof-array.md",
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-instanceof-array.md",
},
fixable: "code",
schema: [],
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-instanceof-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
description: "disallow 'instanceof' for wrapper objects",
category: "Best Practices",
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/v13.0.0/docs/rules/no-instanceof-wrapper.md",
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-instanceof-wrapper.md",
},
fixable: "code",
schema: [],
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-literal-call.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
category: "Possible Errors",
recommended: false,
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/v13.0.0/docs/rules/no-literal-call.md",
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-literal-call.md",
},
fixable: null,
schema: [],
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-this-in-static.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
description: "Disallow `this`/`super` in static methods",
category: "Best Practices",
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/v13.0.0/docs/rules/no-this-in-static.md",
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-this-in-static.md",
},
fixable: null,
schema: [],
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-use-ignored-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
category: "Stylistic Issues",
recommended: false,
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/v13.0.0/docs/rules/no-use-ignored-vars.md",
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-use-ignored-vars.md",
},
fixable: null,
schema: [{ type: "string" }],
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-useless-rest-spread.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module.exports = {
category: "Best Practices",
recommended: false,
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/v13.0.0/docs/rules/no-useless-rest-spread.md",
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-useless-rest-spread.md",
},
fixable: "code",
schema: [],
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-for-of.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ module.exports = {
category: "Best Practices",
recommended: false,
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/v13.0.0/docs/rules/prefer-for-of.md",
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/prefer-for-of.md",
},
fixable: "code",
schema: [],
Expand Down
4 changes: 2 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ module.exports = {
return configuredRulesDocumentUrl
}
try {
const { version, repository } = JSON.parse(
const { repository } = JSON.parse(
fs.readFileSync(
path.join(process.cwd(), "package.json"),
"utf8"
)
)
const baseUrl = getBaseUrl(repository)
if (baseUrl) {
return `${baseUrl}/blob/v${version}/docs/rules/{{name}}.md`
return `${baseUrl}/blob/HEAD/docs/rules/{{name}}.md`
}
} catch (_error) {
// ignore
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-community/eslint-plugin-mysticatea",
"version": "13.0.0",
"version": "0.0.0-semantically-released",
"description": "Additional ESLint rules.",
"engines": {
"node": ">=8.10.0"
Expand All @@ -25,7 +25,6 @@
},
"devDependencies": {
"@eslint-community/eslint-plugin-mysticatea": "file:.",
"codecov": "^3.6.1",
"eslint": "~6.6.0",
"fs-extra": "^8.1.0",
"globals": "^12.1.1",
Expand All @@ -39,7 +38,6 @@
"scripts": {
"clean": "rimraf .nyc_output coverage",
"coverage": "opener coverage/lcov-report/index.html",
"codecov": "codecov --disable=gcov -t $CODECOV_TOKEN",
"lint": "eslint lib scripts tests",
"test": "nyc mocha \"tests/lib/**/*.js\" --reporter dot",
"update": "node scripts/generate-browser-globals && node scripts/generate-configs && node scripts/generate-rules",
Expand Down

0 comments on commit 1cc30ef

Please sign in to comment.