-
Notifications
You must be signed in to change notification settings - Fork 2
160 lines (137 loc) · 4.56 KB
/
release-binary.yml
File metadata and controls
160 lines (137 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: release-binary
on:
workflow_dispatch:
push:
tags:
- "v*"
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-latest
target: linux-x64
node-arch: x64
- os: ubuntu-latest
target: linux-arm64
node-arch: arm64
- os: macos-latest
target: darwin-arm64
node-arch: arm64
- os: macos-latest
target: darwin-x64
node-arch: x64
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Create standalone bundle
run: |
mkdir -p release
# Bundle everything into a single file with node shebang
npx esbuild dist/cli.mjs --bundle --platform=node --target=node20 \
--outfile=release/axme-code-${{ matrix.target }} \
--banner:js='#!/usr/bin/env node'
chmod +x release/axme-code-${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: axme-code-${{ matrix.target }}
path: release/axme-code-${{ matrix.target }}
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/*/axme-code-*
generate_release_notes: true
publish-npm:
# Publish @axme/code to npm. We do this in the same workflow as release-binary
# (chained via `needs: release`) instead of a separate `release: published`
# trigger workflow because GitHub Actions does NOT fire workflow events from
# actions taken by GITHUB_TOKEN (anti-recursion safety). When release-binary
# creates the GitHub release via softprops/action-gh-release, no downstream
# workflow listening on `release: published` will run. Chaining via `needs:`
# in the same workflow run avoids that limitation entirely.
needs: release
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Lint
run: npm run lint
- name: Test
run: npm test
- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
sync-plugin-repo:
# Sync plugin bundle to AxmeAI/axme-code-plugin. Same anti-recursion reason:
# if we wait for `release: published` we never run, so we chain on `needs: publish-npm`
# to keep the previous behavior (sync after npm publish succeeds).
needs: publish-npm
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Sync plugin repo
env:
PLUGIN_REPO_TOKEN: ${{ secrets.PLUGIN_REPO_TOKEN }}
run: |
git clone https://x-access-token:${PLUGIN_REPO_TOKEN}@github.com/AxmeAI/axme-code-plugin.git /tmp/plugin-repo
cd /tmp/plugin-repo
# Remove old files (except .git and .gitignore)
ls -A | grep -v '^\.\(git\|gitignore\)$' | xargs rm -rf
# Copy new plugin bundle
cp -r ${GITHUB_WORKSPACE}/dist/plugin/. .
cp ${GITHUB_WORKSPACE}/dist/plugin/.mcp.json .
cp -r ${GITHUB_WORKSPACE}/dist/plugin/.claude-plugin .
# Remove sourcemaps and node_modules (not needed in repo)
rm -f *.map
rm -rf node_modules package-lock.json
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add -A
git commit -m "sync: ${GITHUB_REF_NAME} from axme-code" || echo "No changes to commit"
git push