wingetautoupdate/.github/workflows/WAU-AutoCreatePreVersion.yml

116 lines
3.8 KiB
YAML

---
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: ubuntu-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@b0314e8d64baee1c3f74233edb71eb976503a6a4 # 1.0.10
id: versioning
with:
releaseType: prerelease
incrementPerCommit: false
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Next Release Number
id: WAU_version
run: |
echo "Next Release version: ${{ steps.versioning.outputs.version }}"
- name: Overwrite Version.txt file
uses: DamianReeves/write-file-action@0a7fcbe1960c53fc08fe789fa4850d24885f4d84 # v1.2
with:
path: Winget-AutoUpdate/Version.txt
write-mode: overwrite
contents: ${{ steps.versioning.outputs.version }}
- name: Commit & Push
uses: actions-js/push@156f2b10c3aa000c44dbe75ea7018f32ae999772 # v1.4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
force: true
message: "Changed version to ${{ steps.versioning.outputs.version }}"
- name: Build project
run: |
# Get MDT from Microsoft
wget https://download.microsoft.com/download/3/3/9/339BE62D-B4B8-4956-B58D-73C4685FC492/MicrosoftDeploymentToolkit_x64.msi
# Extract MSI
7z x MicrosoftDeploymentToolkit_x64.msi
# Copy ServiceUI.exe to Winget-AutoUpdate folder
mv Modena_File206 Winget-AutoUpdate/ServiceUI.exe
# Zip WAU
zip -r WAU.zip Winget-AutoUpdate
zip WAU.zip Winget-AutoUpdate-Install.ps1
zip WAU.zip excluded_apps.txt
zip WAU.zip Gui.ps1
zip WAU.zip "WAU Configurator.lnk"
# Zip ADMX
cd Policies
zip -r ../WAU_ADMX.zip *
cd ..
# Add install counter
echo "Install counter file." > WAU_InstallCounter
- name: Create release
uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5 # v1.13.0
id: release
with:
tag: "v${{ steps.versioning.outputs.version }}"
prerelease: true
generateReleaseNotes: true
name: "v${{ steps.versioning.outputs.version }} [Nightly Build]"
artifacts: "WAU.zip,WAU_ADMX.zip,WAU_InstallCounter"
- name: URL to release
run: echo "Release -> ${{ steps.release.outputs.html_url }}"