-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (148 loc) · 5.49 KB
/
ci.yml
File metadata and controls
166 lines (148 loc) · 5.49 KB
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
156
157
158
159
160
161
162
163
164
165
166
name: CI
on:
push:
branches:
- master
tags:
- v*
pull_request:
release:
types: [created, published]
workflow_dispatch:
permissions:
contents: read
env:
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
RESONITE_INSTALL_DIR: ${{ github.workspace }}/.resonite
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Verify Steam credentials
shell: bash
run: |
if [ -z "${{ secrets.STEAMUSER }}" ]; then
echo '::error::Missing secrets.STEAMUSER. Add the Steam username used for SteamCMD downloads.'
exit 1
fi
if [ -z "${{ secrets.STEAMPASS }}" ]; then
echo '::error::Missing secrets.STEAMPASS. Add the Steam password used for SteamCMD downloads.'
exit 1
fi
- name: Setup Resonite environment
id: resonite
uses: resonite-modding-group/setup-resonite-env-action@v0.1.0
with:
steam-user: ${{ secrets.STEAMUSER }}
steam-password: ${{ secrets.STEAMPASS }}
resonite-path: ${{ env.RESONITE_INSTALL_DIR }}
- name: Install ResoniteModLoader binaries
env:
RESONITE_PATH: ${{ env.RESONITE_INSTALL_DIR }}
shell: bash
run: |
set -euo pipefail
if [ -z "${RESONITE_PATH:-}" ]; then
echo '::error::Resonite path is empty. Ensure the setup-resonite-env step succeeded and exposed resonite-path.'
exit 1
fi
install -d "$RESONITE_PATH/Libraries" "$RESONITE_PATH/rml_libs"
curl -sSfL -o "$RESONITE_PATH/Libraries/ResoniteModLoader.dll" \
https://github.com/resonite-modding-group/ResoniteModLoader/releases/latest/download/ResoniteModLoader.dll
curl -sSfL -o "$RESONITE_PATH/rml_libs/0Harmony.dll" \
https://github.com/resonite-modding-group/ResoniteModLoader/releases/latest/download/0Harmony.dll
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json', '**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore
env:
ResoniteAssembliesDir: ${{ env.RESONITE_INSTALL_DIR }}
shell: bash
run: |
dotnet restore WhileLoopTimeout.sln
- name: Verify formatting
env:
ResoniteAssembliesDir: ${{ env.RESONITE_INSTALL_DIR }}
shell: bash
run: |
dotnet format WhileLoopTimeout.sln --verify-no-changes --no-restore
- name: Build
env:
ResoniteAssembliesDir: ${{ env.RESONITE_INSTALL_DIR }}
shell: bash
run: |
dotnet build WhileLoopTimeout.sln --configuration Release --no-restore
- name: Test
env:
ResoniteAssembliesDir: ${{ env.RESONITE_INSTALL_DIR }}
shell: bash
run: |
dotnet test WhileLoopTimeout.sln --configuration Release --no-build
- name: Prepare release assets
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release'
shell: bash
run: |
set -euo pipefail
artifacts_dir=release-artifacts
mkdir -p "$artifacts_dir"
cp src/WhileLoopTimeout/bin/Release/net9.0/WhileLoopTimeout.dll "$artifacts_dir/WhileLoopTimeout.dll"
if [ -f src/WhileLoopTimeout/bin/Release/net9.0/WhileLoopTimeout.pdb ]; then
cp src/WhileLoopTimeout/bin/Release/net9.0/WhileLoopTimeout.pdb "$artifacts_dir/WhileLoopTimeout.pdb"
fi
- name: Upload release artifacts
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release'
uses: actions/upload-artifact@v4
with:
name: while-loop-timeout
path: release-artifacts
if-no-files-found: error
release:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release'
permissions:
contents: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: while-loop-timeout
path: release-artifacts
- name: Determine release tag
id: tag
shell: bash
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "tag_name=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "tag_name=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
else
echo "::error::Unexpected event: ${{ github.event_name }} with ref: ${{ github.ref }}"
exit 1
fi
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag_name }}
name: While Loop Timeout ${{ steps.tag.outputs.tag_name }}
# When triggered by release event, this updates the existing release
# When triggered by tag push, this creates a new release
generate_release_notes: ${{ github.event_name != 'release' }}
files: |
release-artifacts/WhileLoopTimeout.dll
release-artifacts/WhileLoopTimeout.pdb