-
Notifications
You must be signed in to change notification settings - Fork 5
99 lines (85 loc) · 3.28 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
name: Publish Release
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
env:
BundleBepInEx : false
BepInExVersion : 5
BepInExArch : x64
BepInExRuntime : IL2CPP
PluginName : CommonAPI-CommonAPI
GithubRelease : true
ThunderstoreRelease: true
PublishNuget: true
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0 # can't shallowly clone due to git versioning
- name: Get version of the project
id: get-version
uses: 'euberdeveloper/ga-project-version@main'
with:
path: 'version.json'
- name: Check Tag
id: check-tag
uses: actions-ecosystem/action-regex-match@v2
with:
text: ${{ steps.get-version.outputs.version }}
regex: '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
- name: Fail if invalid
if: steps.check-tag.outputs.match == ''
uses: Actions/github-script@v3
with:
script: |
core.setFailed('Invalid tag')
- uses: actions/setup-dotnet@v1
- name: BepInEx 6
run: |
bepinexurl = $(curl -vs https://builds.bepinex.dev/projects/bepinex_be 2>&1 | grep -Po '(?<=href=")(\/projects\/bepinex_be\/(.*)\/BepInEx_Unity${{env.BepInExRuntime}}_${{env.BepInExArch}}(.*))(?=")' | head -1)"
wget $bepinexurl > bepinex.zip
if: env.BundleBepInEx == 'true' && env.BepInExVersion == '6'
- name: BepInEx 5
shell: pwsh
run: |
$webData = Invoke-WebRequest -Uri "https://api.github.com/repos/BepInEx/BepInEx/releases/latest"
$release = ConvertFrom-Json $webData.content
$bepinexurl = $release.assets.browser_download_url -match '${{env.BepInExArch}}'
wget $bepinexurl > bepinex.zip
if: env.BundleBepInEx == 'true' && env.BepInExVersion == '5'
- name: Extract BepInEx
run: |
mkdir out;
unzip BepInEx* -d out;
if: env.BundleBepInEx == 'true'
- name: Setup Thunderstore CLI
run: |
dotnet tool install -g tcli
- name: Build & zip
run: |
dotnet build CommonAPIPublish.sln -c Release /p:ReleaseMode=1
tcli build --config-path Config/thunderstore.toml --package-version ${{ steps.get-version.outputs.version }}
- name: Publish to Github
uses: ncipollo/release-action@v1
with:
artifacts: "Build/*.zip"
tag: ${{ steps.get-version.outputs.version }}
commit: ${{ github.ref }}
artifactErrorsFailBuild: true
draft: true
allowUpdates: true
if: env.GithubRelease == 'true'
- name: Publish to Thunderstore
env:
TCLI_AUTH_TOKEN: ${{ secrets.TCLI_AUTH_TOKEN }}
run: |
tcli publish --config-path Config/thunderstore.toml --package-version ${{ steps.get-version.outputs.version }}
if: env.ThunderstoreRelease == 'true'
- name: Publish to NuGet
run: |
dotnet pack CommonAPI/CommonAPI.csproj /p:ReleaseMode=1 -c Release -o "."
dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} --skip-duplicate
if: env.PublishNuget == 'true'