Skip to content

Commit 29a2394

Browse files
authored
Merge pull request #2 from tscircuit/publish
Set up publishing to github packages
1 parent f2f929b commit 29a2394

4 files changed

Lines changed: 152 additions & 3 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
2+
name: Publish to npm
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- '!version-bumps/**'
8+
workflow_dispatch:
9+
10+
env:
11+
UPSTREAM_REPOS: "" # comma-separated list, e.g. "eval,tscircuit,docs"
12+
UPSTREAM_PACKAGES_TO_UPDATE: "" # comma-separated list, e.g. "@tscircuit/core,@tscircuit/protos"
13+
14+
jobs:
15+
publish:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Setup bun
20+
uses: oven-sh/setup-bun@v2
21+
with:
22+
bun-version: latest
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: 20
26+
registry-url: https://registry.npmjs.org/
27+
- run: npm install -g pver
28+
- run: bun install --frozen-lockfile
29+
- run: bun run build
30+
- run: pver release --no-push-main
31+
env:
32+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
33+
GITHUB_TOKEN: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
34+
35+
- name: Get package version
36+
id: package-version
37+
run: |
38+
VERSION=$(node -p "require('./package.json').version")
39+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
40+
41+
42+
- name: Create Pull Request
43+
id: create-pr
44+
uses: peter-evans/create-pull-request@v6
45+
with:
46+
commit-message: "chore: bump version"
47+
title: "chore: bump version to v${{ steps.package-version.outputs.version }}"
48+
body: "Automated package update"
49+
branch: version-bumps/v${{ steps.package-version.outputs.version }}
50+
base: main
51+
token: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
52+
committer: tscircuitbot <githubbot@tscircuit.com>
53+
author: tscircuitbot <githubbot@tscircuit.com>
54+
55+
- name: Enable auto-merge
56+
if: steps.create-pr.outputs.pull-request-number != ''
57+
run: |
58+
gh pr merge ${{ steps.create-pr.outputs.pull-request-number }} --auto --squash --delete-branch
59+
env:
60+
GH_TOKEN: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
61+
62+
- name: Trigger upstream repo updates
63+
if: env.UPSTREAM_REPOS && env.UPSTREAM_PACKAGES_TO_UPDATE
64+
run: |
65+
IFS=',' read -ra REPOS <<< "${{ env.UPSTREAM_REPOS }}"
66+
for repo in "${REPOS[@]}"; do
67+
if [[ -n "$repo" ]]; then
68+
echo "Triggering update for repo: $repo"
69+
curl -X POST \
70+
-H "Accept: application/vnd.github.v3+json" \
71+
-H "Authorization: token ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}" \
72+
-H "Content-Type: application/json" \
73+
"https://api.github.com/repos/tscircuit/$repo/actions/workflows/update-package.yml/dispatches" \
74+
-d "{\"ref\":\"main\",\"inputs\":{\"package_names\":\"${{ env.UPSTREAM_PACKAGES_TO_UPDATE }}\"}}"
75+
fi
76+
done
77+
- name: Notify release-tracker of version update
78+
# Continue-on-error just in case the tracker is down
79+
continue-on-error: true
80+
run: |
81+
VERSION=$(node -p "require('./package.json').version")
82+
PACKAGE_JSON=$(cat package.json)
83+
curl -X POST https://release-tracker.tscircuit.com/release_events/create \
84+
-H "Content-Type: application/json" \
85+
-d "{
86+
\"event\": {
87+
\"event_type\": \"versions_updated\",
88+
\"repo\": \"tscircuit/circuit-json-to-kicad\",
89+
\"version\": \"$VERSION\",
90+
\"package_json\": $PACKAGE_JSON
91+
}
92+
}"

.github/workflows/publish-gpr.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish to GitHub Packages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- publish
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
packages: write
13+
14+
jobs:
15+
publish:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v4
24+
25+
- name: Create Empty Build Directory
26+
run: mkdir -p Docker/build
27+
28+
- name: Build Docker Image
29+
run: docker build --no-cache -t eecircuit ./Docker
30+
31+
- name: Run Docker Container
32+
run: docker run -t -e VERSION=main -v $(realpath ./Docker):/mnt eecircuit
33+
34+
- name: Copy SPICE WASM files
35+
run: |
36+
cp ./Docker/build/spice.wasm ./src/spice.wasm
37+
cp ./Docker/build/spice.js ./src/spice.js
38+
39+
- uses: actions/setup-node@v4
40+
with:
41+
node-version: 20
42+
registry-url: https://npm.pkg.github.com
43+
44+
- run: npm install
45+
46+
- run: npm run build
47+
48+
- run: npm install -g pver
49+
50+
- name: Release to GitHub Packages
51+
run: pver release --no-push-main
52+
env:
53+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "eecircuit-engine",
2+
"name": "@tscircuit/eecircuit-engine",
33
"version": "1.7.0",
44
"description": "EEcircuit's simulation engine",
55
"repository": {
@@ -32,6 +32,9 @@
3232
"test:browser:all": "npx playwright test test/test-browser-regression.spec.mts"
3333
},
3434
"author": "Danial Chitnis",
35+
"publishConfig": {
36+
"registry": "https://npm.pkg.github.com"
37+
},
3538
"license": "MIT",
3639
"devDependencies": {
3740
"@eslint/js": "^10.0.1",

0 commit comments

Comments
 (0)