WolvenKit-Nightly #238
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}} | |
# Pack and upload prerelease nugets | |
- name: pack cli | |
if: ${{ env.HAS_CLI_COMMITS == 'true' }} | |
run: dotnet pack ./WolvenKit.CLI/WolvenKit.CLI.csproj --version-suffix "nightly.${{env.ISODATE}}" | |
- name: push nuget | |
continue-on-error: true | |
if: ${{ env.HAS_CLI_COMMITS == 'true' }} | |
run: dotnet nuget push .\WolvenKit.CLI\nupkg\*.nupkg --api-key ${{secrets.NUGET_KEY}} --source "https://api.nuget.org/v3/index.json" --skip-duplicate | |
########################################## | |
# 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 }}" | |