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