-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (80 loc) · 3.08 KB
/
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
name: publish
on:
push:
branches: [ master, develop ]
jobs:
build:
runs-on: self-hosted
environment: CommonEnv
env:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
steps:
- uses: actions/checkout@v3
with:
token: ${{secrets.PAT_TOKEN}}
- name: Setup .NET Core SDK 3.1.x
uses: actions/[email protected]
with:
dotnet-version: '7.0.x'
- name: Restore .Net
run: dotnet restore src
- name: Configure version
run: |
git fetch --unshallow
lastTag=$(git describe --tags --abbrev=0)
lastTagMainVersion=$(sed -n 's/^\([0-9]*\.[0-9]*\).*/\1/p' <<<"$lastTag")
currentVersion=$(cat VERSION)
currentMainVersion=$(sed -n 's/^\([0-9]*\.[0-9]*\).*/\1/p' <VERSION)
if [ "$lastTagMainVersion" = "$currentMainVersion" ]
then
echo "Version the same."
lastTagBuildVersion=$(sed -n 's/^[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/p' <<<"$lastTag")
newBuildVersion=$((lastTagBuildVersion+1))
newVersion="$lastTagMainVersion"."$newBuildVersion"
echo "newVersion=$newVersion"
echo "newVersion=$newVersion" >> $GITHUB_ENV
else
echo "New version!"
newVersion="$currentMainVersion".1
VersionPrefix=$newVersion
echo "newVersion=$newVersion"
echo "newVersion=$newVersion" >> $GITHUB_ENV
fi
sed -i '' -e "s/\(<Version>\)\(.*\)\(<\/Version>\)/\1$newVersion\3/" src/UnityMVVM/UnityMVVM.csproj
- name: Run tests
run: dotnet test src --verbosity normal
- name: Build for demo project
run: ./BuildForDemo.command
- name: Demo project tests
run: |
/Applications/Unity/Hub/Editor/2022.3.8f1/Unity.app/Contents/MacOS/Unity -runTests -batchmode -projectPath DemoUnityProj/CCG -testResults relults.xml -testPlatform EditMode
- name: Build
run: dotnet build src/UnityMVVM.sln --no-dependencies --property:OutputPath=build
- name: Publish package to GitHub
if: github.ref == 'refs/heads/master'
run: |
dotnet nuget push src/UnityMVVM/build/*.nupkg --skip-duplicate --api-key ${{secrets.PAT_TOKEN}} --source github
- name: Publish package to Nuget
if: github.ref == 'refs/heads/master'
run: |
dotnet nuget push src/UnityMVVM/build/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json
- name: Zip build
run: zip UnityMVVM.zip src/UnityMVVM/build/UnityMVVM.dll src/UnityMVVM/build/UnityMVVM.xml
- name: Create Release
if: github.ref == 'refs/heads/master'
uses: ncipollo/release-action@v1
with:
tag: ${{ env.newVersion }}
name: Release ${{ env.newVersion }}
artifacts: "src/UnityMVVM/build/*.nupkg, UnityMVVM.zip"
token: ${{ secrets.PAT_TOKEN }}
- name: Tag non-release
if: github.ref != 'refs/heads/master'
run: |
git tag ${{ env.newVersion }}
git push --tags
- name: Expose as artifact
uses: actions/[email protected]
with:
name: Build
path: src/UnityMVVM/build