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 contents: write
jobs: 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: build:
name: Create Release Asset name: Create Release Asset
needs: [get_date, check_merged]
if: ${{ needs.check_merged.outputs.should_run == 'true' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: 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 - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
lfs: 'true' lfs: 'true'
- name: Auto Increment Semver Action - name: Get Current Latest Tag
uses: MCKanpolat/auto-semver-action@v1 uses: actions-ecosystem/action-get-latest-tag@v1
id: versioning id: previoustag
with:
github_token: ${{ secrets.GITHUB_TOKEN }} - 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 - name: Overwrite Version.txt file
uses: "DamianReeves/write-file-action@master" uses: "DamianReeves/write-file-action@master"
with: with:
path: Winget-AutoUpdate/Version.txt path: Winget-AutoUpdate/Version.txt
write-mode: overwrite write-mode: overwrite
contents: ${{ steps.versioning.outputs.version }} contents: "${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}"
- name: Commit & Push - name: Commit & Push
uses: Andro999b/push@v1.3 uses: actions-js/push@v1.4
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main branch: main
force: true 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 - name: Build project
run: | run: |
@ -47,12 +97,12 @@ jobs:
zip -r WAU excluded_apps.txt zip -r WAU excluded_apps.txt
zip -r WAU install.bat zip -r WAU install.bat
zip -r WAU uninstall.bat zip -r WAU uninstall.bat
- uses: "marvinpinto/action-automatic-releases@latest" - name: Create release
uses: "ncipollo/release-action@v1"
with: with:
repo_token: "${{ secrets.GITHUB_TOKEN }}" tag: "v${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}"
automatic_release_tag: "v${{ steps.versioning.outputs.version }}"
prerelease: true prerelease: true
title: "v${{ steps.versioning.outputs.version }}" generateReleaseNotes: true
files: | name: "v${{ steps.new_tag.outputs.newtag }}-${{ needs.get_date.outputs.today }} [Nightly Build]"
WAU.zip artifacts: "WAU.zip"