Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Action for publishing new releases #59

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
35 changes: 0 additions & 35 deletions .eslintrc

This file was deleted.

31 changes: 31 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// eslint-disable-next-line no-undef
module.exports = {
root: true,
extends: ["eslint:recommended"],
plugins: ["@typescript-eslint"],
rules: {
"no-console": "error",
"no-debugger": "error",
"indent": ["error", 4],
"max-len": ["warn", { "code": 120 }],
"object-curly-spacing": ["error", "always"],
"quotes": ["error", "double"],
"space-before-function-paren": ["error", "never"],
"no-inner-declarations": "off",
"brace-style": ["error", "1tbs"],
"keyword-spacing": "error",
"no-async-promise-executor": "off",
"require-atomic-updates": "off",
"no-unused-vars": "off"
},
parser: "@typescript-eslint/parser",
parserOptions: {
"ecmaVersion": 6,
"sourceType": "module",
},
env: {
"browser": true,
"node": true,
"jest": true
}
}
27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Lint

on: [push]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Cache node modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm install
- name: Install ESLint CLI
run: npm i -g eslint
- name: Run ESLint
run: eslint "src/**/*.ts"

54 changes: 54 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Publish

on:
push:
branches:
- master

jobs:
release_npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: Install dependencies
run: npm install
- name: Build library
run: npm run build && npm run types
- name: Publish to NPM
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
- name: Get latest commit SHA
id: commit_sha
shell: bash
run: |
echo "::set-output name=sha::$(git rev-parse HEAD)"
- name: Get package version number
id: package_version
shell: bash
run: |
echo "::set-output name=package_version::$(cat package.json | grep 'version' | sed 's/^.*\([0-9]\+.[0-9]\+.[0-9]\+\).*$/\1/')"
- name: Create new tag
uses: octokit/[email protected]
id: create_new_tag
with:
route: POST /repos/:owner/:repo/git/tags
owner: mega-go
repo: megago
tag: ${{ steps.package_version.outputs.package_version }}
message: "Release for version ${{ steps.package_version.outputs.package_version }}"
object: ${{ steps.commit_sha.outputs.sha }}
type: commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.package_version.outputs.package_version }}
release_name: ${{ steps.package_version.outputs.package_version }}
draft: false
prerelease: false
Loading