|
| 1 | +# inspired from https://github.com/eclipse-theia/theia-cpp-extensions/raw/master/.github/workflows/ci-cd.yml |
| 2 | +# and https://github.com/theia-ide/theia-trace-extension/raw/master/.github/workflows/build.yml |
| 3 | + |
| 4 | +name: CI-CD |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - master |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + runs-on: ${{ matrix.os }} |
| 19 | + |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + os: [ubuntu-latest] |
| 23 | + node-version: [12.x] |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v2 |
| 28 | + with: |
| 29 | + persist-credentials: false |
| 30 | + |
| 31 | + - name: Use Node.js ${{ matrix.node-version }} |
| 32 | + uses: actions/setup-node@v1 |
| 33 | + with: |
| 34 | + node-version: ${{ matrix.node-version }} |
| 35 | + |
| 36 | + - name: Get yarn cache directory path |
| 37 | + id: yarn-cache-dir-path |
| 38 | + run: echo "::set-output name=dir::$(yarn cache dir)" |
| 39 | + |
| 40 | + - name: Cache node_modules with yarn |
| 41 | + uses: actions/cache@v2 |
| 42 | + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) |
| 43 | + with: |
| 44 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 45 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 46 | + restore-keys: | |
| 47 | + ${{ runner.os }}-yarn- |
| 48 | + - run: yarn build --frozen-lockfile |
| 49 | + |
| 50 | + env: |
| 51 | + CI: true |
| 52 | + |
| 53 | + publish: |
| 54 | + needs: build |
| 55 | + if: ${{ github.event_name == 'push' }} |
| 56 | + |
| 57 | + runs-on: ubuntu-latest |
| 58 | + |
| 59 | + strategy: |
| 60 | + matrix: |
| 61 | + node: [12] |
| 62 | + |
| 63 | + steps: |
| 64 | + - name: Checkout |
| 65 | + uses: actions/checkout@v2 |
| 66 | + with: |
| 67 | + persist-credentials: false |
| 68 | + |
| 69 | + - name: Use Node.js ${{ matrix.node }} |
| 70 | + uses: actions/setup-node@v1 |
| 71 | + with: |
| 72 | + node-version: ${{ matrix.node }} |
| 73 | + registry-url: 'https://registry.npmjs.org' |
| 74 | + |
| 75 | + - name: Pre-Publish |
| 76 | + shell: bash |
| 77 | + run: yarn build |
| 78 | + env: |
| 79 | + NODE_OPTIONS: --max_old_space_size=4096 |
| 80 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # https://github.com/microsoft/vscode-ripgrep/issues/9 |
| 81 | + |
| 82 | + - name: Publish |
| 83 | + uses: nick-invision/retry@v2 |
| 84 | + with: |
| 85 | + timeout_minutes: 5 |
| 86 | + retry_wait_seconds: 60 |
| 87 | + max_attempts: 3 |
| 88 | + retry_on: error |
| 89 | + command: yarn run publish:next |
| 90 | + env: |
| 91 | + 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 |
0 commit comments