Skip to content

Commit 76fcb90

Browse files
committed
build release
1 parent a1eedc3 commit 76fcb90

File tree

1 file changed

+79
-2
lines changed

1 file changed

+79
-2
lines changed

.github/workflows/prebuild.yml

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
pull_request:
99
branches: [n_api, master]
1010
workflow_dispatch: # Allow manual triggering
11+
inputs:
12+
release_tag:
13+
description: 'Release tag to upload prebuilds to (e.g., v5.0.0)'
14+
required: false
15+
type: string
1116

1217
jobs:
1318
prebuild-node:
@@ -86,9 +91,27 @@ jobs:
8691
Write-Host "prebuilds directory not found"
8792
}
8893
94+
- name: Debug GitHub ref
95+
run: |
96+
echo "GitHub ref: ${{ github.ref }}"
97+
echo "Is tag: ${{ startsWith(github.ref, 'refs/tags/') }}"
98+
echo "GitHub event name: ${{ github.event_name }}"
99+
89100
- name: Upload to GitHub Release
90101
if: startsWith(github.ref, 'refs/tags/')
91-
run: npx prebuild --upload-all
102+
run: |
103+
echo "Uploading prebuilds to GitHub release..."
104+
echo "Current tag: ${{ github.ref_name }}"
105+
npx prebuild --upload-all --tag-prefix v
106+
env:
107+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108+
109+
# Alternative: Upload to a specific release when running manually
110+
- name: Upload to Specific Release (Manual)
111+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag != ''
112+
run: |
113+
echo "Uploading prebuilds to release: ${{ github.event.inputs.release_tag }}"
114+
npx prebuild --upload-all --tag-prefix v --target ${{ github.event.inputs.release_tag }}
92115
env:
93116
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94117

@@ -164,9 +187,27 @@ jobs:
164187
Write-Host "prebuilds directory not found"
165188
}
166189
190+
- name: Debug GitHub ref (Electron)
191+
run: |
192+
echo "GitHub ref: ${{ github.ref }}"
193+
echo "Is tag: ${{ startsWith(github.ref, 'refs/tags/') }}"
194+
echo "GitHub event name: ${{ github.event_name }}"
195+
167196
- name: Upload to GitHub Release
168197
if: startsWith(github.ref, 'refs/tags/')
169-
run: npx prebuild -r electron --upload-all
198+
run: |
199+
echo "Uploading Electron prebuilds to GitHub release..."
200+
echo "Current tag: ${{ github.ref_name }}"
201+
npx prebuild -r electron --upload-all --tag-prefix v
202+
env:
203+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
204+
205+
# Alternative: Upload to a specific release when running manually
206+
- name: Upload to Specific Release (Manual)
207+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag != ''
208+
run: |
209+
echo "Uploading Electron prebuilds to release: ${{ github.event.inputs.release_tag }}"
210+
npx prebuild -r electron --upload-all --tag-prefix v --target ${{ github.event.inputs.release_tag }}
170211
env:
171212
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
172213

@@ -198,3 +239,39 @@ jobs:
198239
run: |
199240
TOTAL=$(find prebuilds-artifacts -name "*.node" -o -name "*.tar.gz" | wc -l)
200241
echo "Total prebuilds created: $TOTAL"
242+
243+
# Upload to existing release when manually triggered with a release tag
244+
- name: Upload to Existing Release
245+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag != ''
246+
env:
247+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
248+
run: |
249+
echo "Uploading prebuilds to existing release: ${{ github.event.inputs.release_tag }}"
250+
251+
# Create a temporary directory and copy all tar.gz files
252+
mkdir -p upload-staging
253+
find prebuilds-artifacts -name "*.tar.gz" -exec cp {} upload-staging/ \;
254+
255+
# Upload each file to the release
256+
cd upload-staging
257+
for file in *.tar.gz; do
258+
echo "Uploading $file..."
259+
gh release upload "${{ github.event.inputs.release_tag }}" "$file" --clobber
260+
done
261+
262+
# Create a draft release for testing (when no release tag specified)
263+
- name: Create Draft Release with Prebuilds
264+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag == ''
265+
uses: softprops/action-gh-release@v1
266+
with:
267+
draft: true
268+
tag_name: test-${{ github.run_number }}
269+
name: Test Release ${{ github.run_number }}
270+
files: prebuilds-artifacts/**/*.tar.gz
271+
body: |
272+
This is a test release created by workflow run #${{ github.run_number }}.
273+
274+
## Prebuilds included:
275+
- Node.js versions: 20, 22, 23, 24
276+
- Electron versions: 32, 33, 34, 35, 36
277+
- Platforms: Windows, Linux, macOS

0 commit comments

Comments
 (0)