wingetautoupdate/.github/workflows/AutoCreatePreVersion.yml

107 lines
3.6 KiB
YAML
Raw Normal View History

2023-04-12 12:11:31 +00:00
name: Auto Create Pre-Release Version
on:
2023-04-14 17:08:09 +00:00
schedule:
- cron: '0 0 * * *'
2023-04-12 14:25:56 +00:00
2023-04-12 12:30:51 +00:00
permissions:
contents: write
2023-04-12 12:11:31 +00:00
jobs:
2023-04-14 16:44:22 +00:00
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
2023-04-12 12:11:31 +00:00
build:
name: Create Release Asset
2023-04-14 16:44:22 +00:00
needs: [get_date, check_merged]
if: ${{ needs.check_merged.outputs.should_run == 'true' }}
2023-04-12 12:11:31 +00:00
runs-on: ubuntu-latest
steps:
2023-04-14 16:44:22 +00:00
- 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 }}"
2023-04-12 12:11:31 +00:00
- name: Checkout code
uses: actions/checkout@v3
with:
2023-04-12 14:25:56 +00:00
lfs: 'true'
2023-04-14 16:44:22 +00:00
- 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
2023-04-12 14:25:56 +00:00
- name: Overwrite Version.txt file
uses: "DamianReeves/write-file-action@master"
with:
2023-04-12 14:51:47 +00:00
path: Winget-AutoUpdate/Version.txt
2023-04-12 14:25:56 +00:00
write-mode: overwrite
2023-04-14 16:44:22 +00:00
contents: "${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}"
2023-04-12 14:25:56 +00:00
- name: Commit & Push
2023-04-14 16:44:22 +00:00
uses: actions-js/push@v1.4
2023-04-12 14:25:56 +00:00
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
force: true
2023-04-14 16:44:22 +00:00
message: 'Changed version to ${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}'
2023-04-12 14:25:56 +00:00
- name: Build project
2023-04-12 12:11:31 +00:00
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
2023-04-14 16:44:22 +00:00
- name: Create release
uses: "ncipollo/release-action@v1"
2023-04-12 12:11:31 +00:00
with:
2023-04-14 16:44:22 +00:00
tag: "v${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}"
2023-04-12 12:11:31 +00:00
prerelease: true
2023-04-14 16:44:22 +00:00
generateReleaseNotes: true
name: "v${{ steps.new_tag.outputs.newtag }}-${{ needs.get_date.outputs.today }} [Nightly Build]"
artifacts: "WAU.zip"