-
-
Notifications
You must be signed in to change notification settings - Fork 29
169 lines (144 loc) · 6.46 KB
/
Copy pathdotnet.yml
File metadata and controls
169 lines (144 loc) · 6.46 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
167
168
169
# This is a basic workflow to help you get started with Actions
name: Build and Draft Nightly Release
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
schedule:
- cron: "0 7 * * *"
# 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 checks to see if branch has any changes since last wo
prep:
runs-on: ubuntu-latest
name: Prepare for Build
outputs:
oldversion: ${{ steps.previoustag.outputs.tag }}
version: ${{ steps.semvers.outputs.patch }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# the nightly tag is moved to the built commit on every successful release,
# so building only when HEAD differs from it also picks up commits that a
# previously failed run never shipped. the run is failed on purpose when
# there is nothing to build so a "no new nightly" day is visible as red
- name: "check for new commits since last nightly"
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "This workflow was triggered manually! Forcing a build."
elif [[ "$(git rev-parse HEAD)" == "$(git rev-parse 'refs/tags/nightly^{commit}' 2>/dev/null)" ]]; then
echo "::error::No new commits since last nightly release, no build created."
exit 1
fi
- name: "Check if nightly exists"
id: nightly
uses: cardinalby/git-get-release-action@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag: "nightly"
prerelease: true
doNotFailIfNotFound: true
- name: "Get Previous tag"
id: previoustag
run: |
nightly=""
if [ "${{steps.nightly.outputs.id}}" != "" ]; then
nightly=$(echo "${{steps.nightly.outputs.name}}" | perl -pe '($_)=/([0-9]+([.][0-9]+)+)/')
fi
# a stable release (release.yml) can be published with a higher version
# than the running nightly series, so continue from whichever is newer
stable=$(git tag --list '[0-9]*' | sort -V | tail -n 1)
tag=$(printf '%s\n' "$nightly" "$stable" | grep . | sort -V | tail -n 1)
echo "Previous version: $tag (nightly: ${nightly:-none}, stable: ${stable:-none})"
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: "Get next version"
id: semvers
uses: "WyriHaximus/github-action-next-semvers@v1"
with:
version: ${{ steps.previoustag.outputs.tag }}
- name: output
run: echo ${{steps.previoustag.outputs.tag}} ${{steps.semvers.outputs.patch}}
build:
needs: prep
runs-on: windows-2022
name: Build RePlays
permissions:
contents: write
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
submodules: "true"
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.403
# vpk (velopack) is pinned in .config/dotnet-tools.json and run by the publish
- name: Restore dotnet tools
run: dotnet tool restore
# the previous full package is what the delta package is built against. with --pre
# the newest version across the stable and nightly releases is taken, the same set
# of releases the app itself reads on the nightly channel
- name: Download previous release to create delta
run: dotnet vpk download github --repoUrl https://github.com/${{ github.repository }} --token ${{ secrets.GITHUB_TOKEN }} --pre --outputDir bin/Deployment/Releases
# libobs is built once per version of build-libobs.cmd and kept on the
# "libobs" release, so this normally only downloads it (see libobs.yml)
- name: Get LibObs
uses: ./.github/actions/libobs
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Build RePlays
env:
CI: false
run: dotnet publish /p:Configuration=Release /p:Version=${{needs.prep.outputs.version}} /p:UpdateChannel=Nightly /p:PublishProfile=FolderProfile -v d
- name: Append version to setup file
run: ren ./bin/Deployment/Releases/RePlays-win-Setup.exe RePlaysSetup-${{needs.prep.outputs.version}}.exe
- name: Update nightly tag
uses: richardsimko/update-tag@v1
with:
tag_name: nightly
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Delete old prerelease deltas
run: |
gh release delete-asset "nightly" "RePlays-${{needs.prep.outputs.oldversion}}-full.nupkg" &&
gh release delete-asset "nightly" "RePlays-${{needs.prep.outputs.oldversion}}-delta.nupkg"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create prerelease
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: "nightly"
prerelease: true
generate_release_notes: true
name: ${{ format('Nightly RePlays v{0}', needs.prep.outputs.version )}}
body: "Nightly release, built with the latest and potentially breaking changes, test at your own risk."
files: |
./bin/Deployment/Releases/RELEASES
./bin/Deployment/Releases/releases.win.json
./bin/Deployment/Releases/RePlaysSetup-${{needs.prep.outputs.version}}.exe
./bin/Deployment/Releases/RePlays-${{needs.prep.outputs.version}}-full.nupkg
./bin/Deployment/Releases/RePlays-${{needs.prep.outputs.version}}-delta.nupkg
# the setup executables are the only assets that survive from one nightly
# to the next, so keep the three most recent ones and drop the rest
- name: Prune old nightly setup executables
shell: bash
run: |
gh release view nightly --json assets --jq '.assets[].name' \
| grep -E '^RePlaysSetup-[0-9]+(\.[0-9]+)+\.exe$' \
| sort -V \
| head -n -3 \
| while read -r asset; do
echo "Deleting $asset"
gh release delete-asset nightly "$asset" --yes
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}