Skip to content

Commit 6ad690a

Browse files
committed
add github workflows
1 parent ccc13e6 commit 6ad690a

File tree

2 files changed

+226
-0
lines changed

2 files changed

+226
-0
lines changed

.github/workflows/build.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Build
2+
3+
on:
4+
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g., for dependabot pull requests)
5+
push:
6+
branches: [ main ]
7+
# Trigger the workflow on any pull request
8+
pull_request:
9+
10+
jobs:
11+
build:
12+
name: Build
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Fetch Sources
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
filter: tree:0
20+
submodules: recursive
21+
22+
- name: Setup .NET environment
23+
uses: actions/setup-dotnet@v3
24+
with:
25+
dotnet-version: "8.0.100"
26+
27+
- name: Restore project
28+
run: |
29+
dotnet restore
30+
dotnet tool restore
31+
32+
- name: Build and pack solution
33+
run: |
34+
dotnet pack -c Release
35+
36+
- name: Upload thunderstore artifact
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: thunderstore-build
40+
path: |
41+
./*/assets/thunderstore.toml.user
42+
./*/bin/Release/netstandard2.1/dist/*.zip
43+
44+
- name: Upload nupkg artifact
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: nupkg-build
48+
path: ./*/bin/Release/*.nupkg
49+
50+
upload-release-artifacts:
51+
name: Upload Release Artifacts
52+
needs: build
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: Fetch Sources
56+
uses: actions/checkout@v4
57+
58+
- name: Download all artifacts
59+
uses: actions/download-artifact@v4
60+
61+
- name: Upload artifacts to Release
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
run: gh release upload ${{ github.event.release.tag_name }} thunderstore-build/*/bin/Release/netstandard2.1/dist/*.zip nupkg-build/*/bin/Release/*.nupkg
65+
66+
deploy-nuget:
67+
name: Deploy to NuGet
68+
needs: build
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Fetch Sources
72+
uses: actions/checkout@v4
73+
74+
- name: Download nupkg artifact
75+
uses: actions/download-artifact@v4
76+
with:
77+
name: nupkg-build
78+
79+
- name: Setup .NET environment
80+
uses: actions/setup-dotnet@v3
81+
with:
82+
dotnet-version: "8.0.100"
83+
84+
- name: Publish to NuGet.org
85+
run: |
86+
dotnet nuget push ./*/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_TOKEN }} --source https://api.nuget.org/v3/index.json
87+
88+
deploy-thunderstore:
89+
name: Deploy to Thunderstore
90+
needs: build
91+
runs-on: ubuntu-latest
92+
steps:
93+
- name: Fetch Sources
94+
uses: actions/checkout@v4
95+
96+
- name: Download Thunderstore artifact
97+
uses: actions/download-artifact@v4
98+
with:
99+
name: thunderstore-build
100+
101+
- name: Setup .NET environment
102+
uses: actions/setup-dotnet@v3
103+
with:
104+
dotnet-version: "8.0.100"
105+
106+
- name: Restore dotnet tools
107+
run: |
108+
dotnet tool restore
109+
110+
- name: Publish to Thunderstore
111+
env:
112+
TCLI_AUTH_TOKEN: ${{ secrets.THUNDERSTORE_API_TOKEN }}
113+
run: |
114+
dotnet build -c Release -target:ThunderstorePublish

.github/workflows/publish.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [prereleased, released]
6+
7+
jobs:
8+
build:
9+
name: Build
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Fetch Sources
13+
uses: actions/checkout@v4
14+
with:
15+
ref: ${{ github.event.release.tag_name }}
16+
fetch-depth: 0
17+
filter: tree:0
18+
submodules: recursive
19+
20+
- name: Setup .NET environment
21+
uses: actions/setup-dotnet@v3
22+
with:
23+
dotnet-version: "8.0.100"
24+
25+
- name: Restore project
26+
run: |
27+
dotnet restore
28+
dotnet tool restore
29+
30+
- name: Build and pack solution
31+
run: |
32+
dotnet pack -c Release
33+
34+
- name: Upload thunderstore artifact
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: thunderstore-build
38+
path: |
39+
./*/assets/thunderstore.toml.user
40+
./*/bin/Release/netstandard2.1/dist/*.zip
41+
42+
- name: Upload nupkg artifact
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: nupkg-build
46+
path: ./*/bin/Release/*.nupkg
47+
48+
upload-release-artifacts:
49+
name: Upload Release Artifacts
50+
needs: build
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Fetch Sources
54+
uses: actions/checkout@v4
55+
56+
- name: Download all artifacts
57+
uses: actions/download-artifact@v4
58+
59+
- name: Upload artifacts to Release
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
run: gh release upload ${{ github.event.release.tag_name }} thunderstore-build/*/dist/*.zip nupkg-build/*/bin/Release/*.nupkg
63+
64+
deploy-nuget:
65+
name: Deploy to NuGet
66+
needs: build
67+
runs-on: ubuntu-latest
68+
steps:
69+
- name: Fetch Sources
70+
uses: actions/checkout@v4
71+
72+
- name: Download nupkg artifact
73+
uses: actions/download-artifact@v4
74+
with:
75+
name: nupkg-build
76+
77+
- name: Setup .NET environment
78+
uses: actions/setup-dotnet@v3
79+
with:
80+
dotnet-version: "8.0.100"
81+
82+
- name: Publish to NuGet.org
83+
run: |
84+
dotnet nuget push ./*/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_TOKEN }} --source https://api.nuget.org/v3/index.json
85+
86+
deploy-thunderstore:
87+
name: Deploy to Thunderstore
88+
needs: build
89+
runs-on: ubuntu-latest
90+
steps:
91+
- name: Fetch Sources
92+
uses: actions/checkout@v4
93+
94+
- name: Download Thunderstore artifact
95+
uses: actions/download-artifact@v4
96+
with:
97+
name: thunderstore-build
98+
99+
- name: Setup .NET environment
100+
uses: actions/setup-dotnet@v3
101+
with:
102+
dotnet-version: "8.0.100"
103+
104+
- name: Restore dotnet tools
105+
run: |
106+
dotnet tool restore
107+
108+
- name: Publish to Thunderstore
109+
env:
110+
TCLI_AUTH_TOKEN: ${{ secrets.THUNDERSTORE_API_TOKEN }}
111+
run: |
112+
dotnet build -target:ThunderstorePublish

0 commit comments

Comments
 (0)