-
-
Notifications
You must be signed in to change notification settings - Fork 195
155 lines (134 loc) · 5.25 KB
/
workflow.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
147
148
149
150
151
152
153
154
155
name: build
on:
push:
paths-ignore:
- '**.md'
- 'funding.yml'
- '.gitignore'
- '.gitattributes'
- '.github/images'
- '.github/ISSUE_TEMPLATE'
- '**/*.hlsl'
pull_request:
paths-ignore:
- '**.md'
- 'funding.yml'
- '.gitignore'
- '.gitattributes'
- '.github/images'
- '.github/ISSUE_TEMPLATE'
- '**/*.hlsl'
jobs:
build:
strategy:
matrix:
include:
- api: vulkan
configuration: Release
- api: vulkan
configuration: Debug
- api: d3d12
configuration: Release
runs-on: "windows-latest"
env:
msbuild_path: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install Python dependencies
run: python -m pip install requests tqdm
- name: Generate project files
shell: python
env:
API: ${{ matrix.api }}
run: |
import subprocess
import os
api = os.environ["API"]
subprocess.run(f"python generate_vs2022_{api}.py ci")
- name: Build
shell: cmd
run: '"%msbuild_path%\MSBuild.exe" /p:Platform=Windows /p:Configuration=${{ matrix.configuration }} /m spartan.sln'
- name: Create artifacts
if: github.event_name != 'pull_request' && matrix.api == 'vulkan'
shell: cmd
run: |
echo "Creating artifacts for ${{ matrix.api }} - ${{ matrix.configuration }}"
IF "${{ matrix.configuration }}" == "Release" (
echo "Creating binaries-only archive for Release..."
build_scripts\7z.exe a -bb1 spartan_vulkan_release.7z .\binaries\7z.exe .\binaries\dxcompiler.dll .\binaries\download_assets.py .\binaries\file_utilities.py .\binaries\fmod.dll .\binaries\data .\binaries\spartan_${{ matrix.api }}.exe
) ELSE (
echo "Creating binaries-only archive for Debug..."
build_scripts\7z.exe a -bb1 spartan_vulkan_debug.7z .\binaries\7z.exe .\binaries\dxcompiler.dll .\binaries\download_assets.py .\binaries\file_utilities.py .\binaries\fmodL.dll .\binaries\data .\binaries\spartan_${{ matrix.api }}_debug.exe
)
echo "Artifact creation completed for ${{ matrix.api }} - ${{ matrix.configuration }}"
- name: Upload artifact
if: github.event_name != 'pull_request' && matrix.api == 'vulkan'
uses: actions/upload-artifact@v4
with:
name: spartan_vulkan_${{ matrix.configuration == 'Release' && 'release' || 'debug' }}
path: spartan_vulkan_${{ matrix.configuration == 'Release' && 'release' || 'debug' }}.7z
release:
if: github.event_name != 'pull_request'
runs-on: "ubuntu-latest"
needs: build
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download vulkan release build
uses: actions/download-artifact@v4
with:
name: spartan_vulkan_release
path: .
- name: Download vulkan debug build
uses: actions/download-artifact@v4
with:
name: spartan_vulkan_debug
path: .
- name: Get date and time for versioning
id: get_datetime
run: echo "version=$(date +'%Y.%m.%d.%H.%M')" >> $GITHUB_OUTPUT
- name: Rename release artifact
run: |
mv spartan_vulkan_release.7z spartan_vulkan_release_${{ steps.get_datetime.outputs.version }}.7z
- name: Rename debug artifact
run: |
mv spartan_vulkan_debug.7z spartan_vulkan_debug_${{ steps.get_datetime.outputs.version }}.7z
- name: Generate release notes
id: generate_release_notes
uses: actions/github-script@v7
with:
script: |
const { data: releases } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 1
});
const lastRelease = releases[0];
const lastReleaseDate = lastRelease ? lastRelease.published_at : null;
const { data: commits } = await github.rest.repos.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
since: lastReleaseDate,
per_page: 100
});
const releaseNotes = commits.map(commit => `- ${commit.commit.message}`).join('\n');
return releaseNotes;
- name: Publish release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ steps.get_datetime.outputs.version }}"
prerelease: true
title: "Spartan v${{ steps.get_datetime.outputs.version }}"
body: "${{ steps.generate_release_notes.outputs.result }}"
files: |
spartan_vulkan_release_${{ steps.get_datetime.outputs.version }}.7z
spartan_vulkan_debug_${{ steps.get_datetime.outputs.version }}.7z
- name: Set environment file for release
run: echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV