Skip to content

Commit

Permalink
feat: initialize repository
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Oct 23, 2020
0 parents commit ca42087
Show file tree
Hide file tree
Showing 69 changed files with 8,179 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @type {import('eslint').Linter.Config}
*/
module.exports = {
env: {
es2021: true,
browser: true,
node: true
},
extends: [
'plugin:vue/essential',
'standard'
],
globals: {
__static: true,
__windowUrls: true,
NodeJS: true
},
parserOptions: {
ecmaVersion: 12,
parser: '@typescript-eslint/parser',
sourceType: 'module'
},
plugins: [
'vue',
'@typescript-eslint'
],
rules: {
'space-before-function-paren': 0,
'vue/no-multiple-template-root': 0,
'import/no-absolute-path': 0
},
ignorePatterns: [
'node_modules/**',
'dist/**'
]
}
9 changes: 9 additions & 0 deletions .github/actions/get-build-number/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: TEST
description: Prepare Pull Request for the current change
outputs:
build_number:
description: The release body
runs:
using: 'node12'
main: index.js

9 changes: 9 additions & 0 deletions .github/actions/get-build-number/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
async function main(output) {
output('build_number', process.env.GITHUB_RUN_NUMBER);
}

function setOutput(name, value) {
process.stdout.write(Buffer.from(`::set-output name=${name}::${value}`))
}

main(setOutput);
6 changes: 6 additions & 0 deletions .github/actions/get-build-number/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"devDependencies": {
"@actions/core": "1.2.6"
}
}
9 changes: 9 additions & 0 deletions .github/actions/get-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Get Package Version
description: Get NPM Package Version
outputs:
version:
description: The version
runs:
using: 'node12'
main: index.js

11 changes: 11 additions & 0 deletions .github/actions/get-version/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { readFileSync } = require("fs");

async function main(output) {
output('version', JSON.parse(readFileSync('./package.json')).version)
}

function setOutput(name, value) {
process.stdout.write(Buffer.from(`::set-output name=${name}::${value}`))
}

main(setOutput);
6 changes: 6 additions & 0 deletions .github/actions/get-version/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"devDependencies": {
"@actions/core": "1.2.6"
}
}
15 changes: 15 additions & 0 deletions .github/actions/update-version-changelog/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Update Version and Write Changelog
description: Update the version and write changelog
inputs:
version:
description: The version to write
default: ''
required: false
changelog:
description: The changelog to write
default: ''
required: false
runs:
using: 'node12'
main: index.js

22 changes: 22 additions & 0 deletions .github/actions/update-version-changelog/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { writeFileSync, readFileSync } = require("fs");

function main(input) {
const version = input('version')
const changelog = input('changelog')

if (changelog) {
const content = changelog + readFileSync('./CHANGELOG.md').toString()
writeFileSync('./CHANGELOG.md', Buffer.from(content))
}
if (version) {
const package = JSON.parse(readFileSync('./package.json'))
package.version = version
writeFileSync('./package.json', JSON.stringify(package, null, 2))
}
}

function getInput(name) {
return process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
}

main(getInput);
6 changes: 6 additions & 0 deletions .github/actions/update-version-changelog/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"devDependencies": {
"@actions/core": "1.2.6"
}
}
160 changes: 160 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
name: Build

on:
push:
branches:
- master
paths:
- 'build/**'
- 'scripts/*'
- 'src/**'
- 'static/**'
- 'package.json'
- 'package-lock.json'

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12
# - name: Get npm cache directory
# id: npm-cache
# run: |
# echo "::set-output name=dir::$(npm config get cache)"
# - uses: actions/cache@v1
# with:
# path: ${{ steps.npm-cache.outputs.dir }}
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-node-
- name: Install
run: |
npm ci
- name: Get Build Number
id: vars
uses: ./.github/actions/get-build-number
- name: Build
run: |
npm run build:production
env:
BUILD_NUMBER: ${{ steps.vars.outputs.build_number }}
FULL_RELEASE: ${{ startsWith(github.event.commits[0].message, 'chore(release)') }}
# If you build nsis web, you should uncomment below
# - name: Upload Web Build
# uses: actions/upload-artifact@v2
# with:
# name: build
# path: build/nsis-web/*.*
- name: Upload Build
uses: actions/upload-artifact@v2
with:
name: build
path: build/*.*
- name: Upload Windows Asar
if: ${{ runner.os == 'Windows' && startsWith(github.event.commits[0].message, 'chore(release)') }}
uses: actions/upload-artifact@v2
with:
name: build
path: build/win-unpacked/resources/app.asar

repare-release:
runs-on: ubuntu-latest
needs: build
if: ${{ !startsWith(github.event.commits[0].message, 'chore(release)') }}
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- name: Fetch All
run: git fetch --prune --unshallow
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: |
npm ci
env:
CI: true
- name: Get Package Version
uses: ./.github/actions/get-version
id: package
- name: Bump Version and Generate Changelog
id: version
uses: ci010/conventional-changelog-action@master
with:
github-token: ${{ secrets.github_token }}
version: ${{ steps.package.outputs.version }}
tag-prefix: 'v'
- name: Update package.json and CHANGELOG.md
uses: ./.github/actions/update-version-changelog
with:
version: ${{ steps.version.outputs.version }}
changelog: ${{ steps.version.outputs.changelog }}
- name: Create Pull Request
if: ${{ steps.version.outputs.skipped == 'false' }}
uses: peter-evans/create-pull-request@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: >-
${{ format('chore(release): {0}', steps.version.outputs.version) }}
title: ${{ format('Prepare Release {0}', steps.version.outputs.version) }}
body: ${{ steps.version.outputs.clean_changelog }}
branch: prepare-release

release:
if: startsWith(github.event.commits[0].message, 'chore(release)')
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12
- name: Fetch All
run: git fetch --prune --unshallow
# - uses: actions/cache@v1
# with:
# path: ~/.npm
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-node-
- name: Install
run: |
npm ci
- name: Download Build
uses: actions/download-artifact@v2
with:
name: build
path: build
- name: Get Package Version
uses: ./.github/actions/get-version
id: package
- name: Prepare Release
id: prepare_release
uses: ci010/conventional-changelog-action@master
with:
github-token: ${{ secrets.github_token }}
version: ${{ steps.package.outputs.version }}
tag-prefix: 'v'
- name: Draft Release
id: create_release
uses: voxelum/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ format('v{0}', steps.prepare_release.outputs.version) }}
release_name: ${{ format('v{0}', steps.prepare_release.outputs.version) }}
draft: false
prerelease: false
body: ${{ steps.prepare_release.outputs.clean_changelog }}
asset_dir_path: ./build
50 changes: 50 additions & 0 deletions .github/workflows/test-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: TestWorkflow

on:
issue_comment


jobs:
bump:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- name: Fetch All
run: git fetch --prune --unshallow
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: |
npm ci
env:
CI: true
- name: Get Package Version
uses: ./.github/actions/get-version
id: package
- name: Bump Version and Generate Changelog
id: version
uses: ci010/conventional-changelog-action@master
with:
github-token: ${{ secrets.github_token }}
version: ${{ steps.package.outputs.version }}
tag-prefix: 'v'
- name: Update package.json and CHANGELOG.md
uses: ./.github/actions/update-version-changelog
with:
version: ${{ steps.version.outputs.version }}
changelog: ${{ steps.version.outputs.changelog }}
- name: Create Pull Request
if: ${{ steps.version.outputs.skipped == 'false' }}
uses: peter-evans/create-pull-request@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: >-
${{ format('chore(release): {0}', steps.version.outputs.version) }}
title: ${{ format('Prepare Release {0}', steps.version.outputs.version) }}
body: ${{ steps.version.outputs.clean_changelog }}
branch: prepare-release
28 changes: 28 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Validate

on:
pull_request

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12
- name: Install
run: |
npm ci
- name: Lint
uses: mrdivyansh/eslint-action
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
eslint-rc: .eslintrc.js
execute-on-files:
- ./src
- name: Build
run: |
npm run build
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.DS_Store
dist
build
*.local
Loading

0 comments on commit ca42087

Please sign in to comment.