-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
5,827 additions
and
765 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
name: Node.js CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "v[0-9]+.[0-9]+.[0-9]+*" | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js 20.x | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Lint with ESLint | ||
run: npm run lint | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [16.x, 18.x, 20.x, 22.x] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Build and test | ||
run: npm run build | ||
- run: npm run test | ||
- name: Upload coverage reports to Codecov | ||
if: matrix.node-version == '20.x' && github.repository == 'tsutsu3/unbound-control-ts' | ||
uses: codecov/codecov-action@v4 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
fail_ci_if_error: true | ||
changelog: | ||
name: Generate Changelog | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.ref_name, 'release-v') | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install dependencies | ||
run: npm install | ||
- name: Extract version from branch | ||
id: extract_version | ||
run: | | ||
branch_name="${{ github.ref_name }}" | ||
version="${branch_name#release-v}" | ||
echo "version=v$version" >> $GITHUB_ENV | ||
- name: Generate Changelog | ||
run: | | ||
git cliff --tag ${{ env.version }} --output CHANGELOG.md | ||
git add CHANGELOG.md | ||
git commit -m "chore: update CHANGELOG for version ${{ env.version }}" | ||
git push origin ${{ github.ref_name }} | ||
# After the PR is merged to the main branch, create a new tag and release | ||
release: | ||
name: Create Tag and Release | ||
needs: test | ||
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release-v') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Git | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
- name: Extract version from branch | ||
id: extract_version | ||
run: | | ||
branch_name=$(echo "${GITHUB_REF}" | awk -F'/' '{print $3}') | ||
version=${branch_name#release-v} | ||
echo "version=${version}" >> $GITHUB_ENV | ||
- name: Generate Latest Changelog | ||
run: | | ||
git cliff --tag ${{ env.version }} --output CHANGELOG_DIFF.md --latest | ||
- name: Create and push tag | ||
run: | | ||
git tag -a "v${{ env.version }}" -m "Release v${{ env.version }}" | ||
git push origin "v${{ env.version }}" | ||
- name: Create GitHub Release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: "v${{ env.version }}" | ||
release_name: "Release v${{ env.version }}" | ||
body_path: CHANGELOG_DIFF.md | ||
draft: false | ||
prerelease: false | ||
publish: | ||
needs: [release] | ||
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release-v') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
registry-url: "https://registry.npmjs.org" | ||
- run: npm ci | ||
- run: npm run build | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dist/ | ||
node_modules/ | ||
README.md | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"trailingComma": "all", | ||
"tabWidth": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"markdown.extension.toc.levels": "1..3", | ||
"markdown.extension.toc.orderedList": true, | ||
"markdown.extension.toc.omittedFromToc": { | ||
"README.md": ["## Table of Contents"] | ||
}, | ||
"editor.formatOnSave": true, | ||
"editor.formatOnType": true, | ||
"editor.formatOnPaste": true, | ||
"files.eol": "\n" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import eslint from "@eslint/js"; | ||
import tseslint from "typescript-eslint"; | ||
import globals from "globals"; | ||
import tsParser from "@typescript-eslint/parser"; | ||
import eslintConfigPrettier from "eslint-config-prettier"; | ||
|
||
export default [ | ||
{ | ||
ignores: [ | ||
"dist", | ||
"examples", | ||
"vite.config.ts", | ||
"eslint.config.mjs", | ||
"jest.config.ts", | ||
"coverage", | ||
], | ||
}, | ||
{ | ||
files: ["**/*.{js,mjs,cjs,ts}"], | ||
languageOptions: { | ||
parser: tsParser, | ||
parserOptions: { | ||
sourceType: "module", | ||
project: "./tsconfig.eslint.json", | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
globals: globals.node, | ||
}, | ||
}, | ||
eslint.configs.recommended, | ||
...tseslint.configs.strictTypeChecked, | ||
eslintConfigPrettier, | ||
]; |
Oops, something went wrong.