Skip to content

Commit 4031230

Browse files
authored
Main shared configs release (#77)
* use script commands as const * stricter typing for commands * lint * fix output returning undefined * isValidPackage accepts FullPackageName for pkg * call pnpm package * uses trsted-publishers * add release tag in CI * add getPackageJson() helper * add version handling to releases. * add additional error handling for versions * handle root package * handle root package * clean up dependencies * update dependencies * add esm as a template type * update readme examples * also tag shared-configs * re-add tags on main * create github release on release * @instructure.ai/shared-configs v1.1.0 * add explicit permissions * explicit permissions * fix release logic
1 parent 8f4f7ee commit 4031230

21 files changed

+953
-1534
lines changed

.changeset/README.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

.changeset/config.json

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
name: Publish Package
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
tags:
9+
- '@instructure.ai/*@*.*.*'
10+
11+
permissions:
12+
id-token: write
13+
contents: read
14+
15+
jobs:
16+
publish:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Exclude shared-configs tags
20+
run: |
21+
if [[ "${GITHUB_REF_NAME}" == @instructure.ai/shared-configs*@* ]]; then
22+
echo "Tag matches excluded pattern (@instructure.ai/shared-configs). Skipping publish."
23+
exit 0
24+
fi
25+
- uses: actions/checkout@v4
26+
27+
- uses: actions/setup-node@v4
28+
with:
29+
node-version: '24'
30+
registry-url: 'https://registry.npmjs.org'
31+
32+
- name: Update npm
33+
run: npm install -g npm@latest
34+
- run: npm ci
35+
- run: npm run build --if-present
36+
- run: npm test
37+
- run: npm publish
38+
39+
- name: Create GitHub Release
40+
uses: softprops/action-gh-release@v1
41+
with:
42+
tag_name: ${{ github.ref_name }}
43+
name: Release ${{ github.ref_name }}
44+
draft: false
45+
prerelease: false
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
name: retag-on-merge
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
retag:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up Git user
17+
run: |
18+
git config user.name "github-actions[bot]"
19+
git config user.email "github-actions[bot]@users.noreply.github.com"
20+
- name: Retag all changed packages
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
run: |
24+
for pkgjson in $(git diff --name-only HEAD~1 HEAD | grep -E '^(package.json|packages/.*/package.json)$'); do
25+
NAME=$(jq -r .name $pkgjson)
26+
VERSION=$(jq -r .version $pkgjson)
27+
TAG="${NAME}@${VERSION}"
28+
git tag -f $TAG
29+
git push --force origin $TAG
30+
done

.github/workflows/tag-release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Tag on Merge
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
tag:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Git user
18+
run: |
19+
git config user.name "github-actions[bot]"
20+
git config user.email "github-actions[bot]@users.noreply.github.com"
21+
22+
- name: Tag changed packages and root
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
run: |
26+
# Tag changed packages
27+
for pkg in $(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep 'packages/.*/package.json' | xargs -n1 dirname); do
28+
NAME=$(jq -r .name $pkg/package.json)
29+
VERSION=$(jq -r .version $pkg/package.json)
30+
TAG="${NAME}@${VERSION}"
31+
git tag $TAG
32+
git push origin $TAG
33+
done
34+
35+
# Tag root package if changed
36+
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^package.json$'; then
37+
NAME=$(jq -r .name package.json)
38+
VERSION=$(jq -r .version package.json)
39+
TAG="${NAME}@${VERSION}"
40+
git tag $TAG
41+
git push origin $TAG
42+
fi

.template/esm/package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "<<packagename>>",
3+
"version": "0.0.0",
4+
"type": "module",
5+
"main": "dist/index.mjs",
6+
"types": "dist/index.d.ts",
7+
"exports": {
8+
".": {
9+
"import": "./dist/index.mjs",
10+
"types": "./dist/index.d.ts"
11+
}
12+
},
13+
"files": ["dist"],
14+
"scripts": {
15+
"build": "vite build",
16+
"typecheck": "tsgo --noEmit",
17+
"lint": "pnpm biome check",
18+
"<<cliname>>": "vite-node ./dist/index.mjs"
19+
},
20+
"bin": {
21+
"<<cliname>>": "./dist/index.mjs"
22+
},
23+
"devDependencies": {
24+
"@instructure.ai/shared-configs": "workspace:^"
25+
}
26+
}

.template/esm/src/index.mts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env node
2+
3+
const main = async () => {
4+
console.log('Hello World!');
5+
};
6+
7+
main().catch((e) => {throw new Error(e)});

.template/esm/tsconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "ESNext",
5+
"moduleResolution": "Node",
6+
"outDir": "dist",
7+
"rootDir": "src",
8+
"esModuleInterop": true,
9+
"forceConsistentCasingInFileNames": true,
10+
"strict": true,
11+
"skipLibCheck": true
12+
},
13+
"extends": "../../tsconfig.json",
14+
"include": ["src"]
15+
}

.template/esm/vite.config.mts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import baseConfig from "@instructure.ai/shared-configs/esm";
2+
import { defineConfig, mergeConfig } from "vite";
3+
4+
export default mergeConfig(baseConfig, defineConfig({}));

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
This is a monorepo of apps and packages. Apps are served on [instructure.ai](https://instructure.ai)
77

8-
Configs and dev dependencies are shared from the root package `@instructure.ai/shared-configs` and extended in workspace packages in `apps` and `/packages`.
8+
Configs and dev dependencies are shared from the root package `@instructure.ai/shared-configs` and extended in workspace packages in `/apps` and `/packages`.
99

1010
Helper utilities are provided for adding and managing packages.
1111

1212
```shell
13-
pnpm new <packagename> [--template (default: vanilla | react | instui)] [--type (default: app | package)]
13+
pnpm new <packagename> [--template (default: vanilla | react | instui | esm)]
1414
```
1515

1616
Will instantiate a new vanillajs or react project with all configurations set up under `./<apps|packages>/<packagename>`
@@ -40,6 +40,7 @@ What comes out of the box?
4040

4141
* vite (vanilla-ts, react-ts)
4242
* vite-node
43+
* vite-plugin-dts
4344
* vitest
4445
* biomejs
4546
* typescript-native

0 commit comments

Comments
 (0)