@@ -11,18 +11,31 @@ jobs:
1111 runs-on : ubuntu-latest
1212 outputs :
1313 should_build : ${{ steps.check.outputs.should_build }}
14+ is_release : ${{ steps.check.outputs.is_release }}
15+ build_timestamp : ${{ steps.check.outputs.build_timestamp }}
1416 steps :
15- - name : Check commit/PR message for 'build'
17+ - name : Check commit/PR message for 'build' or 'release'
1618 id : check
1719 env :
1820 COMMIT_MSG : ${{ github.event.head_commit.message }}
1921 PR_TITLE : ${{ github.event.pull_request.title }}
2022 run : |
2123 MSG=$(echo "${COMMIT_MSG}${PR_TITLE}" | tr '[:upper:]' '[:lower:]')
22- if [[ "$MSG" == build* ]]; then
24+
25+ # Generate a single unified timestamp (Eastern Time)
26+ export TZ='America/New_York'
27+ TS=$(date +'%Y-%m-%d_%H%M')
28+ echo "build_timestamp=$TS" >> $GITHUB_OUTPUT
29+
30+ if [[ "$MSG" == release* ]]; then
31+ echo "should_build=true" >> $GITHUB_OUTPUT
32+ echo "is_release=true" >> $GITHUB_OUTPUT
33+ elif [[ "$MSG" == build* ]]; then
2334 echo "should_build=true" >> $GITHUB_OUTPUT
35+ echo "is_release=false" >> $GITHUB_OUTPUT
2436 else
2537 echo "should_build=false" >> $GITHUB_OUTPUT
38+ echo "is_release=false" >> $GITHUB_OUTPUT
2639 fi
2740
2841 build-linux :
5164 - name : Build with PyInstaller
5265 run : |
5366 export TZ='America/New_York'
54- TS=$(date +'%Y-%m-%d_%H%M')
67+ TS="${{ needs.check-trigger.outputs.build_timestamp }}"
68+ # Use the provided timestamp if set by the trigger, otherwise fallback to now (for older triggers that might not supply it)
69+ if [ -z "$TS" ]; then TS=$(date +'%Y-%m-%d_%H%M'); fi
5570 BUILD_DATE=$(date +'%Y-%m-%d %H:%M EST')
5671 echo "Built: $BUILD_DATE" > version.txt
5772 echo "Archive: ${TS}_PyCronVideoAlarm_Linux" >> version.txt
@@ -100,9 +115,10 @@ jobs:
100115
101116 - name : Build with PyInstaller
102117 run : |
118+ $ts = "${{ needs.check-trigger.outputs.build_timestamp }}"
119+ if ([string]::IsNullOrEmpty($ts)) { $ts = $(Get-Date).ToString('yyyy-MM-dd_HHmm') }
103120 $tz = [System.TimeZoneInfo]::FindSystemTimeZoneById("Eastern Standard Time")
104121 $est = [System.TimeZoneInfo]::ConvertTimeFromUtc((Get-Date).ToUniversalTime(), $tz)
105- $ts = $est.ToString('yyyy-MM-dd_HHmm')
106122 "Built: $($est.ToString('yyyy-MM-dd HH:mm')) EST" | Out-File -FilePath version.txt -Encoding utf8
107123 "Archive: ${ts}_PyCronVideoAlarm_Windows.exe" | Add-Content -Path version.txt -Encoding utf8
108124
@@ -130,3 +146,104 @@ jobs:
130146 with :
131147 name : PyCronVideoAlarm_Windows
132148 path : dist/PyCronVideoAlarm_Windows.exe
149+
150+ create-release :
151+ runs-on : ubuntu-latest
152+ needs : [check-trigger, build-linux, build-windows]
153+ if : needs.check-trigger.outputs.is_release == 'true'
154+ permissions :
155+ contents : write
156+ steps :
157+ - name : Checkout code
158+ uses : actions/checkout@v3
159+
160+ - name : Download all artifacts
161+ uses : actions/download-artifact@v4
162+ with :
163+ path : release_artifacts
164+
165+ - name : Create Multi-Platform Portable Bundle
166+ run : |
167+ mkdir -p SuperPortable/portablevideoalarm
168+
169+ # Intelligent Media Finder: Checks root and subfolders, case-insensitive
170+ # 1. Look for sequences
171+ if [ -d sequences ]; then cp -r sequences SuperPortable/portablevideoalarm/;
172+ elif [ -d PortableVideoAlarm/sequences ]; then cp -r PortableVideoAlarm/sequences SuperPortable/portablevideoalarm/;
173+ elif [ -d portablevideoalarm/sequences ]; then cp -r portablevideoalarm/sequences SuperPortable/portablevideoalarm/;
174+ else mkdir -p SuperPortable/portablevideoalarm/sequences; fi
175+
176+ # 2. Look for audio
177+ if [ -d audio ]; then cp -r audio SuperPortable/portablevideoalarm/;
178+ elif [ -d PortableVideoAlarm/audio ]; then cp -r PortableVideoAlarm/audio SuperPortable/portablevideoalarm/;
179+ elif [ -d portablevideoalarm/audio ]; then cp -r portablevideoalarm/audio SuperPortable/portablevideoalarm/;
180+ else mkdir -p SuperPortable/portablevideoalarm/audio; fi
181+
182+ # 3. Look for video
183+ if [ -d video ]; then cp -r video SuperPortable/portablevideoalarm/;
184+ elif [ -d PortableVideoAlarm/video ]; then cp -r PortableVideoAlarm/video SuperPortable/portablevideoalarm/;
185+ elif [ -d portablevideoalarm/video ]; then cp -r portablevideoalarm/video SuperPortable/portablevideoalarm/;
186+ else mkdir -p SuperPortable/portablevideoalarm/video; fi
187+
188+ # Copy executables into the unified folder
189+ cp release_artifacts/PyCronVideoAlarm_Linux/PyCronVideoAlarm_Linux SuperPortable/portablevideoalarm/
190+ cp release_artifacts/PyCronVideoAlarm_Windows/PyCronVideoAlarm_Windows.exe SuperPortable/portablevideoalarm/
191+
192+ # Include LICENSE
193+ cp LICENSE SuperPortable/portablevideoalarm/
194+
195+ # Create a helper README for the portable pack
196+ echo "PyCron Video Alarm - Super Portable Pack" > SuperPortable/portablevideoalarm/README_Portable.txt
197+ echo "==========================================" >> SuperPortable/portablevideoalarm/README_Portable.txt
198+ echo "This folder contains executables for Linux and Windows." >> SuperPortable/portablevideoalarm/README_Portable.txt
199+ echo "" >> SuperPortable/portablevideoalarm/README_Portable.txt
200+ echo "1. Run the version for your OS." >> SuperPortable/portablevideoalarm/README_Portable.txt
201+ echo "2. Your settings, logs, and media will be stored in this shared folder." >> SuperPortable/portablevideoalarm/README_Portable.txt
202+
203+ cd SuperPortable
204+ zip -r ../PyCronVideoAlarm_MultiPlatform_Portable.zip portablevideoalarm
205+
206+ - name : Prepare Assets for Release
207+ run : |
208+ mkdir staging
209+ cp release_artifacts/PyCronVideoAlarm_Linux/PyCronVideoAlarm_Linux staging/
210+ cp release_artifacts/PyCronVideoAlarm_Windows/PyCronVideoAlarm_Windows.exe staging/
211+ cp PyCronVideoAlarm_MultiPlatform_Portable.zip staging/
212+
213+ - name : Generate Release Info
214+ id : release_info
215+ run : |
216+ DATE_DISPLAY=$(date +'%Y-%m-%d %H:%M EST')
217+ DATE_STR="${{ needs.check-trigger.outputs.build_timestamp }}"
218+ SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
219+
220+ MSG="${{ github.event.head_commit.message }}"
221+ # Strip the first word "release" and any leading colon/space/dash
222+ CLEAN_MSG=$(echo "$MSG" | sed -E 's/^release[:[:space:]-]*//i' | tr -d '\n' | tr -s ' ')
223+
224+ echo "tag=v${DATE_STR}" >> $GITHUB_OUTPUT
225+ echo "title=${DATE_STR} ${CLEAN_MSG}" >> $GITHUB_OUTPUT
226+ echo "date_display=${DATE_DISPLAY}" >> $GITHUB_OUTPUT
227+ echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
228+
229+ - name : Create GitHub Release
230+ uses : softprops/action-gh-release@v1
231+ with :
232+ tag_name : ${{ steps.release_info.outputs.tag }}
233+ name : ${{ steps.release_info.outputs.title }}
234+ files : |
235+ staging/PyCronVideoAlarm_Linux
236+ staging/PyCronVideoAlarm_Windows.exe
237+ staging/PyCronVideoAlarm_MultiPlatform_Portable.zip
238+ body : |
239+ Automated Multi-Platform Release
240+
241+ **Release Date:** ${{ steps.release_info.outputs.date_display }}
242+ **Commit Hash:** ${{ steps.release_info.outputs.short_sha }}
243+
244+ Included Files:
245+ - **PyCronVideoAlarm_Linux**: Linux standalone binary
246+ - **PyCronVideoAlarm_Windows.exe**: Windows standalone executable
247+ - **PyCronVideoAlarm_MultiPlatform_Portable.zip**: All-in-one pack with shared media directories. (download this if this is your first time using the app)
248+ env :
249+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments