|
| 1 | +name: main |
| 2 | +on: [push, pull_request] |
| 3 | + |
| 4 | +jobs: |
| 5 | + test: |
| 6 | + runs-on: ubuntu-latest |
| 7 | + permissions: |
| 8 | + checks: write |
| 9 | + pull-requests: write |
| 10 | + services: |
| 11 | + postgres: |
| 12 | + image: postgres |
| 13 | + env: |
| 14 | + POSTGRES_USER: postgres |
| 15 | + POSTGRES_PASSWORD: postgres |
| 16 | + POSTGRES_DB: postgres |
| 17 | + options: >- |
| 18 | + --health-cmd pg_isready |
| 19 | + --health-interval 10s |
| 20 | + --health-timeout 5s |
| 21 | + --health-retries 5 |
| 22 | + ports: |
| 23 | + - 5432:5432 |
| 24 | + env: |
| 25 | + DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + - uses: denoland/setup-deno@v1 |
| 29 | + with: |
| 30 | + deno-version: v1.x |
| 31 | + - uses: actions/setup-node@v4 |
| 32 | + with: |
| 33 | + node-version: lts/* |
| 34 | + - uses: oven-sh/setup-bun@v1 |
| 35 | + with: |
| 36 | + bun-version: latest |
| 37 | + - run: deno task test --junit-path=.test-report.xml |
| 38 | + - uses: EnricoMi/publish-unit-test-result-action@v2 |
| 39 | + if: always() |
| 40 | + with: |
| 41 | + files: .test-report.xml |
| 42 | + - run: deno task check |
| 43 | + - run: deno task dnt |
| 44 | + - run: bun run ./test_runner.js |
| 45 | + working-directory: ${{ github.workspace }}/npm/ |
| 46 | + |
| 47 | + publish: |
| 48 | + if: github.event_name == 'push' |
| 49 | + needs: [test] |
| 50 | + runs-on: ubuntu-latest |
| 51 | + permissions: |
| 52 | + contents: read |
| 53 | + id-token: write |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v4 |
| 56 | + - uses: denoland/setup-deno@v1 |
| 57 | + with: |
| 58 | + deno-version: v1.x |
| 59 | + - uses: actions/setup-node@v4 |
| 60 | + with: |
| 61 | + node-version: lts/* |
| 62 | + - if: github.ref_type == 'branch' |
| 63 | + run: | |
| 64 | + jq \ |
| 65 | + --arg build "$GITHUB_RUN_NUMBER" \ |
| 66 | + --arg commit "${GITHUB_SHA::8}" \ |
| 67 | + '.version = .version + "-dev." + $build + "+" + $commit' \ |
| 68 | + deno.json > deno.json.tmp |
| 69 | + mv deno.json.tmp deno.json |
| 70 | + - if: github.ref_type == 'tag' |
| 71 | + run: '[[ "$(jq -r .version deno.json)" = "$GITHUB_REF_NAME" ]]' |
| 72 | + - run: 'deno task dnt "$(jq -r .version deno.json)"' |
| 73 | + env: |
| 74 | + DNT_TEST: false |
| 75 | + - run: | |
| 76 | + set -ex |
| 77 | + npm config set //registry.npmjs.org/:_authToken "$NPM_AUTH_TOKEN" |
| 78 | + if [[ "$GITHUB_REF_TYPE" = "tag" ]]; then |
| 79 | + npm publish --provenance --access public |
| 80 | + else |
| 81 | + npm publish --provenance --access public --tag dev |
| 82 | + fi |
| 83 | + env: |
| 84 | + NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |
| 85 | + working-directory: ${{ github.workspace }}/npm/ |
| 86 | + - run: deno publish --allow-dirty |
0 commit comments