Skip to content

Commit

Permalink
feat: release 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
iseizuu committed Aug 17, 2024
1 parent d3a9359 commit 7fa9a0d
Show file tree
Hide file tree
Showing 144 changed files with 24,213 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"reporter": ["text", "json-summary", "json", "lcov"]
}
3 changes: 3 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["@commitlint/config-conventional"]
}
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
root = true
22 changes: 22 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"env": {
"node": true,
"jest": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest"
},
"plugins": ["@typescript-eslint"],
"root": true,
"ignorePatterns": ["**/*.js"],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-interface": "off"
}
}
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'daily'
open-pull-requests-limit: 10
37 changes: 37 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Dependabot Auto Merge Pull Request
on: pull_request_target

permissions:
pull-requests: write
contents: write

jobs:
dependabot:
runs-on: ubuntu-latest

permissions:
contents: write
issues: write
pull-requests: write

if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.5.1
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'

- name: Auto-merge Dependabot PRs for semver-minor updates
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Auto-merge Dependabot PRs for semver-patch updates
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
66 changes: 66 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Deploy to GitHub Pages

on:
workflow_dispatch:
workflow_run:
workflows: ['Release package']
types:
- completed

# Allow one concurrent deployment
concurrency:
group: 'pages'
cancel-in-progress: true

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: npm

- name: Install dependencies
run: npm ci

- name: Install Docs dependencies
run: |
cd docs
npm ci
- name: Build website
run: |
cd docs
npm run build
- name: Setup Pages
uses: actions/configure-pages@v3

- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: './docs/build'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
21 changes: 21 additions & 0 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release to Github

on:
push:
tags:
- 'v*.*.*'

permissions:
contents: write
discussions: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
94 changes: 94 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Release package
on:
workflow_dispatch:
inputs:
release-type:
description: 'Release type (one of): patch, minor, major, prepatch, preminor, premajor, prerelease'
required: true

concurrency:
group: 'release'
cancel-in-progress: true

permissions:
contents: write
pull-requests: write

jobs:
release:
runs-on: ubuntu-latest
steps:
# Checkout project repository
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.BUILD_TOKEN }}

# Setup Node.js environment
- name: Setup Node.js
uses: actions/setup-node@v3
with:
registry-url: https://registry.npmjs.org/
node-version: '18'

# Install dependencies (required by Run tests step)
- name: Install dependencies
run: npm ci

# Build application
- name: Build application
run: npm run build

# Configure Git
- name: Git configuration
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
# Bump package version to NPM
# Use tag latest
- name: Bump release version to NPM
if: startsWith(github.event.inputs.release-type, 'pre') != true
run: |
echo "NEW_VERSION=$(npm --no-git-tag-version version $RELEASE_TYPE)" >> $GITHUB_ENV
echo "RELEASE_TAG=latest" >> $GITHUB_ENV
echo "PRERELEASE=false >> $GITHUB_ENV"
env:
RELEASE_TYPE: ${{ github.event.inputs.release-type }}

# Bump package pre-release version to NPM
# Use tag beta for pre-release versions
- name: Bump pre-release version to NPM
if: startsWith(github.event.inputs.release-type, 'pre')
run: |
echo "NEW_VERSION=$(npm --no-git-tag-version --preid=beta version $RELEASE_TYPE)" >> $GITHUB_ENV
echo "RELEASE_TAG=beta" >> $GITHUB_ENV
echo "PRERELEASE=true >> $GITHUB_ENV"
env:
RELEASE_TYPE: ${{ github.event.inputs.release-type }}

# Commit changes
- name: Commit package.json changes and create tag
run: |
git add "package.json"
git commit -m "chore: release ${{ env.NEW_VERSION }}"
git tag ${{ env.NEW_VERSION }}
# Publish version to public repository
- name: Publish
run: npm publish --verbose --access public --tag ${{ env.RELEASE_TAG }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }}

# Push repository changes
- name: Push changes to repository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push origin && git push --tags
- uses: google-github-actions/release-please-action@v3
name: Release package to NPM
with:
release-type: node
package-name: release-please-action
73 changes: 73 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Test

on:
workflow_dispatch:
push:
branches: [master]
pull_request_target:
branches:
- master

concurrency:
group: 'test'
cancel-in-progress: false

jobs:
test:
name: Test Library API Response
runs-on: ubuntu-latest

permissions:
checks: write
pull-requests: write
contents: write

steps:
- uses: actions/checkout@v3
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'npm'
cache-dependency-path: package-lock.json

- name: Install dependencies
run: npm ci

- name: Make envfile
uses: SpicyPizza/create-envfile@v1.3
with:
envkey_DEBUG: true
envkey_LTOKEN: ${{ secrets.LTOKEN }}
envkey_LTUID_V2: ${{ secrets.LTUID_V2 }}
envkey_ACCOUNT_ID: ${{ secrets.ACCOUNT_ID }}
envkey_COOKIE_TOKEN: ${{ secrets.COOKIE_TOKEN }}
envkey_ACCOUNT_ID_V2: ${{ secrets.ACCOUNT_ID_V2 }}
envkey_ACCOUNT_MID_V2: ${{ secrets.ACCOUNT_MID_V2 }}
envkey_COOKIE_TOKEN_V2: ${{ secrets.COOKIE_TOKEN_V2 }}
envkey_HI_UID: ${{ secrets.HI_UID }}
envkey_GI_UID: ${{ secrets.GI_UID }}
envkey_HSR_UID: ${{ secrets.HSR_UID }}

- name: Lint
run: npm run lint

- name: Format
run: npm run format

- name: Test and Coverage
run: npm run test:coverage

- name: Create Coverage Badges
uses: jaywcjlove/coverage-badges-cli@main
with:
style: flat
source: coverage/coverage-summary.json
output: coverage/badges.svg

- name: Deploy Test
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/master'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./coverage
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
node_modules
run
hoyoapi-*.tgz
dist
test.ts
api.text
api
coverage
.env
docs
docs/.docusaurus
docs/build
guide.md
guide.html
typedoc.json
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx commitlint --edit ${1}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
5 changes: 5 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run format
npm run lint
Loading

0 comments on commit 7fa9a0d

Please sign in to comment.