forked from MrLesk/Backlog.md
-
Notifications
You must be signed in to change notification settings - Fork 0
215 lines (209 loc) · 7.29 KB
/
Copy pathrelease.yml
File metadata and controls
215 lines (209 loc) · 7.29 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: Release multi-platform executables
on:
push:
tags: ['v*.*.*']
permissions:
contents: write
id-token: write
jobs:
build:
name: build-${{ matrix.target }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: bun-linux-x64
- os: ubuntu-latest
target: bun-linux-arm64
- os: macos-latest
target: bun-darwin-x64
- os: macos-latest
target: bun-darwin-arm64
- os: windows-latest
target: bun-windows-x64
runs-on: ${{ matrix.os }}
env:
BIN: backlog-bin${{ contains(matrix.target,'windows') && '.exe' || '' }}
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- uses: actions/cache@v4
id: cache
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-${{ matrix.target }}-bun-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-bun-
- run: bun install --frozen-lockfile
- name: Sync version to tag
shell: bash
run: |
TAG="${GITHUB_REF##refs/tags/v}"
jq ".version = \"$TAG\"" package.json > tmp.json && mv tmp.json package.json
- name: Compile standalone binary
shell: bash
run: |
mkdir -p dist
bun build src/cli.ts --compile --minify --target=${{ matrix.target }} --define __EMBEDDED_VERSION__="\"${GITHUB_REF##refs/tags/v}\"" --outfile=dist/${{ env.BIN }}
- name: Make binary executable (non-Windows)
if: ${{ !contains(matrix.target,'windows') }}
run: chmod +x "dist/${{ env.BIN }}"
- name: Check build output and move binary
shell: bash
run: |
echo "Contents of dist/:"
ls -la dist/
echo "Moving dist/${{ env.BIN }} to ${{ env.BIN }}"
mv dist/${{ env.BIN }} ${{ env.BIN }}
echo "Final binary size:"
ls -lh ${{ env.BIN }}
- uses: actions/upload-artifact@v4
with:
name: backlog-${{ matrix.target }}
path: ${{ env.BIN }}
npm-publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Prepare npm package
shell: bash
run: |
mkdir -p dist
cp scripts/cli.cjs dist/cli.js
cp scripts/resolveBinary.cjs dist/resolveBinary.cjs
cp scripts/postuninstall.cjs dist/postuninstall.cjs
chmod +x dist/cli.js
- name: Create npm-ready package.json
shell: bash
run: |
TAG="${GITHUB_REF##refs/tags/v}"
jq 'del(.devDependencies,.scripts.prepare,.scripts.preinstall,.type) |
.version = "'$TAG'" |
.bin = {backlog:"cli.js"} |
.files = ["cli.js","resolveBinary.cjs","postuninstall.cjs","package.json","README.md","LICENSE"] |
.scripts = {"postuninstall": "node postuninstall.cjs"} |
.optionalDependencies = {
"backlog.md-linux-x64" : "'$TAG'",
"backlog.md-linux-arm64": "'$TAG'",
"backlog.md-darwin-x64" : "'$TAG'",
"backlog.md-darwin-arm64": "'$TAG'",
"backlog.md-windows-x64": "'$TAG'"
}' package.json > dist/package.json
cp LICENSE README.md dist/ 2>/dev/null || true
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
- name: Publish to npm
run: |
cd dist
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
publish-binaries:
needs: [build, npm-publish]
strategy:
matrix:
include:
- target: bun-linux-x64
package: backlog.md-linux-x64
os: linux
cpu: x64
- target: bun-linux-arm64
package: backlog.md-linux-arm64
os: linux
cpu: arm64
- target: bun-darwin-x64
package: backlog.md-darwin-x64
os: darwin
cpu: x64
- target: bun-darwin-arm64
package: backlog.md-darwin-arm64
os: darwin
cpu: arm64
- target: bun-windows-x64
package: backlog.md-windows-x64
os: win32
cpu: x64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: backlog-${{ matrix.target }}
timeout-minutes: 15
- name: Prepare package
shell: bash
run: |
TAG="${GITHUB_REF##refs/tags/v}"
mkdir -p pkg
# Rename the binary to the expected name
if [[ -f backlog-bin.exe ]]; then
mv backlog-bin.exe pkg/backlog.exe
elif [[ -f backlog-bin ]]; then
mv backlog-bin pkg/backlog
else
echo "Error: No binary found"
ls -la
exit 1
fi
cp LICENSE README.md pkg/ 2>/dev/null || true
cat <<EOF > pkg/package.json
{
"name": "${{ matrix.package }}",
"version": "${TAG}",
"os": ["${{ matrix.os }}"],
"cpu": ["${{ matrix.cpu }}"],
"bin": {"backlog": "backlog${{ contains(matrix.target,'windows') && '.exe' || '' }}"},
"files": ["backlog${{ contains(matrix.target,'windows') && '.exe' || '' }}","package.json","LICENSE"]
}
EOF
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
- name: Publish platform package
run: |
cd pkg
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
github-release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: release-assets
timeout-minutes: 15
- name: Rename binaries for release
run: |
echo "=== Debug: Downloaded artifacts ==="
find release-assets -type f -exec ls -lh {} \;
echo "=== Processing artifacts ==="
mkdir -p binaries
for dir in release-assets/*/; do
if [ -d "$dir" ]; then
target=$(basename "$dir" | sed 's/backlog-//')
echo "Processing target: $target"
echo "Directory contents:"
ls -la "$dir"
binary=$(find "$dir" -name "backlog-bin*" -type f)
if [ -n "$binary" ]; then
echo "Found binary: $binary ($(ls -lh "$binary" | awk '{print $5}'))"
if [[ "$target" == *"windows"* ]] && [[ "$binary" == *".exe" ]]; then
cp "$binary" "binaries/backlog-${target}.exe"
echo "Copied to binaries/backlog-${target}.exe ($(ls -lh "binaries/backlog-${target}.exe" | awk '{print $5}'))"
else
cp "$binary" "binaries/backlog-${target}"
echo "Copied to binaries/backlog-${target} ($(ls -lh "binaries/backlog-${target}" | awk '{print $5}'))"
fi
fi
fi
done
echo "=== Final binaries ==="
ls -lh binaries/
- uses: softprops/action-gh-release@v1
with:
files: binaries/*