Skip to content

Commit 6b2f66e

Browse files
authored
Publish unreleased modules on push to main (#4)
1 parent f682aff commit 6b2f66e

File tree

15 files changed

+125
-20
lines changed

15 files changed

+125
-20
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ module.exports = {
77
node: true,
88
},
99
parserOptions: {
10-
project: './tsconfig.json',
10+
project: ['./tsconfig.json', './packages/*/tsconfig.json'],
1111
},
1212
};

.github/actions/setup/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ inputs:
66
description: 'Node.js version to install'
77
default: '18'
88

9+
registry-url:
10+
description: 'Registry URL (required for publish)'
11+
required: false
12+
913
runs:
1014
using: 'composite'
1115
steps:
@@ -16,6 +20,7 @@ runs:
1620
uses: actions/setup-node@v3
1721
with:
1822
node-version: ${{ inputs.node-version }}
23+
registry-url: ${{ inputs.registry-url }}
1924
cache: pnpm
2025

2126
- name: 'Install development dependencies'

.github/workflows/ci.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,38 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v3
16+
1617
- name: 'Install 🔧'
1718
uses: ./.github/actions/setup
19+
1820
- name: 'Run checks ✅'
1921
run: pnpm all
22+
23+
publish:
24+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
25+
needs: [check]
26+
runs-on: ubuntu-latest
27+
permissions:
28+
# write permission required to push tags
29+
contents: write
30+
31+
steps:
32+
- uses: actions/checkout@v3
33+
34+
- name: 'Install 🔧'
35+
uses: ./.github/actions/setup
36+
with:
37+
registry-url: 'https://registry.npmjs.org'
38+
39+
- name: 'Build 🏗️'
40+
run: pnpm build
41+
42+
- name: 'Configure Git for publish 🌴'
43+
run: |
44+
git config user.name github-actions
45+
git config user.email [email protected]
46+
47+
- name: 'Publish packages 🚀'
48+
run: ./scripts/publish.sh
49+
env:
50+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
node_modules
2+
pnpm-publish-summary.json
3+
*.d.cts

README.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
# Viam Shared Web Project Config
2-
3-
Shared configuration for web tooling:
4-
5-
- [ESLint](./packages/eslint-config)
6-
- [Pretter](./packages/prettier-config)
7-
- [TypeScript](./packages/typescript-config)
1+
# Viam Shared JS/TS Config
2+
3+
Shared configuration for JavaScript and TypeScript tools:
4+
5+
| Tool | NPM Module | Version |
6+
| ----------------------------- | --------------------------------- | ----------------------------------------- |
7+
| [ESLint][eslint docs] | `@viamrobotics/eslint-config` | [![eslint version][]][eslint npm] |
8+
| [Prettier][prettier docs] | `@viamrobotics/prettier-config` | [![prettier version][]][prettier npm] |
9+
| [TypeScript][typescript docs] | `@viamrobotics/typescript-config` | [![typescript version][]][typescript npm] |
10+
11+
[eslint docs]: ./packages/eslint-config
12+
[eslint npm]: https://www.npmjs.com/package/@viamrobotics/eslint-config
13+
[eslint version]: https://img.shields.io/npm/v/@viamrobotics/eslint-config?style=flat-square
14+
[prettier docs]: ./packages/prettier-config
15+
[prettier npm]: https://www.npmjs.com/package/@viamrobotics/prettier-config
16+
[prettier version]: https://img.shields.io/npm/v/@viamrobotics/prettier-config?style=flat-square
17+
[typescript docs]: ./packages/typescript-config
18+
[typescript npm]: https://www.npmjs.com/package/@viamrobotics/typescript-config
19+
[typescript version]: https://img.shields.io/npm/v/@viamrobotics/typescript-config?style=flat-square
820

921
## Contributing
1022

@@ -20,7 +32,7 @@ pnpm install
2032
Once your development dependencies are installed, you can verify that all checks and tests are passing:
2133

2234
```shell
23-
# run all checks
35+
# run all checks and builds
2436
pnpm all
2537

2638
# check lints
@@ -32,6 +44,9 @@ pnpm check-types
3244
# check formatting
3345
pnpm check-format
3446

47+
# build all packages
48+
pnpm build
49+
3550
# auto-format (modifies files)
3651
pnpm format
3752
```
@@ -41,4 +56,4 @@ pnpm format
4156

4257
### Releasing
4358

44-
TK
59+
Modules in this repository are continuously deployed to npm from the `main` branch. To trigger a release, create a commit that bumps `version` in one or more `package.json` files and create a pull request to merge that commit into `main`.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
"license": "Apache-2.0",
1010
"type": "module",
1111
"scripts": {
12-
"all": "concurrently -g pnpm:check-*",
12+
"all": "concurrently -g pnpm:check-* pnpm:build",
1313
"check-format": "pnpm run _prettier-base --check",
1414
"check-lint": "eslint \"**/*.@(js|cjs|ts)\"",
1515
"check-types": "tsc",
16+
"build": "pnpm run -r --aggregate-output build",
1617
"format": "pnpm run _prettier-base --write",
1718
"_prettier-base": "prettier \"**/*.@(js|cjs|ts|json|yaml|md)\""
1819
},

packages/eslint-config/package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33
"publishConfig": {
44
"access": "public"
55
},
6-
"version": "0.0.0",
6+
"version": "0.0.1",
77
"description": "Common ESLint configuration for Viam projects.",
8+
"types": "./base.d.cts",
89
"exports": {
9-
".": "./base.cjs"
10+
".": {
11+
"types": "./base.d.cts",
12+
"default": "./base.cjs"
13+
}
14+
},
15+
"scripts": {
16+
"build": "tsc"
1017
},
1118
"repository": {
1219
"type": "git",

packages/eslint-config/tsconfig.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "@viamrobotics/typescript-config",
3+
"compilerOptions": {
4+
"types": ["node"],
5+
"declaration": true,
6+
"emitDeclarationOnly": true
7+
},
8+
"include": ["./**/*.cjs"]
9+
}

packages/prettier-config/package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33
"publishConfig": {
44
"access": "public"
55
},
6-
"version": "0.0.0",
6+
"version": "0.0.1",
77
"description": "Common Prettier configuration for Viam projects.",
8+
"types": "./base.d.cts",
89
"exports": {
9-
".": "./base.cjs",
10-
"./svelte": "./svelte.cjs"
10+
".": {
11+
"types": "./base.d.cts",
12+
"default": "./base.cjs"
13+
}
14+
},
15+
"scripts": {
16+
"build": "tsc"
1117
},
1218
"repository": {
1319
"type": "git",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "@viamrobotics/typescript-config",
3+
"compilerOptions": {
4+
"types": ["node"],
5+
"declaration": true,
6+
"emitDeclarationOnly": true
7+
},
8+
"include": ["./**/*.cjs"]
9+
}

packages/typescript-config/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Shared TypeScript Config for Viam
22

3-
This module contains [Viam][]'s shared [TypeScript][] configurations for TypeScript v5. The main difference between the different configurations is their module resolution strategy.
3+
This module contains [Viam][]'s shared [TypeScript][] configurations for TypeScript v5.
44

55
```shell
66
npm install --save-dev typescript @viamrobotics/typescript-config
@@ -11,7 +11,7 @@ npm install --save-dev typescript @viamrobotics/typescript-config
1111

1212
### Base config
1313

14-
Use the [base config](./base.json) for generic TypeScript projects, including code that runs natively in Node.js or isomorphicaly, in both Node.js and the browser.
14+
Use the [base config](./tsconfig.base.json) for generic TypeScript projects, including code that runs natively in Node.js or isomorphicaly, in both Node.js and the browser.
1515

1616
```json
1717
// tsconfig.json

packages/typescript-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publishConfig": {
44
"access": "public"
55
},
6-
"version": "0.0.0",
6+
"version": "0.0.1",
77
"description": "Common TypeScript configuration for Viam projects.",
88
"exports": {
99
".": "./tsconfig.base.json"

packages/typescript-config/tsconfig.base.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
// use import/export and legacy node resolution logic
4+
"target": "esnext",
45
"module": "esnext",
56
"moduleResolution": "node",
67
"resolveJsonModule": true,

scripts/publish.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# publish all unpublished versions in the workspace
6+
pnpm publish --recursive --report-summary
7+
8+
# read published packages
9+
tags=$(jq -r ".publishedPackages[] | .name + \"@\" + .version" < pnpm-publish-summary.json)
10+
11+
# add a tag for each released version
12+
for tag in ${tags}; do
13+
git tag -a "${tag}" -m "${tag}"
14+
done
15+
16+
# push tags
17+
for tag in ${tags}; do
18+
git push origin "${tag}"
19+
done

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"types": ["node"],
55
"noEmit": true
66
},
7-
"include": ["./.*", "./**/*"]
7+
"include": ["./**/.*"]
88
}

0 commit comments

Comments
 (0)