1- # Build and release md-magic binaries to GitHub Releases
2- name : Release Binary
1+ # Reusable workflow for building and releasing Bun binaries
2+ name : Build Binary
33
44on :
5- push :
6- tags :
7- - ' markdown-magic@*'
8- workflow_dispatch :
5+ workflow_call :
96 inputs :
10- version :
7+ package_path :
8+ description : ' Path to package (e.g., packages/core)'
9+ required : true
10+ type : string
11+ binary_name :
12+ description : ' Binary name prefix (e.g., md-magic)'
13+ required : true
14+ type : string
15+ tag_prefix :
16+ description : ' Tag prefix for version extraction (e.g., markdown-magic@)'
17+ required : true
18+ type : string
19+ version_tag :
1120 description : ' Version tag (e.g., markdown-magic@4.0.5)'
1221 required : true
1322 type : string
@@ -36,21 +45,21 @@ jobs:
3645
3746 - name : Build binaries
3847 run : |
39- cd packages/core
48+ cd ${{ inputs.package_path }}
4049 mkdir -p dist
4150 for target in $(echo "${{ matrix.targets }}" | tr ',' ' '); do
42- echo "Building md-magic -$target..."
51+ echo "Building ${{ inputs.binary_name }} -$target..."
4352 bun build ./cli.js --compile --minify \
4453 --target=bun-$target \
45- --outfile dist/md-magic -$target
54+ --outfile dist/${{ inputs.binary_name }} -$target
4655 done
4756 ls -la dist/
4857
4958 - name : Upload artifacts
5059 uses : actions/upload-artifact@v4
5160 with :
52- name : binaries-${{ matrix.os }}
53- path : packages/core/ dist/md-magic -*
61+ name : binaries-${{ inputs.binary_name }}-${{ matrix.os }}
62+ path : ${{ inputs.package_path }}/ dist/${{ inputs.binary_name }} -*
5463
5564 build-windows :
5665 runs-on : windows-latest
@@ -66,16 +75,16 @@ jobs:
6675 - name : Build Windows binary
6776 shell : bash
6877 run : |
69- cd packages/core
78+ cd ${{ inputs.package_path }}
7079 mkdir -p dist
71- bun build ./cli.js --compile --minify --target=bun-windows-x64 --outfile dist/md-magic -windows-x64.exe
80+ bun build ./cli.js --compile --minify --target=bun-windows-x64 --outfile dist/${{ inputs.binary_name }} -windows-x64.exe
7281 ls dist/
7382
7483 - name : Upload artifacts
7584 uses : actions/upload-artifact@v4
7685 with :
77- name : binaries-windows
78- path : packages/core/ dist/md-magic -*
86+ name : binaries-${{ inputs.binary_name }}- windows
87+ path : ${{ inputs.package_path }}/ dist/${{ inputs.binary_name }} -*
7988
8089 release :
8190 needs : [build, build-windows]
8493 - name : Download all artifacts
8594 uses : actions/download-artifact@v4
8695 with :
96+ pattern : binaries-${{ inputs.binary_name }}-*
8797 path : dist
8898 merge-multiple : true
8999
@@ -93,24 +103,24 @@ jobs:
93103 - name : Create checksums
94104 run : |
95105 cd dist
96- sha256sum md-magic -* > checksums.txt
106+ sha256sum ${{ inputs.binary_name }} -* > checksums.txt
97107 cat checksums.txt
98108
99109 - name : Get version
100110 id : version
101111 run : |
102- TAG="${{ inputs.version || github.ref_name }}"
103- VERSION="${TAG#markdown-magic@ }"
112+ TAG="${{ inputs.version_tag }}"
113+ VERSION="${TAG#${{ inputs.tag_prefix }} }"
104114 echo "tag=$TAG" >> $GITHUB_OUTPUT
105115 echo "version=$VERSION" >> $GITHUB_OUTPUT
106116
107117 - name : Create Release
108118 uses : softprops/action-gh-release@v2
109119 with :
110120 tag_name : ${{ steps.version.outputs.tag }}
111- name : md-magic v${{ steps.version.outputs.version }}
121+ name : ${{ inputs.binary_name }} v${{ steps.version.outputs.version }}
112122 files : |
113- dist/md-magic -*
123+ dist/${{ inputs.binary_name }} -*
114124 dist/checksums.txt
115125 generate_release_notes : true
116126 draft : false
0 commit comments