Skip to content

Commit e80cb2e

Browse files
authored
Merge pull request #853 from danditomaso/ci/publish-workflow-updates
Refactor CI publish workflow and remove Rust support
2 parents cba89ee + 491783b commit e80cb2e

File tree

4 files changed

+205
-76
lines changed

4 files changed

+205
-76
lines changed

.github/workflows/publish.yml

Lines changed: 202 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish to Cargo, JSR, & NPM
1+
name: Publish to JSR & NPM
22

33
on:
44
push:
@@ -10,123 +10,254 @@ on:
1010
description: "Version to publish (e.g. v1.2.3). Used when manually dispatching."
1111
required: false
1212
type: string
13+
dry_run:
14+
description: "Dry run mode - generate artifacts without publishing"
15+
required: false
16+
type: boolean
17+
default: false
1318

14-
permissions: write-all
19+
permissions:
20+
contents: write
21+
id-token: write
1522

1623
jobs:
1724
codegen:
1825
runs-on: ubuntu-24.04
26+
outputs:
27+
version: ${{ steps.version.outputs.VERSION }}
28+
tag: ${{ steps.version.outputs.TAG }}
1929
steps:
2030
- name: Checkout code
2131
uses: actions/checkout@v4
2232
with:
23-
fetch-depth: 0
33+
fetch-depth: 0
2434

25-
- name: Show files exist
26-
run: |
27-
set -euxo pipefail
28-
ls -la packages/ts || true
29-
ls -la packages/rust || true
30-
cat packages/ts/deno.json
31-
cat packages/ts/package.json
32-
cat packages/rust/Cargo.toml
33-
34-
- name: Determine VERSION
35+
- name: Determine version
36+
id: version
3537
run: |
3638
set -euo pipefail
3739
if [ "${{ github.ref_type }}" = "tag" ]; then
38-
VERSION="${{ github.ref_name }}"
40+
TAG="${{ github.ref_name }}"
3941
elif [ -n "${{ inputs.version || '' }}" ]; then
40-
VERSION="${{ inputs.version }}"
42+
TAG="${{ inputs.version }}"
4143
else
4244
echo "No tag ref and no 'version' input. Provide a tag (push a tag) or pass inputs.version." >&2
4345
exit 1
4446
fi
45-
# If you don't want the leading 'v' inside files, strip it:
46-
STRIPPED="${VERSION#v}"
47-
echo "VERSION=$STRIPPED" >> "$GITHUB_ENV"
48-
echo "Resolved VERSION=$STRIPPED"
49-
50-
- name: Set Package Versions to current tag
51-
run: |
52-
set -euxo pipefail
53-
for f in \
54-
packages/ts/deno.json \
55-
packages/ts/package.json \
56-
packages/rust/Cargo.toml
57-
do
58-
test -f "$f" || { echo "Missing $f" >&2; exit 1; }
59-
# replace __PACKAGE_VERSION__ with env VERSION
60-
sed -i "s/__PACKAGE_VERSION__/${VERSION//\//-}/g" "$f"
61-
done
47+
VERSION="${TAG#v}"
48+
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
49+
echo "TAG=$TAG" >> "$GITHUB_OUTPUT"
50+
echo "Resolved VERSION=$VERSION, TAG=$TAG"
6251
6352
- name: Setup Buf
6453
uses: bufbuild/buf-setup-action@main
6554
with:
6655
github_token: ${{ github.token }}
6756

68-
- name: Generate code
57+
- name: Generate protobuf code
6958
run: buf generate
7059

71-
- name: Copy license & README
60+
- name: Move generated files to lib root
7261
run: |
73-
cp LICENSE packages/ts
74-
cp LICENSE packages/rust
75-
cp README.md packages/ts
76-
cp README.md packages/rust
62+
set -euo pipefail
63+
src_dir="packages/ts/lib/meshtastic"
64+
dest_dir="packages/ts/lib"
7765
78-
- name: Upload Rust code
79-
uses: actions/upload-artifact@v4
80-
with:
81-
name: rust_code
82-
path: packages/rust
66+
if [ ! -d "$src_dir" ]; then
67+
echo "Expected source directory '$src_dir' does not exist. 'buf generate' may have failed or changed its output paths." >&2
68+
exit 1
69+
fi
70+
71+
if ! compgen -G "$src_dir"/*_pb.ts > /dev/null; then
72+
echo "No '*_pb.ts' files found in '$src_dir'. 'buf generate' may have produced no TypeScript files or changed their naming." >&2
73+
exit 1
74+
fi
75+
76+
mv "$src_dir"/*_pb.ts "$dest_dir"/
77+
- name: Show generated files
78+
run: |
79+
echo "=== packages/ts contents ==="
80+
ls -la packages/ts/
81+
echo "=== packages/ts/lib contents ==="
82+
ls -la packages/ts/lib/ || echo "lib folder not found"
83+
84+
- name: Set package versions
85+
run: |
86+
set -euo pipefail
87+
VERSION="${{ steps.version.outputs.VERSION }}"
88+
for f in packages/ts/deno.json packages/ts/package.json; do
89+
test -f "$f" || { echo "Missing $f" >&2; exit 1; }
90+
sed -i "s/__PACKAGE_VERSION__/${VERSION}/g" "$f"
91+
done
92+
93+
- name: Copy license & README
94+
run: cp LICENSE README.md packages/ts/
8395

8496
- name: Upload TypeScript code
8597
uses: actions/upload-artifact@v4
8698
with:
8799
name: ts_code
88100
path: packages/ts
89101

90-
- name: Push to schema registry
91-
env:
92-
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
93-
run: |
94-
buf push --tag ${{ github.ref_name }}
95-
96-
publish-jsr:
102+
build-typescript:
97103
runs-on: ubuntu-24.04
98104
needs: codegen
99-
permissions:
100-
contents: read
101-
id-token: write
102105
steps:
103106
- name: Download TypeScript code
104107
uses: actions/download-artifact@v4
105108
with:
106109
name: ts_code
107-
- name: Remove package.json (JSR doesn’t need it)
108-
run: rm -f package.json
109-
- name: Set up Deno
110-
uses: denoland/setup-deno@main
110+
111+
- name: Show downloaded files
112+
run: |
113+
echo "=== Working directory ==="
114+
pwd
115+
echo "=== Contents ==="
116+
ls -la
117+
echo "=== lib/ contents ==="
118+
ls -la lib/ || echo "lib folder not found"
119+
120+
- name: Setup Node.js
121+
uses: actions/setup-node@v4
111122
with:
112-
deno-version: rc
113-
- name: Publish to JSR
114-
run: deno publish --unstable-sloppy-imports
123+
node-version: "22"
115124

116-
publish-cargo:
125+
- name: Install dependencies
126+
run: npm install
127+
128+
- name: Build with tsdown
129+
run: npm run build
130+
131+
- name: Show build output
132+
run: |
133+
echo "=== Build output ==="
134+
ls -la
135+
ls -la dist/
136+
137+
- name: Upload built NPM package
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: npm_package
141+
path: |
142+
dist/
143+
package.json
144+
LICENSE
145+
README.md
146+
147+
- name: Upload JSR package
148+
uses: actions/upload-artifact@v4
149+
with:
150+
name: jsr_package
151+
path: |
152+
lib/
153+
mod.ts
154+
deno.json
155+
LICENSE
156+
README.md
157+
158+
create-release-zips:
159+
runs-on: ubuntu-24.04
160+
needs: [codegen, build-typescript]
161+
steps:
162+
- name: Download NPM package
163+
uses: actions/download-artifact@v4
164+
with:
165+
name: npm_package
166+
path: npm_package
167+
168+
- name: Download JSR package
169+
uses: actions/download-artifact@v4
170+
with:
171+
name: jsr_package
172+
path: jsr_package
173+
174+
- name: Create zip archives
175+
run: |
176+
cd npm_package && zip -r ../meshtastic-protobufs-npm.zip . && cd ..
177+
cd jsr_package && zip -r ../meshtastic-protobufs-jsr.zip . && cd ..
178+
179+
- name: Upload release zips
180+
uses: actions/upload-artifact@v4
181+
with:
182+
name: release_zips
183+
path: |
184+
meshtastic-protobufs-npm.zip
185+
meshtastic-protobufs-jsr.zip
186+
187+
upload-release-assets:
188+
runs-on: ubuntu-24.04
189+
needs: [codegen, create-release-zips]
190+
if: ${{ !inputs.dry_run }}
191+
steps:
192+
- name: Download release zips
193+
uses: actions/download-artifact@v4
194+
with:
195+
name: release_zips
196+
197+
- name: Upload assets to GitHub release
198+
uses: softprops/action-gh-release@v2
199+
with:
200+
tag_name: ${{ needs.codegen.outputs.tag }}
201+
files: |
202+
meshtastic-protobufs-npm.zip
203+
meshtastic-protobufs-jsr.zip
204+
205+
push-buf-registry:
117206
runs-on: ubuntu-24.04
118207
needs: codegen
208+
if: ${{ !inputs.dry_run }}
209+
steps:
210+
- name: Checkout code
211+
uses: actions/checkout@v4
212+
213+
- name: Setup Buf
214+
uses: bufbuild/buf-setup-action@main
215+
with:
216+
github_token: ${{ github.token }}
217+
218+
- name: Push to schema registry
219+
env:
220+
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
221+
run: buf push --tag ${{ needs.codegen.outputs.tag }}
222+
223+
publish-npm:
224+
runs-on: ubuntu-24.04
225+
needs: [codegen, build-typescript]
226+
if: ${{ !inputs.dry_run }}
227+
steps:
228+
- name: Download NPM package
229+
uses: actions/download-artifact@v4
230+
with:
231+
name: npm_package
232+
233+
- name: Setup Node.js
234+
uses: actions/setup-node@v4
235+
with:
236+
node-version: "22"
237+
registry-url: "https://registry.npmjs.org"
238+
239+
- name: Publish to NPM
240+
run: npm publish --access public
241+
env:
242+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
243+
244+
publish-jsr:
245+
runs-on: ubuntu-24.04
246+
needs: [codegen, build-typescript]
247+
if: ${{ !inputs.dry_run }}
248+
permissions:
249+
contents: read
250+
id-token: write
119251
steps:
120-
- name: Download Rust code
252+
- name: Download JSR package
121253
uses: actions/download-artifact@v4
122254
with:
123-
name: rust_code
124-
- name: Set up Rust
125-
uses: actions-rust-lang/setup-rust-toolchain@v1
126-
- name: Check Library
127-
run: cargo check
128-
- name: Publish to crates.io
129-
uses: katyo/publish-crates@v2
255+
name: jsr_package
256+
257+
- name: Setup Node.js
258+
uses: actions/setup-node@v4
130259
with:
131-
registry-token: ${{ secrets.CARGO_TOKEN }}
132-
ignore-unpublished-changes: true
260+
node-version: "22"
261+
262+
- name: Publish to JSR
263+
run: npx jsr publish

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
.DS_Store
2+
3+
# Generated protobuf files
4+
packages/ts/lib/

buf.gen.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,3 @@ plugins:
33
- remote: buf.build/bufbuild/es:v2.1.0
44
out: packages/ts/lib
55
opt: target=ts
6-
- remote: buf.build/community/neoeinstein-prost:v0.4.0
7-
out: packages/rust/src/generated
8-
- remote: buf.build/community/neoeinstein-prost-crate:v0.4.1
9-
out: packages/rust/src/generated
10-
opt: no_features

0 commit comments

Comments
 (0)