|
1 |
| -# This is a basic workflow to help you get started with Actions |
2 | 1 | name: CI
|
3 | 2 |
|
4 |
| -# Controls when the workflow will run |
5 | 3 | on:
|
6 |
| - # Triggers the workflow on push or pull request events but only for the master branch |
7 | 4 | push:
|
8 | 5 | branches: [ master ]
|
9 |
| - |
10 |
| - # Allows you to run this workflow manually from the Actions tab |
11 | 6 | workflow_dispatch:
|
12 | 7 |
|
13 |
| -# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
14 | 8 | jobs:
|
15 |
| - # This workflow contains a single job called "build" |
16 | 9 | build:
|
17 |
| - # The type of runner that the job will run on |
18 | 10 | runs-on: windows-2019
|
19 | 11 |
|
20 |
| - # Steps represent a sequence of tasks that will be executed as part of the job |
21 | 12 | steps:
|
22 |
| - - name: Check Commit and Install 7Zip PowerShell Module |
| 13 | + - name: Check Commit Message |
23 | 14 | shell: powershell
|
24 | 15 | run: |
|
25 |
| - # cancel early, if not build commit |
26 | 16 | $strVal ='${{ github.event.commits[0].message }}'
|
27 |
| - # Convert commit message to a single line if multiline |
28 | 17 | $singleLineStrVal = $strVal -replace "`r`n", " " -replace "`n", " "
|
29 |
| - if($singleLineStrVal -match '#GITBUILD') |
30 |
| - { |
31 |
| - Write-Host 'True' |
| 18 | + if($singleLineStrVal -match '#GITBUILD') { |
| 19 | + Write-Host 'Build commit detected. Proceeding with build...' |
| 20 | + echo "build_trigger=true" >> $env:GITHUB_ENV |
32 | 21 | } else {
|
33 |
| - Write-Host 'False' |
34 |
| - exit(1) |
35 |
| - } |
36 |
| - Install-Module 7Zip4PowerShell -Force -Verbose |
| 22 | + Write-Host 'No build commit. Skipping build steps...' |
| 23 | + echo "build_trigger=false" >> $env:GITHUB_ENV |
37 | 24 |
|
38 | 25 | - uses: actions/checkout@v2
|
39 | 26 |
|
40 |
| - - name: Restore NuGet packages |
41 |
| - run: nuget restore UnityLauncherPro.sln |
42 |
| - |
43 |
| - - name: Build Binary |
44 |
| - shell: cmd |
45 |
| - run: call .\Build.cmd |
46 |
| - |
47 |
| - - name: Build Artifact |
48 |
| - shell: cmd |
49 |
| - run: call .\ArtifactBuild.cmd |
| 27 | + - name: Conditional Build Steps |
| 28 | + if: env.build_trigger == 'true' |
| 29 | + steps: |
| 30 | + - name: Install 7Zip PowerShell Module |
| 31 | + shell: powershell |
| 32 | + run: Install-Module 7Zip4PowerShell -Force -Verbose |
| 33 | + |
| 34 | + - name: Restore NuGet packages |
| 35 | + run: nuget restore UnityLauncherPro.sln |
| 36 | + |
| 37 | + - name: Build Binary |
| 38 | + shell: cmd |
| 39 | + run: call .\Build.cmd |
| 40 | + |
| 41 | + - name: Build Artifact |
| 42 | + shell: cmd |
| 43 | + run: call .\ArtifactBuild.cmd |
50 | 44 |
|
51 | 45 | - name: Get current date and time
|
52 | 46 | id: datetime
|
53 | 47 | run: |
|
54 | 48 | echo "current_datetime=$(date +'%d/%m/%Y %H:%M')" >> $GITHUB_ENV
|
55 | 49 |
|
56 |
| - # Step to get previous tag and commits |
57 | 50 | - name: Get commits since last release
|
58 | 51 | id: get_commits
|
59 | 52 | shell: bash
|
60 | 53 | run: |
|
61 |
| - # Get the most recent tag |
62 | 54 | PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "none")
|
63 | 55 | if [ "$PREV_TAG" = "none" ]; then
|
64 |
| - echo "No previous tag found, listing all commits" |
65 | 56 | COMMITS=$(git log --pretty=format:"* %s" --no-merges)
|
66 | 57 | else
|
67 |
| - echo "Previous tag: $PREV_TAG" |
68 |
| - # List commits since last tag |
69 | 58 | COMMITS=$(git log $PREV_TAG..HEAD --pretty=format:"* %s" --no-merges)
|
70 | 59 | fi
|
71 |
| - echo "Commits since last release: $COMMITS" |
72 |
| - |
73 |
| - # Save commits to environment file for later use |
74 | 60 | echo "commits=$COMMITS" >> $GITHUB_ENV
|
75 | 61 |
|
76 | 62 | - name: Create Release
|
|
87 | 73 | ### Commits in this release:
|
88 | 74 | ${{ env.commits }}
|
89 | 75 | draft: false
|
90 |
| - prerelease: false |
91 |
| - |
| 76 | + prerelease: false |
| 77 | + |
92 | 78 | - name: Upload Release Asset
|
93 | 79 | id: upload-release-asset
|
94 | 80 | uses: actions/upload-release-asset@v1
|
|
0 commit comments