Repository navigation
138 lines (120 loc) · 5.9 KB
/
Copy pathbuild-hogql-parser-npm.yml
File metadata and controls
138 lines (120 loc) · 5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Release hogql-parser npm
on:
pull_request:
paths:
- common/hogql_parser/**
- .github/workflows/build-hogql-parser-npm.yml
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
# npm's audit blocks the pnpm bootstrap. See .github/actions/pnpm-install for why.
NPM_CONFIG_AUDIT: 'false'
NPM_CONFIG_FUND: 'false'
jobs:
check-package-version:
name: Check npm package version
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
contents: read
pull-requests: write
outputs:
is-new-version: ${{ steps.check-package-version.outputs.is-new-version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check if common/hogql_parser/ has changed
id: changed-files
if: github.event_name == 'pull_request'
uses: step-security/changed-files@2e07db73e5ccdb319b9a6c7766bd46d39d304bad # v47.0.5
with:
use_rest_api: true
files_yaml: |
parser:
- common/hogql_parser/**
- name: Check package version and detect an update
id: check-package-version
uses: PostHog/check-package-version@f540540cb12d45ec3c58d42dbf1d60070ed2d268 # v2.1.1
with:
path: common/hogql_parser
- name: Comment on PR if version not bumped
if: steps.changed-files.outputs.parser_any_changed == 'true' && steps.check-package-version.outputs.is-new-version == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMITTED_VERSION: ${{ steps.check-package-version.outputs.committed-version }}
IS_FORK: ${{ github.event.pull_request.head.repo.full_name != 'PostHog/posthog' }}
run: |
message_body="It looks like the code of \`@posthog/hogql-parser\` (npm) changed in this PR, but its version stayed the same at $COMMITTED_VERSION. 👀"
message_body+=$'\n'"Make sure to resolve this in \`common/hogql_parser/package.json\` before merging!"
if [[ "$IS_FORK" == 'true' ]]; then
message_body+=$'\n'"This needs to be performed on a branch created on the PostHog/posthog repo itself. A PostHog team member will assist with this."
fi
if [ -f .github/scripts/post-reminder-section.mjs ]; then
BODY="$message_body" GITHUB_TOKEN="$GH_TOKEN" node .github/scripts/post-reminder-section.mjs hogql-parser-npm warn "version bump needed"
else
echo "$message_body"
fi
# Version was bumped — mark any reminder from an earlier push resolved.
- name: Clear version reminder
if: steps.changed-files.outputs.parser_any_changed == 'true' && steps.check-package-version.outputs.is-new-version == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEW_VERSION: ${{ steps.check-package-version.outputs.committed-version }}
run: |
if [ -f .github/scripts/post-reminder-section.mjs ]; then
node .github/scripts/post-reminder-section.mjs hogql-parser-npm --clear "version bumped to $NEW_VERSION"
fi
build-wasm:
name: Build WASM
needs: check-package-version
runs-on: ubuntu-24.04
timeout-minutes: 30
if: needs.check-package-version.outputs.is-new-version == 'true' &&
(github.event_name == 'workflow_dispatch' ||
github.event.pull_request.head.repo.full_name == 'PostHog/posthog')
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Emscripten for WASM build
uses: ./.github/actions/setup-emsdk
- name: Install Ninja
run: sudo apt-get install -y ninja-build
- name: Build WASM package
run: cd common/hogql_parser && npm run build
- name: Upload dist artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: hogql-parser-dist
path: common/hogql_parser/dist/
if-no-files-found: error
publish-npm:
name: Publish on npm
needs: build-wasm
# A version must not ship before the code that produces it lands, so a release
# is a manual dispatch on master and never a pull request run.
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master' && github.repository == 'PostHog/posthog'
environment: npm-hogql-parser
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Download dist artifact
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: hogql-parser-dist
path: common/hogql_parser/dist
- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org
- name: Publish package to npm
run: cd common/hogql_parser && npm publish --access public
env:
NODE_AUTH_TOKEN: ''
NPM_CONFIG_PROVENANCE: true