diff --git a/.github/actions/run-tests/action.yaml b/.github/actions/run-tests/action.yaml new file mode 100644 index 0000000..8bcad2e --- /dev/null +++ b/.github/actions/run-tests/action.yaml @@ -0,0 +1,12 @@ +name: "Run tests" +description: "Runs the tests. Requires that the repo is checked out and gcloud credentials are set." +runs: + using: "composite" + steps: + - name: Install deps + run: npm ci + shell: bash + + - name: Test + run: npm run test + shell: bash \ No newline at end of file diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..3b7f619 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,60 @@ +name: Publish to npm + +on: + workflow_dispatch: {} + workflow_call: + inputs: + version: + required: true + type: string + +env: + FORCE_COLOR: 1 + +jobs: + test: + name: Test + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x, 14.x, 15.x, 16.x] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Run tests + uses: ./.github/actions/run-tests + + build-publish: + if: github.ref == 'refs/heads/master' + + name: Publish + runs-on: ubuntu-latest + needs: test + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: '16.x' + registry-url: 'https://registry.npmjs.org' + + - name: Install deps + run: npm ci + + - name: Build project + run: npm run build + + - name: Publish + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..c917e4e --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,29 @@ +name: Test + +on: + pull_request: + types: [opened, labeled, synchronize] + +env: + FORCE_COLOR: 1 + +jobs: + test: + name: Test + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [10.x, 12.x, 14.x, 15.x] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Run tests + uses: ./.github/actions/run-tests