diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml new file mode 100644 index 0000000..8d5b3a0 --- /dev/null +++ b/.github/workflows/github-actions-demo.yml @@ -0,0 +1,38 @@ +name: Tests + +on: [push, pull_request] + +jobs: + node-tests: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x, 14.x, 16.x] + + steps: + - uses: actions/checkout@v2 + - name: Install Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run lint + - run: npm run test + + browser-tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Install Node.js 14 + uses: actions/setup-node@v2 + with: + node-version: 14.x + cache: 'npm' + - name: Install Chrome Stable + uses: browser-actions/setup-chrome@latest + - run: npm ci + - run: npm run lint + - run: npm run test:browser diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..bca7370 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,22 @@ +name: Publish Package +on: + push: + tags: + - '*' +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '14.x' + registry-url: 'https://registry.npmjs.org' + - run: npm ci + - run: npm run prepublishOnly + - id: get_npm_label + run: if (npx semver ${{ github.event.release.tag_name }} --range '>0.0.0'); then echo ::set-output name=NPM_LABEL::latest; else echo ::set-output name=NPM_LABEL::beta; fi; # Using the fact that semver by default considers that pre-releases do not respect stable ranges + - run: npm publish --tag=${NPM_LABEL} --access public + env: + NPM_LABEL: ${{ steps.get_npm_label.outputs.NPM_LABEL }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 558b895..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,35 +0,0 @@ -stages: - - test - - test-browser - - deploy - -image: node:14 - -before_script: - - echo "//registry.npmjs.org/:_authToken=${NPM_REGISTRY_TOKEN}" > .npmrc - - npm ci --cache .npm --prefer-offline - -cache: - key: "nedb" # universal cache - paths: - - .npm/ - -test: - stage: test - script: - - npm run lint - - npm run test - -test-browser: - image: nexus-docker.tardis.seald.io/seald/docker-browser-testing:CHROME_88 - stage: test-browser - script: npm run test:browser - -deploy: - stage: deploy - script: - - npm run prepublishOnly - - if (npx semver $CI_COMMIT_TAG --range '>0.0.0'); then NPM_TAG=latest; else NPM_TAG=beta; fi; # Using the fact that semver by default considers that pre-releases do not respect stable ranges - - npm publish --tag=$NPM_TAG --access public - only: - - tags