WAU - Auto Create Pre-Release Version #167
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: WAU - Auto Create Pre-Release Version | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
permissions: | |
contents: write | |
jobs: | |
check_merged: | |
name: Compare latest merge and tag | |
runs-on: ubuntu-latest | |
outputs: | |
should_run: ${{ steps.should_run.outputs.SHOULD_RUN }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Check if latest merged is older than latest tag | |
id: should_run | |
run: | | |
echo "Latest tag:" | |
git log --tags --pretty="%ci - %h - %s %d" -n 1 | |
LATEST_TAG_DATE=$(git log --tags -n 1 --pretty="%ct") | |
echo $LATEST_TAG_DATE | |
echo "Latest merge:" | |
git log --merges --pretty="%ci - %h - %s %d" -n 1 | |
LATEST_MERGE_DATE=$(git log --merges -n 1 --pretty="%ct") | |
echo $LATEST_MERGE_DATE | |
if [[ $LATEST_MERGE_DATE -gt $LATEST_TAG_DATE ]]; then | |
echo "Latest tag is older than latest merge. Nightly will be created." | |
echo "SHOULD_RUN=true" >> $GITHUB_OUTPUT | |
else | |
echo "Latest merge is not older than latest tag. No new release needed." | |
echo "SHOULD_RUN=false" >> $GITHUB_OUTPUT | |
fi | |
build: | |
name: Create Release Asset | |
needs: [check_merged] | |
if: ${{ needs.check_merged.outputs.should_run == 'true' }} | |
runs-on: windows-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
lfs: "true" | |
fetch-depth: 0 | |
- name: Auto Increment Semver Action | |
uses: MCKanpolat/auto-semver-action@5003b8d37f4b03d95f15303ea10242cbf7c13141 # 1.0.11 | |
id: versioning | |
with: | |
releaseType: patch | |
incrementPerCommit: false | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Next Release Number | |
id: WAU_version | |
run: | | |
echo "Next Release version: ${{ steps.versioning.outputs.version }}" | |
- name: Build project | |
shell: powershell | |
run: | | |
echo "### Get MDT from Microsoft ###" | |
wget https://download.microsoft.com/download/3/3/9/339BE62D-B4B8-4956-B58D-73C4685FC492/MicrosoftDeploymentToolkit_x64.msi -UseBasicParsing -OutFile .\MicrosoftDeploymentToolkit_x64.msi | |
Start-Process .\MicrosoftDeploymentToolkit_x64.msi -ArgumentList "/quiet /norestart" -Wait | |
echo "### Copy ServiceUI.exe x64 to 'Sources\Winget-AutoUpdate' folder ###" | |
Copy-Item -Path "C:\Program Files\Microsoft Deployment Toolkit\Templates\Distribution\Tools\x64\ServiceUI.exe" -Destination ".\Sources\Winget-AutoUpdate\ServiceUI.exe" -Force | |
Get-Item .\Sources\Winget-AutoUpdate\* | |
echo "### Install WiX" | |
dotnet new console | |
dotnet tool install --global wix --version 5.0.1 | |
wix extension add WixToolset.UI.wixext/5.0.1 -g | |
wix extension add WixToolset.Util.wixext/5.0.1 -g | |
echo "### Create WAU msi ###" | |
cd .\Sources\Wix\ | |
wix build -src build.wxs -ext WixToolset.Util.wixext -ext WixToolset.UI.wixext -out ..\..\WAU.msi -arch x64 -d Version=${{ steps.versioning.outputs.version }} -d Comment=NIGHTLY -d PreRelease=1 | |
cd ..\.. | |
Get-Item .\WAU.msi | |
echo "### Get MSI file SHA ###" | |
$MsiSHA = (Get-FileHash .\WAU.msi).hash | |
echo " - WAU.msi SHA256: $MsiSHA" | |
echo "MSI_SHA=$MsiSHA" >> $env:GITHUB_ENV | |
echo "### Zip ADMX ###" | |
Compress-Archive -Path .\Sources\Policies\ADMX -DestinationPath .\WAU_ADMX.zip -Force | |
Get-Item .\*.zip | |
echo "### Get ADMX zip SHA ###" | |
$ADMXSHA = (Get-FileHash .\WAU_ADMX.zip).hash | |
echo " - WAU_ADMX.zip SHA256: $ADMXSHA" | |
echo "ADMX_SHA=$ADMXSHA" >> $env:GITHUB_ENV | |
echo "### Create install counter file ###" | |
echo "Install counter file." > WAU_InstallCounter | |
- name: Create release | |
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 | |
id: release | |
with: | |
tag: "v${{ steps.versioning.outputs.version }}" | |
prerelease: true | |
generateReleaseNotes: true | |
name: "v${{ steps.versioning.outputs.version }} [Nightly Build]" | |
artifacts: "WAU.msi,WAU_ADMX.zip,WAU_InstallCounter" | |
body: | | |
|Files|Hash (SHA256)|Downloads| | |
|---|---|---| | |
|[WAU.msi](https://github.com/Romanitho/WAU-MSI/releases/download/v${{ steps.versioning.outputs.version }}/WAU.msi) (x64)|${{ env.MSI_SHA }}|<picture>![WAU](https://img.shields.io/github/downloads/Romanitho/WAU-MSI/v${{ steps.versioning.outputs.version }}/WAU.msi?style=flat-square&label=&color=blue)</picture>| | |
|[WAU_ADMX.zip](https://github.com/Romanitho/WAU-MSI/releases/download/v${{ steps.versioning.outputs.version }}/WAU_ADMX.zip)|${{ env.ADMX_SHA }}|<picture>![WAU_ADMX](https://img.shields.io/github/downloads/Romanitho/WAU-MSI/v${{ steps.versioning.outputs.version }}/WAU_ADMX.zip?style=flat-square&label=&color=blue)</picture>| | |
<picture>![Install counter](https://img.shields.io/github/downloads/Romanitho/WAU-MSI/v${{ steps.versioning.outputs.version }}/WAU_InstallCounter?style=flat-square&label=Total%20reported%20installations%20for%20this%20release&color=blue)</picture> | |
- name: URL to release | |
run: echo "Release -> ${{ steps.release.outputs.html_url }}" |