|
| 1 | +name: Publish TypeScript Telemetry |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + publish: |
| 10 | + name: Build and Publish |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Setup Node.js |
| 18 | + uses: actions/setup-node@v4 |
| 19 | + with: |
| 20 | + node-version: '22' |
| 21 | + registry-url: 'https://registry.npmjs.org' |
| 22 | + |
| 23 | + - name: Install pnpm |
| 24 | + uses: pnpm/action-setup@v2 |
| 25 | + with: |
| 26 | + version: 9 |
| 27 | + |
| 28 | + - name: Get pnpm store directory |
| 29 | + shell: bash |
| 30 | + run: | |
| 31 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 32 | +
|
| 33 | + - name: Setup pnpm cache |
| 34 | + uses: actions/cache@v3 |
| 35 | + with: |
| 36 | + path: ${{ env.STORE_PATH }} |
| 37 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 38 | + restore-keys: | |
| 39 | + ${{ runner.os }}-pnpm-store- |
| 40 | +
|
| 41 | + - name: Get package version |
| 42 | + id: get_version |
| 43 | + run: | |
| 44 | + CURRENT_VERSION=$(node -p "require('./packages/telemetry/typescript/package.json').version") |
| 45 | + echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT |
| 46 | +
|
| 47 | + - name: Check version on npm |
| 48 | + id: check_version |
| 49 | + run: | |
| 50 | + NPM_VERSION=$(npm view @latitude-data/telemetry version 2>/dev/null || echo "0.0.0") |
| 51 | + if [ "${{ steps.get_version.outputs.version }}" != "$NPM_VERSION" ]; then |
| 52 | + echo "should_publish=true" >> $GITHUB_OUTPUT |
| 53 | + else |
| 54 | + echo "should_publish=false" >> $GITHUB_OUTPUT |
| 55 | + fi |
| 56 | +
|
| 57 | + - name: Install dependencies |
| 58 | + if: steps.check_version.outputs.should_publish == 'true' |
| 59 | + run: pnpm install --filter=@latitude-data/telemetry... |
| 60 | + |
| 61 | + - name: Build package (with workspace dependencies) |
| 62 | + if: steps.check_version.outputs.should_publish == 'true' |
| 63 | + run: pnpm exec turbo run build --filter=@latitude-data/telemetry... |
| 64 | + |
| 65 | + - name: Run linter |
| 66 | + if: steps.check_version.outputs.should_publish == 'true' |
| 67 | + run: pnpm exec turbo run lint --filter=@latitude-data/telemetry... |
| 68 | + |
| 69 | + - name: Run typescript checker |
| 70 | + if: steps.check_version.outputs.should_publish == 'true' |
| 71 | + run: pnpm exec turbo run tc --filter=@latitude-data/telemetry... |
| 72 | + |
| 73 | + - name: Run tests |
| 74 | + if: steps.check_version.outputs.should_publish == 'true' |
| 75 | + run: pnpm exec turbo run test --filter=@latitude-data/telemetry... |
| 76 | + |
| 77 | + - name: Publish to npm |
| 78 | + if: steps.check_version.outputs.should_publish == 'true' |
| 79 | + run: pnpm publish --access public --filter=@latitude-data/telemetry --no-git-checks |
| 80 | + |
| 81 | + env: |
| 82 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments