Repository navigation
186 lines (157 loc) · 5.91 KB
/
Copy pathrelease.yml
File metadata and controls
186 lines (157 loc) · 5.91 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
build:
name: Build for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
name: ccline-88cc-linux-x64.tar.gz
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
name: ccline-88cc-linux-x64-static.tar.gz
- target: x86_64-pc-windows-gnu
os: ubuntu-latest
name: ccline-88cc-windows-x64.zip
- target: x86_64-apple-darwin
os: macos-latest
name: ccline-88cc-macos-x64.tar.gz
- target: aarch64-apple-darwin
os: macos-latest
name: ccline-88cc-macos-arm64.tar.gz
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools
if: matrix.target == 'x86_64-pc-windows-gnu'
run: |
sudo apt-get update
sudo apt-get install -y mingw-w64
- name: Install musl tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Build binary
run: cargo build --release --target ${{ matrix.target }}
- name: Package Linux/macOS
if: matrix.os != 'windows-latest' && matrix.target != 'x86_64-pc-windows-gnu'
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/ccline-88cc dist/ccline-88cc
cd dist
tar czf ../${{ matrix.name }} ccline-88cc
- name: Package Windows
if: matrix.target == 'x86_64-pc-windows-gnu'
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/ccline-88cc.exe dist/ccline-88cc.exe
cd dist
zip ../${{ matrix.name }} ccline-88cc.exe
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: ${{ matrix.name }}
release:
name: Create Release
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/*/*
generate_release_notes: true
draft: false
prerelease: false
- name: Setup Node.js for NPM
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Extract binaries from archives
run: |
mkdir -p extracted
# macOS x64
tar -xzf artifacts/ccline-88cc-macos-x64.tar.gz/ccline-88cc-macos-x64.tar.gz -C extracted
mv extracted/ccline-88cc extracted/ccline-88cc-darwin-x64
# macOS ARM64
tar -xzf artifacts/ccline-88cc-macos-arm64.tar.gz/ccline-88cc-macos-arm64.tar.gz -C extracted
mv extracted/ccline-88cc extracted/ccline-88cc-darwin-arm64
# Linux x64
tar -xzf artifacts/ccline-88cc-linux-x64.tar.gz/ccline-88cc-linux-x64.tar.gz -C extracted
mv extracted/ccline-88cc extracted/ccline-88cc-linux-x64
# Linux musl (static)
tar -xzf artifacts/ccline-88cc-linux-x64-static.tar.gz/ccline-88cc-linux-x64-static.tar.gz -C extracted
mv extracted/ccline-88cc extracted/ccline-88cc-linux-x64-musl
# Windows
unzip artifacts/ccline-88cc-windows-x64.zip/ccline-88cc-windows-x64.zip -d extracted
mv extracted/ccline-88cc.exe extracted/ccline-88cc-win32-x64.exe
# List extracted files
ls -la extracted/
- name: Prepare NPM packages
run: |
# Prepare packages with version management
node npm/scripts/prepare-packages.js
# Copy binaries to platform directories
cp extracted/ccline-88cc-darwin-x64 npm-publish/darwin-x64/ccline-88cc
cp extracted/ccline-88cc-darwin-arm64 npm-publish/darwin-arm64/ccline-88cc
cp extracted/ccline-88cc-linux-x64 npm-publish/linux-x64/ccline-88cc
cp extracted/ccline-88cc-linux-x64-musl npm-publish/linux-x64-musl/ccline-88cc
cp extracted/ccline-88cc-win32-x64.exe npm-publish/win32-x64/ccline-88cc.exe
# Set executable permissions for Unix binaries
chmod +x npm-publish/darwin-x64/ccline-88cc
chmod +x npm-publish/darwin-arm64/ccline-88cc
chmod +x npm-publish/linux-x64/ccline-88cc
chmod +x npm-publish/linux-x64-musl/ccline-88cc
# Verify packages
echo "Package structure:"
find npm-publish -name "package.json" -exec echo "=== {} ===" \; -exec head -5 {} \;
- name: Publish platform packages to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
# Publish platform packages first
for platform in darwin-x64 darwin-arm64 linux-x64 linux-x64-musl win32-x64; do
echo "📦 Publishing @byebyecode/ccline-88cc-$platform"
cd npm-publish/$platform
npm publish --access public
cd ../..
echo "✅ Published @byebyecode/ccline-88cc-$platform"
done
- name: Wait for NPM registry
run: |
echo "⏳ Waiting for platform packages to be available on NPM..."
sleep 30
- name: Publish main package to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cd npm-publish/main
echo "📦 Publishing @byebyecode/ccline-88cc"
npm publish --access public
echo "✅ Published @byebyecode/ccline-88cc"
echo ""
echo "🎉 NPM packages published successfully!"
echo "Install with: npm install -g @byebyecode/ccline-88cc"