Merge pull request #317 from Romanitho/workflow

Auto pre-release review
pull/319/head
Romain 2023-04-14 18:51:53 +02:00 committed by GitHub
commit dfd7cb8673
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 67 additions and 17 deletions

View File

@ -10,35 +10,85 @@ 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: Auto Increment Semver Action
uses: MCKanpolat/auto-semver-action@v1
id: versioning
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- 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.versioning.outputs.version }}
contents: "${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}"
- name: Commit & Push
uses: Andro999b/push@v1.3
uses: actions-js/push@v1.4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
force: true
message: 'Changed version to ${{ steps.versioning.outputs.version }}'
message: 'Changed version to ${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}'
- name: Build project
run: |
@ -48,11 +98,11 @@ jobs:
zip -r WAU install.bat
zip -r WAU uninstall.bat
- uses: "marvinpinto/action-automatic-releases@latest"
- name: Create release
uses: "ncipollo/release-action@v1"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "v${{ steps.versioning.outputs.version }}"
tag: "v${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}"
prerelease: true
title: "v${{ steps.versioning.outputs.version }}"
files: |
WAU.zip
generateReleaseNotes: true
name: "v${{ steps.new_tag.outputs.newtag }}-${{ needs.get_date.outputs.today }} [Nightly Build]"
artifacts: "WAU.zip"