diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..170c5460 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,89 @@ +name: CI +on: + - push + +jobs: + test: + runs-on: ubuntu-latest + steps: + # Setup environment and checkout the project master + - name: Setup Node.js environment + uses: actions/setup-node@v1.4.2 + - name: Checkout + uses: actions/checkout@v2 + + # Setup yarn cache + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - uses: actions/cache@v2 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + # Install and run tests + - name: Install dependencies + run: yarn install + - name: Test + run: yarn test + + lint: + runs-on: ubuntu-latest + steps: + # Setup environment and checkout the project master + - name: Setup Node.js environment + uses: actions/setup-node@v1.4.2 + - name: Checkout + uses: actions/checkout@v2 + + # Setup yarn cache + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - uses: actions/cache@v2 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + # Install and run lint + - name: Install dependencies + run: yarn install + - name: Lint + run: yarn lint + + lincense-check: + runs-on: ubuntu-latest + steps: + # Setup environment and checkout the project master + - name: Setup Node.js environment + uses: actions/setup-node@v1.4.2 + - name: Checkout + uses: actions/checkout@v2 + + # Setup yarn cache + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - uses: actions/cache@v2 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + # Install and run license checker + - name: Install dependencies + run: yarn install + - name: Install License checker + run: | + yarn global add license-checker + echo "::add-path::$(yarn global bin)" + - name: Check licenses + run: "license-checker --onlyAllow '0BDS;MIT;Apache-2.0;ISC;BSD-3-Clause;BSD-2-Clause;CC-BY-4.0;CC-BY-3.0;BSD;CC0-1.0;Unlicense;UNLICENSED' --summary" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..2fef2854 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,41 @@ +name: Publish +on: + release: + types: [created] + +jobs: + publish: + runs-on: ubuntu-latest + steps: + # Checkout project master and setup environment + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Node.js environment + uses: actions/setup-node@v1.4.2 + with: + registry-url: "https://npm.pkg.github.com" + # Defaults to the user or organization that owns the workflow file + scope: "@superindustries" + + # Install dependencies and run test + - name: Install dependencies + run: yarn install + - name: Test + run: yarn test + + # Build the project + - name: Build + run: yarn build + + # Prepare and publish + - name: Publish Git preparation + run: | + echo Publishing as version ${GITHUB_REF##*/v} + # This is to appease the GIT gods. Yarn cannot publish without a version bump (that would invoke git with empty credentials) + git config --global user.email "foo@bar.com" + git config --global user.name "Foo Bar" + git tag -d ${GITHUB_REF##*/} + - name: Publish + run: yarn publish --new-version ${GITHUB_REF##*/v} --verbose + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index e67b3217..ced2022a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "superface", - "version": "0.0.0", + "name": "@superindustries/superface", + "version": "0.0.1", "description": "Level 5 autonomous, self-driving API client, https://superface.ai", "main": "dist/superface.js", "source": "src/index.ts", @@ -12,6 +12,12 @@ "author": "Superface Team", "license": "MIT", "private": false, + "files": [ + "dist/**/*" + ], + "publishConfig": { + "registry": "https://npm.pkg.github.com/" + }, "scripts": { "build": "microbundle --tsconfig tsconfig.release.json", "watch": "yarn build --watch",