forked from WolvenKit/WolvenKit
-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (119 loc) · 5.12 KB
/
nightly.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: WolvenKit-Nightly
on:
schedule:
- cron: "0 12 * * *"
workflow_dispatch:
env:
FINALOUT: ./publish
NAME: WolvenKit
MREPO: ${{github.repository}}
WINGET_ID: REDModding.WolvenKit.Nightly
jobs:
check_date:
runs-on: ubuntu-latest
name: Check latest commit
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
steps:
- uses: actions/checkout@v4
with:
ref: main
- id: should_run
name: check latest commit is less than a day
run: |
myvar=$(git rev-list --after="24 hours" HEAD)
if (test ! -z "$myvar"); then HAS_COMMITS='true'; else HAS_COMMITS='false'; fi;
echo "$HAS_COMMITS"
echo "should_run="$HAS_COMMITS"" >> $GITHUB_OUTPUT
nightly-wkit-win:
needs: check_date
if: ${{ needs.check_date.outputs.should_run == 'true' }}
runs-on: windows-2022
steps:
##########################################
# SETUP
- name: checkout
uses: actions/checkout@v4
with:
ref: main
- name: Get commit
run: |
$commit = git log -1 --format=%H
echo "SHA=$commit" >> $env:GITHUB_ENV
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Get Date
run: |
$date = Get-Date -Format "yyyy-MM-dd"
echo "ISODATE=$date" >> $env:GITHUB_ENV
##########################################
# APP
- name: Get version
uses: naminodarie/get-net-sdk-project-versions-action@v2
id: get_version
with:
proj-path: ./WolvenKit/WolvenKit.csproj
- run: echo "VERSION_APP=${{steps.get_version.outputs.assembly-version}}-nightly.${{env.ISODATE}}" >> $env:GITHUB_ENV
- run: echo "PORTABLE=${{env.NAME}}-${{env.VERSION_APP}}.zip" >> $env:GITHUB_ENV
# Publish app
- run: dotnet publish ./WolvenKit/WolvenKit.csproj -o ./publish/app/ -c Release -p:ApplicationIcon=../WolvenKit/Resources/Media/Images/Icons/Application/TaskBarIcon_Nightly.ico --version-suffix "nightly.${{env.ISODATE}}" -p:InformationalVersion="${{env.VERSION_APP}}"
- run: Compress-Archive -Path ./publish/app/* -DestinationPath ${{env.FINALOUT}}/${{env.PORTABLE}}
##########################################
# CONSOLE
# tag main commit
- name: Create Tag
id: tag_version
uses: rfuzzo/github-tag-action@7b0316b3fb8aa236fdc20bee0614ea6ef99f4bf1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: false
custom_tag: ${{ env.VERSION_APP }}
tag_prefix: ""
# CLI commit checks
- run: git fetch --tags
- name: Get CLI commits
run: |
$commits = (git --no-pager diff --name-only ${{ steps.tag_version.outputs.previous_tag }}) | Out-String
$i = 0
$commits -Split "`r`n" | ForEach-Object { if ( $_.StartsWith("WolvenKit.CLI/") -or $_.StartsWith("WolvenKit.Common/") -or $_.StartsWith("WolvenKit.Core/") -or $_.StartsWith("WolvenKit.Modkit/") -or $_.StartsWith("WolvenKit.RED4/") ) { $i = $i + 1 } }
if ($i -eq 0) { $b = 'false' } else { $b = 'true' }
echo "HAS_CLI_COMMITS=$b" >> $env:GITHUB_ENV
- name: Get console version
if: ${{ env.HAS_CLI_COMMITS == 'true' }}
uses: naminodarie/get-net-sdk-project-versions-action@v2
id: get_version_cli
with:
proj-path: ./WolvenKit.CLI/WolvenKit.CLI.csproj
- name: env cli version
if: ${{ env.HAS_CLI_COMMITS == 'true' }}
run: echo "VERSION_CLI=${{steps.get_version_cli.outputs.assembly-version}}-nightly.${{env.ISODATE}}" >> $env:GITHUB_ENV
- name: env cli name
if: ${{ env.HAS_CLI_COMMITS == 'true' }}
run: echo "CONSOLE=${{env.NAME}}.Console-${{env.VERSION_CLI}}.zip" >> $env:GITHUB_ENV
# Publish console
- name: publish console
if: ${{ env.HAS_CLI_COMMITS == 'true' }}
run: dotnet publish ./WolvenKit.CLI/WolvenKit.CLI.csproj -o ./publish/console/ -c Release --version-suffix "nightly.${{env.ISODATE}}"
- name: zip console
if: ${{ env.HAS_CLI_COMMITS == 'true' }}
run: Compress-Archive -Path ./publish/console/* -DestinationPath ${{env.FINALOUT}}/${{env.CONSOLE}}
##########################################
# INSTALLER
- name: create installer
run: ISCC /O"${{env.FINALOUT}}" /dMyAppBaseDir="..\publish\app\" /dMyAppName="WolvenKit Nightly" /dMyAppId="WolvenKit-Nightly" .\Installers\installer.iss
##########################################
# RELEASE
- name: Release dispatch
id: release_dispatch
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.VERSION_APP }}
generate_release_notes: false
files: |
${{ env.FINALOUT }}/*.zip
${{ env.FINALOUT }}/*.exe
repository: WolvenKit/WolvenKit-nightly-releases
token: ${{ secrets.RELEASE_TOKEN }}
body: "This is a beta release so you may encounter bugs. Please report them.\n${{ steps.tag_version.outputs.changelog }}"