88 workflow_dispatch : {}
99
1010jobs :
11- build :
12- if : ${{ github.event_name != 'schedule' && github.event_name != 'workflow_dispatch' }}
11+ test :
12+ name : Unit Tests ( ${{ matrix.os }})
1313 strategy :
1414 fail-fast : false
1515 matrix :
1919 runs-on : ${{ matrix.os }}
2020 env :
2121 CI : true
22+ APPLE_SIGN_IDENTITY : ${{ secrets.APPLE_SIGN_IDENTITY }}
2223
2324 steps :
24- - name : Checkout repository (no LFS)
25+ - name : Checkout code (no LFS)
26+ if : ${{ github.event_name == 'schedule' }}
27+ uses : actions/checkout@v3
28+ with :
29+ ref : dev
30+ lfs : false
31+
32+ - name : Checkout code (no LFS)
33+ if : ${{ github.event_name != 'schedule' }}
2534 uses : actions/checkout@v3
2635 with :
2736 lfs : false
4756 choco install git-lfs -y
4857 git lfs install --skip-smudge
4958
59+ # ← Cache all LFS objects between runs
60+ - name : Cache Git LFS objects
61+ uses : actions/cache@v3
62+ with :
63+ path : .git/lfs/objects
64+ key : ${{ runner.os }}-git-lfs-${{ hashFiles('**/.gitattributes') }}
65+ restore-keys : |
66+ ${{ runner.os }}-git-lfs-
67+
5068 # Fetch only the LFS objects you need
5169 - name : Fetch specific LFS folders (non-Windows)
5270 if : runner.os != 'Windows'
@@ -123,20 +141,44 @@ jobs:
123141 reporter : java-junit
124142
125143 nightly_compile :
126- if : ${{ github.event_name == 'schedule' && github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/dev' }}
144+ name : Nightly Build & Artifact Upload (${{ matrix.os }})
145+ needs : test
146+ if : ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
127147 strategy :
128148 fail-fast : false
129149 matrix :
130150 os : [ubuntu-latest, macos-latest, windows-latest]
131151
132152 runs-on : ${{ matrix.os }}
153+ env :
154+ CI : true
155+ APPLE_SIGN_IDENTITY : ${{ secrets.APPLE_SIGN_IDENTITY }}
133156
134157 steps :
135158 - name : Checkout code (no LFS)
159+ if : ${{ github.event_name == 'schedule' }}
136160 uses : actions/checkout@v3
137161 with :
162+ ref : dev
138163 lfs : false
139164
165+ - name : Checkout code (no LFS)
166+ if : ${{ github.event_name != 'schedule' }}
167+ uses : actions/checkout@v3
168+ with :
169+ lfs : false
170+
171+ # Common Python setup + build + test
172+ - name : Set up Python 3.11
173+ uses : actions/setup-python@v4
174+ with :
175+ python-version : ' 3.11'
176+
177+ - name : Install UV CLI
178+ run : |
179+ python -m pip install --upgrade pip
180+ pip install uv
181+
140182 # Install Git LFS and disable auto-smudge on each OS
141183 - name : Install Git LFS & disable auto-smudge (Ubuntu)
142184 if : runner.os == 'Linux'
@@ -158,23 +200,111 @@ jobs:
158200 choco install git-lfs -y
159201 git lfs install --skip-smudge
160202
203+ # ← Cache LFS objects for nightly packaging too
204+ - name : Cache Git LFS objects
205+ uses : actions/cache@v3
206+ with :
207+ path : .git/lfs/objects
208+ key : nightly-${{ runner.os }}-git-lfs-${{ hashFiles('**/.gitattributes') }}
209+ restore-keys : |
210+ nightly-${{ runner.os }}-git-lfs-
211+
161212 - name : Fetch only needed LFS resources
162213 run : |
163214 git lfs fetch --include="packages/open_vp_cal/src/open_vp_cal/resources/**"
164215 git lfs checkout packages/open_vp_cal/src/open_vp_cal/resources/**
165216
166- - name : Run nightly build script
167- shell : bash
217+ - name : Stamp version with date and build ID
218+ shell : python
168219 run : |
169- if [[ "${{ runner.os }}" == "Windows" ]]; then
170- build.bat
171- else
172- chmod +x build.sh
173- ./build.sh
174- fi
175-
176- - name : Upload nightly build artifact
177- uses : actions/upload-artifact@v3
220+ import re, os, pathlib
221+ from datetime import datetime
222+
223+ build_id = os.getenv("GITHUB_SHA", "")[:8] or "local"
224+ date_str = datetime.utcnow().strftime("%d_%m_%Y")
225+
226+ init_py = pathlib.Path("packages/open_vp_cal/src/open_vp_cal/__init__.py")
227+ text = init_py.read_text(encoding="utf8")
228+
229+ # 1: prefix (`__version__ = "`), 2: existing version, 3: closing quote
230+ pattern = re.compile(r'(__version__\s*=\s*")([^"]+)(")')
231+
232+ def add_date_and_build(m):
233+ prefix, version, suffix = m.group(1), m.group(2), m.group(3)
234+ # append +DD_MM_YYYY.BUILDID
235+ return f"{prefix}{version}+{date_str}.{build_id}{suffix}"
236+
237+ new_text = pattern.sub(add_date_and_build, text)
238+ init_py.write_text(new_text, encoding="utf8")
239+
240+ # confirm
241+ ver = re.search(r'__version__\s*=\s*"([^"]+)"', new_text).group(1)
242+ print(f"Bumped version to: {ver}")
243+
244+ # Create a temporary keychain and make it default
245+ - name : Create & unlock keychain
246+ if : runner.os == 'macOS'
247+ run : |
248+ security create-keychain -p "" build.keychain
249+ security default-keychain -s build.keychain
250+ security unlock-keychain -p "" build.keychain
251+
252+ # Decode & import your P12 into that keychain
253+ - name : Import signing certificate
254+ if : runner.os == 'macOS'
255+ run : |
256+ echo "${{ secrets.APPLE_CERTIFICATE_P12 }}" | base64 --decode > cert.p12
257+ security import cert.p12 \
258+ -k ~/Library/Keychains/build.keychain \
259+ -P "${{ secrets.APPLE_CERTIFICATE_PASSWORD }}" \
260+ -T /usr/bin/codesign
261+ security set-key-partition-list \
262+ -S apple-tool:,apple: \
263+ -s -k "" build.keychain
264+
265+ # On Windows, run build.bat via PowerShell
266+ - name : Run Windows Build
267+ if : runner.os == 'Windows'
268+ shell : pwsh
269+ run : .\build.bat
270+
271+ # On macOS/Linux, run build.sh via Bash
272+ - name : Run Build
273+ if : runner.os != 'Windows'
274+ run : |
275+ chmod +x build.sh
276+ ./build.sh
277+
278+ - name : Upload macOS nightly artifact
279+ if : runner.os == 'macOS'
280+ uses : actions/upload-artifact@v4
281+ with :
282+ name : nightly-macos
283+ path : ' ./dist/OpenVPCal-*.dmg'
284+
285+ - name : Upload Windows nightly artifact - Zip
286+ if : runner.os == 'Windows'
287+ uses : actions/upload-artifact@v4
288+ with :
289+ name : nightly-windows-setup
290+ path : ' Output/OpenVPCal*.exe'
291+
292+ - name : Upload Windows nightly artifact - Setup
293+ if : runner.os == 'Windows'
294+ uses : actions/upload-artifact@v4
295+ with :
296+ name : nightly-windows-zip
297+ path : ' Output/OpenVPCal*.zip'
298+
299+
300+ - name : Upload Linux nightly artifact
301+ if : runner.os == 'Linux'
302+ uses : actions/upload-artifact@v4
178303 with :
179- name : nightly-${{ matrix.os }}
180- path : out/nightly-build.tar.gz
304+ name : nightly-linux
305+ path : ' Output/OpenVPCal*.zip'
306+
307+ - name : Delete temporary keychain
308+ if : runner.os == 'macOS'
309+ run : |
310+ security delete-keychain build.keychain
0 commit comments