From 222a20f1e817055744576a72d8fc7666f2013fc9 Mon Sep 17 00:00:00 2001 From: Bernd Hufmann Date: Fri, 11 Dec 2020 15:41:50 -0500 Subject: [PATCH] Use github workflow for CI/CD Fixes #8 Signed-off-by: Bernd Hufmann --- .github/workflows/ci-cd.yml | 91 +++++++++++++++++++++++++++++++++++++ .travis.yml | 26 ----------- 2 files changed, 91 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/ci-cd.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml new file mode 100644 index 0000000..9eae16c --- /dev/null +++ b/.github/workflows/ci-cd.yml @@ -0,0 +1,91 @@ +# inspired from https://github.com/eclipse-theia/theia-cpp-extensions/raw/master/.github/workflows/ci-cd.yml +# and https://github.com/theia-ide/theia-trace-extension/raw/master/.github/workflows/build.yml + +name: CI-CD + +on: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: + + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest] + node-version: [12.x] + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + persist-credentials: false + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - name: Cache node_modules with yarn + 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- + - run: yarn build --frozen-lockfile + + env: + CI: true + + publish: + needs: build + if: ${{ github.event_name == 'push' }} + + runs-on: ubuntu-latest + + strategy: + matrix: + node: [12] + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + persist-credentials: false + + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + registry-url: 'https://registry.npmjs.org' + + - name: Pre-Publish + shell: bash + run: yarn build + env: + NODE_OPTIONS: --max_old_space_size=4096 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # https://github.com/microsoft/vscode-ripgrep/issues/9 + + - name: Publish + uses: nick-invision/retry@v2 + with: + timeout_minutes: 5 + retry_wait_seconds: 60 + max_attempts: 3 + retry_on: error + command: yarn run publish:next + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # The variable name comes from here: https://github.com/actions/setup-node/blob/70b9252472eee7495c93bb1588261539c3c2b98d/src/authutil.ts#L48 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7a0339a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -dist: xenial -sudo: required -language: node_js -node_js: '10' -git: - depth: 1 -cache: - yarn: true - directories: - - node_modules -branches: - only: - - master -install: -- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.13.0 -- export PATH=$HOME/.yarn/bin:$PATH ; -script: -- yarn && yarn build -before_deploy: -- printf "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}\n" >> ~/.npmrc -deploy: - provider: script - script: yarn run publish:next - skip_cleanup: true - on: - branch: master