Skip to content

Commit 62b55d2

Browse files
authored
Update GitFlow_Nightly-builds.yml
1 parent 2cd59bf commit 62b55d2

1 file changed

Lines changed: 147 additions & 172 deletions

File tree

Lines changed: 147 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -1,172 +1,147 @@
1-
# This workflow creates nightly builds from the develop branch:
2-
# - Checks for merged PRs since the last tag
3-
# - Creates a pre-release version if changes are detected
4-
# - Builds and packages the software
5-
# - Creates GitHub release with artifacts and download counters
6-
7-
name: GitFlow | Nightly Builds
8-
9-
on:
10-
# Automated nightly builds at midnight
11-
schedule:
12-
- cron: "0 0 * * *"
13-
14-
permissions:
15-
contents: write
16-
17-
jobs:
18-
build:
19-
name: Create Nightly Build
20-
runs-on: windows-latest
21-
steps:
22-
# Step 1: Checkout the develop branch for nightly builds
23-
- name: Checkout code
24-
uses: actions/checkout@v4
25-
with:
26-
lfs: "true"
27-
fetch-depth: 0
28-
# Always checkout develop for nightly builds
29-
ref: develop
30-
31-
# Step 2: Verify if a new build is required by checking for merged PRs since last tag
32-
- name: Check for merged PRs since last tag
33-
id: check_prs
34-
shell: powershell
35-
run: |
36-
# Find the latest tag of any type
37-
$LATEST_TAG = git tag --sort=-v:refname | Select-Object -First 1
38-
Write-Host "Latest tag: $LATEST_TAG"
39-
40-
# Get merged PRs since last tag using Git directly
41-
$MERGED_PRS = git log --merges --grep="Merge pull request" --oneline "$LATEST_TAG..develop"
42-
43-
# If merged PRs exist, set BUILD_NEEDED and determine release type
44-
if ($MERGED_PRS) {
45-
Write-Host "Found PRs merged to develop since latest tag:"
46-
Write-Host $MERGED_PRS
47-
echo "BUILD_NEEDED=true" >> $env:GITHUB_OUTPUT
48-
49-
# Determine release type
50-
if ($LATEST_TAG -like "*-*") {
51-
$RELEASE_TYPE = "prerelease"
52-
}
53-
else {
54-
$RELEASE_TYPE = "preminor"
55-
}
56-
echo "RELEASE_TYPE=$RELEASE_TYPE" >> $env:GITHUB_OUTPUT
57-
Write-Host "Next release: $RELEASE_TYPE"
58-
} else {
59-
# If no merged PRs, skip building
60-
Write-Host "No PRs merged to develop since latest tag. Skipping build."
61-
echo "BUILD_NEEDED=false" >> $env:GITHUB_OUTPUT
62-
}
63-
64-
# Step 3: Generate new semantic version number
65-
- name: Auto Increment Semver Action
66-
uses: MCKanpolat/auto-semver-action@5003b8d37f4b03d95f15303ea10242cbf7c13141 # 2
67-
if: steps.check_prs.outputs.BUILD_NEEDED == 'true'
68-
id: versioning
69-
with:
70-
github_token: ${{ secrets.GITHUB_TOKEN }}
71-
incrementPerCommit: false
72-
releaseType: ${{ steps.check_prs.outputs.RELEASE_TYPE }}
73-
74-
# Step 4: Format version numbers for different purposes (SemVer, MSI version)
75-
- name: Format Semver (and MSI version)
76-
if: steps.check_prs.outputs.BUILD_NEEDED == 'true'
77-
id: format_version
78-
shell: powershell
79-
run: |
80-
# Get version from previous step
81-
$NextSemver = "${{ steps.versioning.outputs.version }}"
82-
83-
# Create MSI-compatible version (x.y.z.build)
84-
$commit_count = (git rev-list --count HEAD)
85-
$commit_count_mod = $commit_count % 65535 # MSI has a version limit
86-
$MsiBase = $NextSemver.Split("-")[0] # Remove prerelease segment
87-
$MsiVersion = "$MsiBase.$commit_count_mod"
88-
89-
# Format the release name
90-
$ReleaseName = "WAU $NextSemver [Nightly Build]"
91-
92-
# Output all version information
93-
echo "MSI version: $MsiVersion"
94-
echo "Semver created: $NextSemver"
95-
echo "Release name: $ReleaseName"
96-
echo "MsiVersion=$MsiVersion" >> $env:GITHUB_OUTPUT
97-
echo "NextSemVer=$NextSemver" >> $env:GITHUB_OUTPUT
98-
echo "ReleaseName=$ReleaseName" >> $env:GITHUB_OUTPUT
99-
100-
# Step 5: Build the project and generate artifacts
101-
- name: Build project
102-
if: steps.check_prs.outputs.BUILD_NEEDED == 'true'
103-
id: build_project
104-
shell: powershell
105-
run: |
106-
# Download and install Microsoft Deployment Toolkit
107-
echo "### Get MDT from Microsoft ###"
108-
wget https://download.microsoft.com/download/3/3/9/339BE62D-B4B8-4956-B58D-73C4685FC492/MicrosoftDeploymentToolkit_x64.msi -UseBasicParsing -OutFile .\MicrosoftDeploymentToolkit_x64.msi
109-
Start-Process .\MicrosoftDeploymentToolkit_x64.msi -ArgumentList "/quiet /norestart" -Wait
110-
111-
# Extract ServiceUI for elevated notifications
112-
echo "### Copy ServiceUI.exe x64 to 'Sources\Winget-AutoUpdate' folder ###"
113-
Copy-Item -Path "C:\Program Files\Microsoft Deployment Toolkit\Templates\Distribution\Tools\x64\ServiceUI.exe" -Destination ".\Sources\Winget-AutoUpdate\ServiceUI.exe" -Force
114-
Get-Item .\Sources\Winget-AutoUpdate\*
115-
116-
# Install WiX tools for MSI creation
117-
echo "### Install WiX ###"
118-
dotnet new console
119-
dotnet tool install --global wix --version 5.0.1
120-
wix extension add WixToolset.UI.wixext/5.0.1 -g
121-
wix extension add WixToolset.Util.wixext/5.0.1 -g
122-
123-
# Build MSI package with version information
124-
echo "### Create WAU MSI ###"
125-
cd .\Sources\Wix\
126-
wix build -src build.wxs -ext WixToolset.Util.wixext -ext WixToolset.UI.wixext -out ..\..\WAU.msi -arch x64 -d Version=${{ steps.format_version.outputs.MsiVersion }} -d NextSemVer=${{ steps.format_version.outputs.NextSemVer }} -d Comment="${{ steps.format_version.outputs.ReleaseName }}" -d PreRelease=1
127-
cd ..\..
128-
Get-Item .\WAU.msi
129-
130-
# Calculate MSI file hash for verification
131-
echo "### Get MSI file SHA ###"
132-
$MsiSHA = (Get-FileHash .\WAU.msi).hash
133-
echo " - WAU.msi SHA256: $MsiSHA"
134-
echo "msi_sha=$MsiSHA" >> $env:GITHUB_OUTPUT
135-
136-
# Package ADMX policy templates
137-
echo "### Zip ADMX ###"
138-
Compress-Archive -Path .\Sources\Policies\ADMX -DestinationPath .\WAU_ADMX.zip -Force
139-
Get-Item .\*.zip
140-
141-
# Calculate ADMX package hash for verification
142-
echo "### Get ADMX zip SHA ###"
143-
$ADMXSHA = (Get-FileHash .\WAU_ADMX.zip).hash
144-
echo " - WAU_ADMX.zip SHA256: $ADMXSHA"
145-
echo "admx_sha=$ADMXSHA" >> $env:GITHUB_OUTPUT
146-
147-
# Create installation counter file for tracking installs
148-
echo "### Create install counter file ###"
149-
echo "Install counter file." > WAU_InstallCounter
150-
151-
# Step 6: Create GitHub release with all artifacts
152-
- name: Create release
153-
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
154-
if: steps.check_prs.outputs.BUILD_NEEDED == 'true'
155-
with:
156-
tag: v${{ steps.format_version.outputs.NextSemVer }}
157-
prerelease: true
158-
generateReleaseNotes: true
159-
name: ${{ steps.format_version.outputs.ReleaseName }}
160-
artifacts: "WAU.msi,WAU_ADMX.zip,WAU_InstallCounter"
161-
body: |
162-
This is an **automated nightly build** created from the latest changes in the develop branch.
163-
164-
⚠️ **Warning**: This build may contain unstable features and is intended for testing purposes only.
165-
166-
## Files
167-
|Files|Hash (SHA256)|Downloads|
168-
|---|---|---|
169-
|[WAU.msi](https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v${{ steps.format_version.outputs.NextSemVer }}/WAU.msi) (x64)|`${{ steps.build_project.outputs.msi_sha }}`|<picture>![WAU.msi](https://img.shields.io/github/downloads/Romanitho/Winget-AutoUpdate/v${{ steps.format_version.outputs.NextSemVer }}/WAU.msi?style=flat-square&label=&color=blue)</picture>|
170-
|[WAU_ADMX.zip](https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v${{ steps.format_version.outputs.NextSemVer }}/WAU_ADMX.zip)|`${{ steps.build_project.outputs.admx_sha }}`|<picture>![WAU_ADMX.zip](https://img.shields.io/github/downloads/Romanitho/Winget-AutoUpdate/v${{ steps.format_version.outputs.NextSemVer }}/WAU_ADMX.zip?style=flat-square&label=&color=blue)</picture>|
171-
172-
<picture>![Install counter](https://img.shields.io/github/downloads/Romanitho/Winget-AutoUpdate/v${{ steps.format_version.outputs.NextSemVer }}/WAU_InstallCounter?style=flat-square&label=Total%20reported%20installations%20for%20this%20release&color=blue)</picture>
1+
# Step 1: Checkout the develop branch for nightly builds
2+
- name: Checkout code
3+
uses: actions/checkout@v4.2.2
4+
with:
5+
fetch-depth: 0
6+
# Always checkout develop for nightly builds
7+
ref: develop
8+
9+
# Vérifier la branche active après le checkout
10+
- name: Vérifier la branche active après checkout
11+
run: echo "Branche active après checkout: $(git branch --show-current)"
12+
13+
# Step 2: Verify if a new build is required by checking for merged PRs since last tag
14+
- name: Check for merged PRs since last tag
15+
id: check_prs
16+
shell: powershell
17+
run: |
18+
# Find the latest tag of any type
19+
$LATEST_TAG = git tag --sort=-v:refname | Select-Object -First 1
20+
Write-Host "Latest tag: $LATEST_TAG"
21+
22+
# Get merged PRs since last tag using Git directly
23+
$MERGED_PRS = git log --merges --grep="Merge pull request" --oneline "$LATEST_TAG..develop"
24+
25+
# If merged PRs exist, set BUILD_NEEDED and determine release type
26+
if ($MERGED_PRS) {
27+
Write-Host "Found PRs merged to develop since latest tag:"
28+
Write-Host $MERGED_PRS
29+
echo "BUILD_NEEDED=true" >> $env:GITHUB_OUTPUT
30+
31+
# Determine release type
32+
if ($LATEST_TAG -like "*-*") {
33+
$RELEASE_TYPE = "prerelease"
34+
}
35+
else {
36+
$RELEASE_TYPE = "preminor"
37+
}
38+
echo "RELEASE_TYPE=$RELEASE_TYPE" >> $env:GITHUB_OUTPUT
39+
Write-Host "Next release: $RELEASE_TYPE"
40+
} else {
41+
# If no merged PRs, skip building
42+
Write-Host "No PRs merged to develop since latest tag. Skipping build."
43+
echo "BUILD_NEEDED=false" >> $env:GITHUB_OUTPUT
44+
}
45+
46+
# Vérifier la branche active après la vérification des PRs
47+
- name: Vérifier la branche active après la vérification des PRs
48+
run: echo "Branche active après la vérification des PRs: $(git branch --show-current)"
49+
50+
# Step 3: Generate new semantic version number
51+
- name: Auto Increment Semver Action
52+
uses: MCKanpolat/auto-semver-action@5003b8d37f4b03d95f15303ea10242cbf7c13141 # 2
53+
if: steps.check_prs.outputs.BUILD_NEEDED == 'true'
54+
id: versioning
55+
with:
56+
github_token: ${{ secrets.GITHUB_TOKEN }}
57+
incrementPerCommit: true
58+
releaseType: ${{ steps.check_prs.outputs.RELEASE_TYPE }}
59+
60+
# Vérifier la branche active après l'incrémentation de la version
61+
- name: Vérifier la branche active après l'incrémentation de la version
62+
run: echo "Branche active après l'incrémentation de la version: $(git branch --show-current)"
63+
64+
# Step 4: Format version numbers for different purposes (SemVer, MSI version)
65+
- name: Format Semver (and MSI version)
66+
if: steps.check_prs.outputs.BUILD_NEEDED == 'true'
67+
id: format_version
68+
shell: powershell
69+
run: |
70+
# Get version from previous step
71+
$NextSemver = "${{ steps.versioning.outputs.version }}"
72+
73+
# Create MSI-compatible version (x.y.z.build)
74+
$commit_count = (git rev-list --count HEAD)
75+
$commit_count_mod = $commit_count % 65535 # MSI has a version limit
76+
$MsiBase = $NextSemver.Split("-")[0] # Remove prerelease segment
77+
$MsiVersion = "$MsiBase.$commit_count_mod"
78+
79+
# Format the release name
80+
$ReleaseName = "WAU $NextSemver [Nightly Build]"
81+
82+
# Output all version information
83+
echo "MSI version: $MsiVersion"
84+
echo "Semver created: $NextSemver"
85+
echo "Release name: $ReleaseName"
86+
echo "MsiVersion=$MsiVersion" >> $env:GITHUB_OUTPUT
87+
echo "NextSemVer=$NextSemver" >> $env:GITHUB_OUTPUT
88+
echo "ReleaseName=$ReleaseName" >> $env:GITHUB_OUTPUT
89+
90+
# Vérifier la branche active après le formatage de la version
91+
- name: Vérifier la branche active après le formatage de la version
92+
run: echo "Branche active après le formatage de la version: $(git branch --show-current)"
93+
94+
# Step 5: Build the project and generate artifacts
95+
- name: Build project
96+
if: steps.check_prs.outputs.BUILD_NEEDED == 'true'
97+
id: build_project
98+
shell: powershell
99+
run: |
100+
# Download and install Microsoft Deployment Toolkit
101+
echo "### Get MDT from Microsoft ###"
102+
wget https://download.microsoft.com/download/3/3/9/339BE62D-B4B8-4956-B58D-73C4685FC492/MicrosoftDeploymentToolkit_x64.msi -UseBasicParsing -OutFile .\MicrosoftDeploymentToolkit_x64.msi
103+
Start-Process .\MicrosoftDeploymentToolkit_x64.msi -ArgumentList "/quiet /norestart" -Wait
104+
105+
# Extract ServiceUI for elevated notifications
106+
echo "### Copy ServiceUI.exe x64 to 'Sources\Winget-AutoUpdate' folder ###"
107+
Copy-Item -Path "C:\Program Files\Microsoft Deployment Toolkit\Templates\Distribution\Tools\x64\ServiceUI.exe" -Destination ".\Sources\Winget-AutoUpdate\ServiceUI.exe" -Force
108+
Get-Item .\Sources\Winget-AutoUpdate\*
109+
110+
# Install WiX tools for MSI creation
111+
echo "### Install WiX ###"
112+
dotnet new console
113+
dotnet tool install --global wix --version 5.0.1
114+
wix extension add WixToolset.UI.wixext/5.0.1 -g
115+
wix extension add WixToolset.Util.wixext/5.0.1 -g
116+
117+
# Build MSI package with version information
118+
echo "### Create WAU MSI ###"
119+
cd .\Sources\Wix\
120+
wix build -src build.wxs -ext WixToolset.Util.wixext -ext WixToolset.UI.wixext -out ..\..\WAU.msi -arch x64 -d Version=${{ steps.format_version.outputs.MsiVersion }} -d NextSemVer=${{ steps.format_version.outputs.NextSemVer }}
121+
cd ..\..
122+
Get-Item .\WAU.msi
123+
124+
# Calculate MSI file hash for verification
125+
echo "### Get MSI file SHA ###"
126+
$MsiSHA = (Get-FileHash .\WAU.msi).hash
127+
echo " - WAU.msi SHA256: $MsiSHA"
128+
echo "msi_sha=$MsiSHA" >> $env:GITHUB_OUTPUT
129+
130+
# Package ADMX policy templates
131+
echo "### Zip ADMX ###"
132+
Compress-Archive -Path .\Sources\Policies\ADMX -DestinationPath .\WAU_ADMX.zip -Force
133+
Get-Item .\*.zip
134+
135+
# Calculate ADMX package hash for verification
136+
echo "### Get ADMX zip SHA ###"
137+
$ADMXSHA = (Get-FileHash .\WAU_ADMX.zip).hash
138+
echo " - WAU_ADMX.zip SHA256: $ADMXSHA"
139+
echo "admx_sha=$ADMXSHA" >> $env:GITHUB_OUTPUT
140+
141+
# Create installation counter file for tracking installs
142+
echo "### Create install counter file ###"
143+
echo "Install counter file." > WAU_InstallCounter
144+
145+
# Vérifier la branche active après la construction du projet
146+
- name: Vérifier la branche active après la construction du projet
147+
run: echo "Branche active après la construction du projet: $(git branch --show-current)"

0 commit comments

Comments
 (0)