Skip to content

Commit 1218001

Browse files
authored
Merge pull request #6 from typetorch/claude/project-thread-63pea2
CI: publish to npm from a version tag
2 parents 347a79e + 5a13cef commit 1218001

2 files changed

Lines changed: 65 additions & 1 deletion

File tree

‎.github/workflows/publish.yml‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Publishes @typetorch/framework to npm when a version tag is pushed:
2+
# npm version <x.y.z> -m "release %s" && git push origin main --follow-tags
3+
# The tag must match package.json. `npm publish` runs prepublishOnly (a clean `rbxtsc --type package` into out/) first.
4+
# Auth: npm trusted publishing (on npmjs.com, @typetorch/framework > Settings > Trusted publishing: this repo, workflow
5+
# publish.yml, environment npm), or an NPM_TOKEN secret (an automation token) on this repo until that is set up.
6+
# Same flow as typetorch/cli. A prerelease version (x.y.z-next.0) goes to the "next" dist-tag; anything else to
7+
# "latest".
8+
name: Publish
9+
10+
on:
11+
push:
12+
tags: ["v*"]
13+
14+
permissions:
15+
contents: write # the GitHub release
16+
id-token: write # npm provenance and trusted publishing
17+
18+
concurrency:
19+
group: publish
20+
cancel-in-progress: false
21+
22+
jobs:
23+
publish:
24+
runs-on: ubuntu-latest
25+
environment: npm
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: oven-sh/setup-bun@v2
29+
with:
30+
bun-version: 1.4.2
31+
- name: Dependencies
32+
run: bun install --frozen-lockfile
33+
- uses: actions/setup-node@v4
34+
with:
35+
node-version: 22
36+
registry-url: https://registry.npmjs.org
37+
- name: npm 11.5+ (trusted publishing)
38+
run: npm install -g npm@^11.5.1
39+
- name: The tag, package.json and npm agree
40+
id: version
41+
run: |
42+
set -euo pipefail
43+
version=$(node -p "require('./package.json').version")
44+
name=$(node -p "require('./package.json').name")
45+
if [ "${GITHUB_REF_NAME}" != "v${version}" ]; then
46+
echo "::error::tag ${GITHUB_REF_NAME} but package.json is ${version}"
47+
exit 1
48+
fi
49+
if npm view "${name}@${version}" version >/dev/null 2>&1; then
50+
echo "::error::${name}@${version} is already on npm"
51+
exit 1
52+
fi
53+
tag=latest
54+
case "$version" in *-*) tag=next ;; esac
55+
echo "version=${version}" >> "$GITHUB_OUTPUT"
56+
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
57+
- name: Publish
58+
run: npm publish --provenance --access public --tag "${{ steps.version.outputs.tag }}"
59+
env:
60+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
61+
- name: GitHub release
62+
run: gh release create "${GITHUB_REF_NAME}" --title "${GITHUB_REF_NAME}" --generate-notes ${{ steps.version.outputs.tag == 'next' && '--prerelease' || '' }}
63+
env:
64+
GH_TOKEN: ${{ github.token }}

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@typetorch/framework",
3-
"version": "0.5.4",
3+
"version": "0.5.5",
44
"description": "TypeTorch framework for roblox-ts: hot-swappable modules (dependency injection, lifecycle, troves), guarded networking, hot assets and the in-game dev menu. Ships inside every TypeTorch artifact.",
55
"license": "MIT",
66
"author": "TypeTorch",

0 commit comments

Comments
 (0)