107 lines
3.6 KiB
YAML
107 lines
3.6 KiB
YAML
name: Auto Create Pre-Release Version
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 0 * * *'
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
get_date:
|
|
name: Get date for release version
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
today: ${{ steps.get_today.outputs.NOW }}
|
|
steps:
|
|
- name: Set current date as env variable
|
|
id: get_today
|
|
run: echo "NOW=$(date +'%y%m%d')" >> $GITHUB_OUTPUT
|
|
- name: Echo current date
|
|
run: echo ${{ steps.get_today.outputs.NOW }}
|
|
|
|
check_merged:
|
|
name: Check if latest merged commit is less than 24h
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
should_run: ${{ steps.should_run.outputs.SHOULD_RUN }}
|
|
merged_sha: ${{ steps.merged_sha.outputs.MERGED_SHA }}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Get latest merged SHA if less than a day
|
|
id: merged_sha
|
|
run: echo "MERGED_SHA=$(git log -n 1 --merges --after="24 hours" --pretty=format:"%H")" >> $GITHUB_OUTPUT
|
|
- name: Check latest merged SHA if less than a day
|
|
id: should_run
|
|
run: |
|
|
echo ${{ steps.merged_sha.outputs.MERGED_SHA }}
|
|
if [ ${{ steps.merged_sha.outputs.MERGED_SHA }} != "" ]; then
|
|
echo "Latest Merged SHA: ${{ steps.merged_sha.outputs.MERGED_SHA }}"
|
|
echo "SHOULD_RUN=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "No merged on last 24h"
|
|
echo "SHOULD_RUN=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
build:
|
|
name: Create Release Asset
|
|
needs: [get_date, check_merged]
|
|
if: ${{ needs.check_merged.outputs.should_run == 'true' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Echo env
|
|
run: |
|
|
echo "merged_sha: ${{ needs.check_merged.outputs.merged_sha }}"
|
|
echo "should_run: ${{ needs.check_merged.outputs.should_run }}"
|
|
echo "today: ${{ needs.get_date.outputs.today }}"
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
lfs: 'true'
|
|
|
|
- name: Get Current Latest Tag
|
|
uses: actions-ecosystem/action-get-latest-tag@v1
|
|
id: previoustag
|
|
|
|
- name: Format New Tag
|
|
id: new_tag
|
|
run: |
|
|
if [[ ${{ steps.previoustag.outputs.tag }} =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
|
|
echo newtag=${BASH_REMATCH[0]} >> $GITHUB_OUTPUT
|
|
else
|
|
echo "Something is wrong with the version"
|
|
fi
|
|
- name: Overwrite Version.txt file
|
|
uses: "DamianReeves/write-file-action@master"
|
|
with:
|
|
path: Winget-AutoUpdate/Version.txt
|
|
write-mode: overwrite
|
|
contents: "${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}"
|
|
|
|
- name: Commit & Push
|
|
uses: actions-js/push@v1.4
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
branch: main
|
|
force: true
|
|
message: 'Changed version to ${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}'
|
|
|
|
- name: Build project
|
|
run: |
|
|
zip -r WAU Winget-AutoUpdate/*
|
|
zip -r WAU Winget-AutoUpdate-Install.ps1
|
|
zip -r WAU excluded_apps.txt
|
|
zip -r WAU install.bat
|
|
zip -r WAU uninstall.bat
|
|
|
|
- name: Create release
|
|
uses: "ncipollo/release-action@v1"
|
|
with:
|
|
tag: "v${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}"
|
|
prerelease: true
|
|
generateReleaseNotes: true
|
|
name: "v${{ steps.new_tag.outputs.newtag }}-${{ needs.get_date.outputs.today }} [Nightly Build]"
|
|
artifacts: "WAU.zip"
|