-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (108 loc) · 3.6 KB
/
release.yml
File metadata and controls
125 lines (108 loc) · 3.6 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
name: Release
on:
push:
branches:
- main
jobs:
# ─── Read version from package.json, bail if the tag already exists ───────
prepare:
name: Prepare
runs-on: ubuntu-latest
outputs:
version: ${{ steps.pkg.outputs.version }}
tag: ${{ steps.pkg.outputs.tag }}
skip: ${{ steps.tag_check.outputs.skip }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: pkg
name: Read version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
- id: tag_check
name: Check for existing tag
run: |
VERSION=$(node -p "require('./package.json').version")
if git ls-remote --tags origin "refs/tags/v$VERSION" | grep -q .; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "Tag v$VERSION already exists — skipping release."
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
# ─── Build platform binaries ──────────────────────────────────────────────
build:
name: Build (${{ matrix.os }})
needs: prepare
if: needs.prepare.outputs.skip == 'false'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Build Mac distributable
if: runner.os == 'macOS'
run: npm run electron:dist
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_IDENTITY_AUTO_DISCOVERY: false
- name: Build Windows distributable
if: runner.os == 'Windows'
shell: bash
run: npx electron-vite build && npx electron-builder --win
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.os }}
path: |
release/*.dmg
release/*.zip
release/*.exe
if-no-files-found: warn
retention-days: 1
# ─── Tag + publish GitHub Release ────────────────────────────────────────
release:
name: Publish Release
needs: [prepare, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download Mac binaries
uses: actions/download-artifact@v4
with:
name: binaries-macos-latest
path: dist-artifacts
continue-on-error: true
- name: Download Windows binaries
uses: actions/download-artifact@v4
with:
name: binaries-windows-latest
path: dist-artifacts
continue-on-error: true
- name: List release assets
run: ls -lh dist-artifacts/ 2>/dev/null || echo "No artifacts downloaded"
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare.outputs.tag }}
name: "MPC Sample ${{ needs.prepare.outputs.tag }}"
generate_release_notes: true
draft: false
prerelease: false
files: dist-artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}