-
Notifications
You must be signed in to change notification settings - Fork 56
101 lines (87 loc) · 3.34 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: windows-2019
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Check Commit and Install 7Zip PowerShell Module
shell: powershell
run: |
# cancel early, if not build commit
$strVal ='${{ github.event.commits[0].message }}'
# Convert commit message to a single line if multiline
$singleLineStrVal = $strVal -replace "`r`n", " " -replace "`n", " "
if($singleLineStrVal -match '#GITBUILD')
{
Write-Host 'True'
} else {
Write-Host 'False'
exit(1)
}
Install-Module 7Zip4PowerShell -Force -Verbose
- uses: actions/checkout@v2
- 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
# Step to get previous tag and commits
- name: Get commits since last release
id: get_commits
shell: bash
run: |
# Get the most recent tag
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "none")
if [ "$PREV_TAG" = "none" ]; then
echo "No previous tag found, listing all commits"
COMMITS=$(git log --pretty=format:"* %s" --no-merges)
else
echo "Previous tag: $PREV_TAG"
# List commits since last tag
COMMITS=$(git log $PREV_TAG..HEAD --pretty=format:"* %s" --no-merges)
fi
echo "Commits since last release: $COMMITS"
# Save commits to environment file for later use
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