diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..af0fbc3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [8.x, 10.x, 12.x] + + steps: + - uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: install deps & check + run: | + yarn + yarn run ci + env: + CI: true diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..0380754 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,19 @@ +name: Publish + +on: + release: + types: [published] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Install dependencies + run: yarn + - name: Publish to npm + run: npm publish --access=public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 0000000..0b6136f --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,29 @@ +name: Tag + +on: + push: + branches: + - master + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Create tag + run: | + tagName="v$(jq '.version' package.json | sed "s/\"//g")" + if [[ -n $(git ls-remote --tags origin $tagName) ]]; then + echo "tag $tagName already exists, skip release" + else + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + git tag -a $tagName -m "release by Github Actions" + fi + - name: Push to repo + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: master diff --git a/package.json b/package.json index e2b08bf..2eaa3f2 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "format": "prettier --write '**/*.{js,json,css,md,less,tsx,ts}'", "check-formatting": "prettier --check '**/*.{js,json,css,md,less,tsx,ts}'", "codecov": "codecov", - "commit": "commit" + "commit": "commit", + "ci": "yarn check-types && yarn check-formatting && yarn test" }, "files": [ "dist/lib"