Skip to content

Commit cfb78a5

Browse files
authored
Merge pull request #2 from byrdsandbytes/feature/build-workflow
Feature/build workflow
2 parents 0811516 + 67abbcd commit cfb78a5

File tree

8 files changed

+165
-17
lines changed

8 files changed

+165
-17
lines changed

.github/workflows/build.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths-ignore:
7+
- '*.md'
8+
- 'docs/**'
9+
pull_request:
10+
branches: [ main ]
11+
paths-ignore:
12+
- '*.md'
13+
- 'docs/**'
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
19+
strategy:
20+
matrix:
21+
node-version: [22.x]
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Node.js ${{ matrix.node-version }}
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: ${{ matrix.node-version }}
31+
cache: 'npm'
32+
33+
- name: Install dependencies
34+
run: npm ci
35+
36+
- name: Run linting
37+
run: npm run lint --if-present
38+
39+
- name: Run tests
40+
run: npm test --if-present
41+
42+
- name: Build project
43+
run: npm run build
44+
45+
- name: Check TypeScript compilation
46+
run: npx tsc --noEmit
47+
48+
- name: Upload build artifacts
49+
if: matrix.node-version == '22.x'
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: dist-files
53+
path: dist/
54+
retention-days: 30

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Install Test
2+
3+
on:
4+
schedule:
5+
# Test installation weekly to ensure it works from GitHub
6+
- cron: '0 0 * * 0'
7+
workflow_dispatch:
8+
9+
jobs:
10+
install-test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Create test project
15+
run: |
16+
mkdir test-install
17+
cd test-install
18+
npm init -y
19+
20+
- name: Test installation from GitHub
21+
run: |
22+
cd test-install
23+
npm install byrdsandbytes/capacitor-zeroconf
24+
25+
- name: Verify package can be imported
26+
run: |
27+
cd test-install
28+
node -e "
29+
try {
30+
const { ZeroConf } = require('capacitor-zeroconf');
31+
console.log('✅ Package imported successfully');
32+
console.log('ZeroConf plugin:', typeof ZeroConf);
33+
} catch (error) {
34+
console.error('❌ Failed to import:', error.message);
35+
process.exit(1);
36+
}
37+
"

.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '22.x'
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Build project
31+
run: npm run build
32+
33+
- name: Run tests
34+
run: npm test --if-present
35+
36+
- name: Create GitHub Release
37+
id: create_release
38+
uses: actions/create-release@v1
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
with:
42+
tag_name: ${{ github.ref }}
43+
release_name: Release ${{ github.ref }}
44+
body: |
45+
See the [README](https://github.com/byrdsandbytes/capacitor-zeroconf/blob/main/README.md) for usage examples.
46+
draft: false
47+
prerelease: false
48+
49+
- name: Zip dist folder
50+
run: zip -r dist.zip dist/
51+
52+
- name: Upload build artifacts to release
53+
uses: actions/upload-release-asset@v1
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
with:
57+
upload_url: ${{ steps.create_release.outputs.upload_url }}
58+
asset_path: ./dist.zip
59+
asset_name: dist.zip
60+
asset_content_type: application/zip

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# node files
2+
dist
23
node_modules
34

45
# iOS files

README.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,6 @@ yarn add byrdsandbytes/capacitor-zeroconf
3737
yarn cap sync
3838
```
3939

40-
**Note:** If you get TypeScript errors like "Cannot find module 'capacitor-zeroconf'", this means the package wasn't built when installed from GitHub. You can either:
41-
42-
1. **Recommended:** Install a specific release tag:
43-
```bash
44-
npm install byrdsandbytes/capacitor-zeroconf#v7.0.0
45-
```
46-
47-
2. **Or** manually build after installation:
48-
```bash
49-
cd node_modules/capacitor-zeroconf
50-
npm run build
51-
```
5240

5341
## Quick Start
5442

@@ -334,7 +322,9 @@ Actions that can occur during service discovery
334322

335323
Construct a type with a set of properties K of type T
336324

337-
<code>{ [P in K]: T; }</code>
325+
<code>{
326+
[P in K]: T;
327+
}</code>
338328

339329

340330
#### ZeroConfWatchCallback

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "capacitor-zeroconf",
3-
"version": "7.0.0",
3+
"version": "7.0.1",
44
"description": "Capacitor ZeroConf plugin",
55
"main": "dist/plugin.cjs.js",
66
"module": "dist/esm/index.js",
@@ -49,7 +49,8 @@
4949
"build-electron": "tsc --project electron/tsconfig.json && rollup -c electron/rollup.config.mjs && rimraf ./electron/build",
5050
"clean": "rimraf ./dist",
5151
"watch": "tsc --watch",
52-
"prepublishOnly": "yarn build"
52+
"prepublishOnly": "yarn build",
53+
"postinstall": "npm run build"
5354
},
5455
"devDependencies": {
5556
"@capacitor/android": "^7.0.0",

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,11 @@ fs.realpath@^1.0.0:
10161016
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
10171017
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==
10181018

1019+
fsevents@~2.3.2:
1020+
version "2.3.3"
1021+
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz"
1022+
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
1023+
10191024
function-bind@^1.1.1:
10201025
version "1.1.1"
10211026
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz"

0 commit comments

Comments
 (0)