Skip to content

Commit 59c370f

Browse files
committed
Add release CI flows
1 parent 4c7432d commit 59c370f

3 files changed

Lines changed: 79 additions & 21 deletions

File tree

.github/workflows/release-binary.yml renamed to .github/workflows/actions/build-binary.yml

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
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

44
on:
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]
@@ -84,6 +93,7 @@ jobs:
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
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Build and release block-parser binaries to GitHub Releases
2+
name: Release Binary (block-parser)
3+
4+
on:
5+
push:
6+
tags:
7+
- 'comment-block-parser@*'
8+
workflow_dispatch:
9+
inputs:
10+
version:
11+
description: 'Version tag (e.g., comment-block-parser@1.2.0)'
12+
required: true
13+
type: string
14+
15+
jobs:
16+
release:
17+
uses: ./.github/workflows/actions/build-binary.yml
18+
with:
19+
package_path: packages/block-parser
20+
binary_name: block-parser
21+
tag_prefix: 'comment-block-parser@'
22+
version_tag: ${{ inputs.version || github.ref_name }}
23+
permissions:
24+
contents: write
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Build and release md-magic binaries to GitHub Releases
2+
name: Release Binary (md-magic)
3+
4+
on:
5+
push:
6+
tags:
7+
- 'markdown-magic@*'
8+
workflow_dispatch:
9+
inputs:
10+
version:
11+
description: 'Version tag (e.g., markdown-magic@4.0.5)'
12+
required: true
13+
type: string
14+
15+
jobs:
16+
release:
17+
uses: ./.github/workflows/actions/build-binary.yml
18+
with:
19+
package_path: packages/core
20+
binary_name: md-magic
21+
tag_prefix: 'markdown-magic@'
22+
version_tag: ${{ inputs.version || github.ref_name }}
23+
permissions:
24+
contents: write

0 commit comments

Comments
 (0)