-
Notifications
You must be signed in to change notification settings - Fork 11
88 lines (73 loc) · 2.42 KB
/
build-publish.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
name: Build and Publish
on:
push:
tags:
- '*'
branches:
- '*'
jobs:
build-publish-on-main:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up .NET Core
uses: actions/[email protected]
with:
dotnet-version: 6
- name: NuGet Restore
run: dotnet restore
- name: Build and Publish project
run: dotnet publish BattleBitAPIRunner/BattleBitAPIRunner.csproj -c Release -o ./publish
- name: Build nuget
run: dotnet build BattleBitAPIRunner/BattleBitAPIRunner.csproj -c Release
- name: Create NuGet package
run: dotnet pack BBRAPIModules/BBRAPIModules.csproj --no-build --output ./nuget
- name: Publish Release Assets
id: publish-assets
uses: softprops/action-gh-release@v1
with:
files: |
publish/*
nuget/*.nupkg
tag: ${{ github.ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release with Changelog
id: create-release
run: |
tag_name="${{ github.ref }}"
release_name="${{ github.ref }}"
previous_tag=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1))
changelog=$(git log --pretty=format:"- %s" $previous_tag..$tag_name)
body="Release ${{ github.ref }} Changelog:\n\n$changelog"
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
"https://api.github.com/repos/${{ github.repository }}/releases" \
-d '{
"tag_name": "'"${tag_name}"'",
"name": "'"${release_name}"'",
"body": "'"${body}"'",
"draft": false,
"prerelease": false
}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-check-on-commits:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up .NET Core
uses: actions/[email protected]
with:
dotnet-version: 6
- name: Build project and check for errors on non-main branch commits
run: |
dotnet build --configuration Release --no-restore
if [ $? -ne 0 ]; then
echo "Build failed"
exit 1
fi