-
Notifications
You must be signed in to change notification settings - Fork 60
87 lines (74 loc) · 2.66 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: CI
on:
push:
branches: [ master ]
workflow_dispatch:
jobs:
build:
runs-on: windows-2019
steps:
- name: Check Commit Message
shell: powershell
run: |
$strVal ='${{ github.event.commits[0].message }}'
$singleLineStrVal = $strVal -replace "`r`n", " " -replace "`n", " "
if($singleLineStrVal -match '#GITBUILD') {
Write-Host 'Build commit detected. Proceeding with build...'
echo "build_trigger=true" >> $env:GITHUB_ENV
} else {
Write-Host 'No build commit. Skipping build steps...'
echo "build_trigger=false" >> $env:GITHUB_ENV
- uses: actions/checkout@v2
- name: Conditional Build Steps
if: env.build_trigger == 'true'
steps:
- name: Install 7Zip PowerShell Module
shell: powershell
run: Install-Module 7Zip4PowerShell -Force -Verbose
- name: Restore NuGet packages
run: nuget restore UnityLauncherPro.sln
- name: Build Binary
shell: cmd
run: call .\Build.cmd
- name: Build Artifact
shell: cmd
run: call .\ArtifactBuild.cmd
- name: Get current date and time
id: datetime
run: |
echo "current_datetime=$(date +'%d/%m/%Y %H:%M')" >> $GITHUB_ENV
- name: Get commits since last release
id: get_commits
shell: bash
run: |
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "none")
if [ "$PREV_TAG" = "none" ]; then
COMMITS=$(git log --pretty=format:"* %s" --no-merges)
else
COMMITS=$(git log $PREV_TAG..HEAD --pretty=format:"* %s" --no-merges)
fi
echo "commits=$COMMITS" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{github.run_number}}
release_name: ${{ env.current_datetime }} (${{ github.run_number }})
body: |
Automated Release by GitHub Action CI
### Commits in this release:
${{ env.commits }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./UnityLauncherPro.zip
asset_name: UnityLauncherPro.zip
asset_content_type: application/zip