Skip to content

Commit 2dd007a

Browse files
Merge pull request #19 from quantfive/github-packages-setup
GitHub packages setup
2 parents f0a1628 + 197cf35 commit 2dd007a

File tree

4 files changed

+156
-76
lines changed

4 files changed

+156
-76
lines changed

.github/workflows/build-and-deploy.yml

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

.github/workflows/codepress-review.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ name: CodePress Review
33
on:
44
pull_request:
55
types: [opened, reopened]
6+
workflow_dispatch: # Allows manual triggering from the Actions tab
67

78
permissions:
89
pull-requests: write
910
contents: read
11+
issues: read # Required to read PR comments
1012

1113
jobs:
1214
ai-review:
1315
runs-on: ubuntu-latest
16+
# Run on: PR events, manual triggers, or PR comments containing '@codepress/review'
1417
steps:
1518
- name: Checkout code
1619
uses: actions/checkout@v4
@@ -22,7 +25,7 @@ jobs:
2225
with:
2326
github_token: ${{ secrets.GITHUB_TOKEN }}
2427
model_provider: "openai"
25-
model_name: "gpt-5-mini"
28+
model_name: "o4-mini"
2629
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
2730
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
2831
gemini_api_key: ${{ secrets.GEMINI_API_KEY }}

.github/workflows/release.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Release and Publish
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
env:
13+
NODE_VERSION: "20"
14+
REGISTRY_URL: "https://npm.pkg.github.com"
15+
SCOPE: "@quantfive"
16+
17+
jobs:
18+
check-version:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: read
23+
outputs:
24+
version_changed: ${{ steps.version_check.outputs.changed }}
25+
new_version: ${{ steps.version_check.outputs.version }}
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
# Scope registry to @quantfive so public deps still come from npmjs.org
33+
- name: Setup Node (scoped registry)
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: ${{ env.NODE_VERSION }}
37+
cache: npm
38+
registry-url: ${{ env.REGISTRY_URL }}
39+
scope: ${{ env.SCOPE }}
40+
41+
- name: Install dependencies
42+
run: npm ci
43+
env:
44+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Check if version should be published
47+
id: version_check
48+
env:
49+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
run: |
51+
CURRENT_VERSION=$(node -p "require('./package.json').version")
52+
LATEST_PUBLISHED=$(npm view @quantfive/codepress-engine version 2>/dev/null || echo "0.0.0")
53+
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
54+
echo "latest_published=$LATEST_PUBLISHED" >> $GITHUB_OUTPUT
55+
56+
if [ "$CURRENT_VERSION" != "$LATEST_PUBLISHED" ]; then
57+
echo "changed=true" >> $GITHUB_OUTPUT
58+
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
59+
else
60+
echo "changed=false" >> $GITHUB_OUTPUT
61+
fi
62+
63+
build-and-publish:
64+
needs: check-version
65+
if: needs.check-version.outputs.version_changed == 'true'
66+
runs-on: ubuntu-latest
67+
permissions:
68+
contents: write
69+
packages: write
70+
steps:
71+
- name: Checkout
72+
uses: actions/checkout@v4
73+
74+
- name: Setup Node (scoped registry)
75+
uses: actions/setup-node@v4
76+
with:
77+
node-version: ${{ env.NODE_VERSION }}
78+
cache: npm
79+
registry-url: ${{ env.REGISTRY_URL }}
80+
scope: ${{ env.SCOPE }}
81+
82+
- name: Setup Rust (stable + WASI)
83+
uses: dtolnay/rust-toolchain@stable
84+
with:
85+
targets: wasm32-wasip1
86+
87+
- name: Install deps
88+
run: npm ci
89+
env:
90+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
92+
- name: Build JS
93+
run: npm run build
94+
95+
- name: Build Rust WASM plugin
96+
run: npm run build:rust
97+
98+
# Optional: verify the pack contents before publishing
99+
- name: Dry-run pack
100+
run: npm pack --dry-run
101+
102+
# Race safety: re-check just before publish
103+
- name: Ensure version not yet published
104+
id: recheck
105+
env:
106+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
run: |
108+
CURRENT_VERSION=$(node -p "require('./package.json').version")
109+
FOUND=$(npm view @quantfive/codepress-engine versions --json | node -e "let a=JSON.parse(require('fs').readFileSync(0,'utf8'));console.log(a.includes(process.argv[1]))" "$CURRENT_VERSION")
110+
if [ "$FOUND" = "true" ]; then
111+
echo "already=true" >> $GITHUB_OUTPUT
112+
else
113+
echo "already=false" >> $GITHUB_OUTPUT
114+
fi
115+
116+
- name: Publish to GitHub Packages
117+
if: steps.recheck.outputs.already == 'false'
118+
run: npm publish
119+
env:
120+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121+
122+
- name: Create Git tag (after successful publish)
123+
if: steps.recheck.outputs.already == 'false'
124+
run: |
125+
VERSION=${{ needs.check-version.outputs.new_version }}
126+
git config --local user.email "[email protected]"
127+
git config --local user.name "GitHub Action"
128+
git tag -a "v$VERSION" -m "Release v$VERSION"
129+
git push origin "v$VERSION"
130+
131+
- name: Create GitHub Release
132+
uses: softprops/action-gh-release@v2
133+
with:
134+
tag_name: v${{ needs.check-version.outputs.new_version }}
135+
name: Release v${{ needs.check-version.outputs.new_version }}
136+
generate_release_notes: true
137+
env:
138+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@quantfive/codepress-engine",
3-
"version": "0.3.0",
3+
"version": "0.3.9",
44
"description": "CodePress engine - Babel and SWC plug-ins",
55
"main": "./babel/index.js",
66
"exports": {
@@ -25,7 +25,11 @@
2525
"build": "babel src --out-dir dist --copy-files",
2626
"build:rust": "mkdir -p swc && cargo build --release --target wasm32-wasip1 --manifest-path codepress-swc-plugin/Cargo.toml && cp codepress-swc-plugin/target/wasm32-wasip1/release/codepress_swc_plugin.wasm swc/codepress_engine.wasm",
2727
"test": "jest",
28-
"dev:link": "npm run build && npm run build:rust && npm link"
28+
"dev:link": "npm run build && npm run build:rust && npm link",
29+
"prepublishOnly": "npm run build && npm run build:rust",
30+
"version:patch": "npm version patch",
31+
"version:minor": "npm version minor",
32+
"version:major": "npm version major"
2933
},
3034
"keywords": [
3135
"babel",
@@ -36,6 +40,14 @@
3640
],
3741
"author": "",
3842
"license": "MIT",
43+
"repository": {
44+
"type": "git",
45+
"url": "git+https://github.com/quantfive/codepress-engine.git"
46+
},
47+
"publishConfig": {
48+
"registry": "https://npm.pkg.github.com",
49+
"access": "restricted"
50+
},
3951
"peerDependencies": {
4052
"@babel/core": "^7.0.0"
4153
},

0 commit comments

Comments
 (0)