-
-
Notifications
You must be signed in to change notification settings - Fork 503
144 lines (131 loc) · 4.99 KB
/
build.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
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
name: .NET Core
on:
push:
pull_request:
release:
types:
- published
env:
# Stop wasting time caching packages
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending usage data to Microsoft
DOTNET_CLI_TELEMETRY_OPTOUT: true
# Project name to pack and publish
PROJECT_NAME: SqlKata
DOTNET_VERSION: 6.0.202
# DOTNET_VERSION: 5.0.201
# DOTNET_VERSION: 2.2.203
# GitHub Packages Feed settings
GITHUB_FEED: https://nuget.pkg.github.com/sqlkata/
GITHUB_USER: ahmad-moussawi
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Official NuGet Feed settings
NUGET_FEED: https://api.nuget.org/v3/index.json
NUGET_KEY: ${{ secrets.NUGET_KEY }}
DB_MYSQL_DATABASE: test_sqlkata
DB_MYSQL_USER: root
DB_MYSQL_PASSWORD: 'root'
DB_MYSQL_HOST: localhost
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Checking release
run: |
echo $RELEASE_VERSION
echo ${{ env.RELEASE_VERSION }}
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build -c Release --no-restore
- name: Start MySql
run: |
sudo /etc/init.d/mysql start
mysqladmin -u ${{ env.DB_MYSQL_USER }} -p${{ env.DB_MYSQL_PASSWORD }} password ''
mysql -e 'CREATE DATABASE ${{ env.DB_MYSQL_DATABASE }};' -u${{ env.DB_MYSQL_USER }}
mysql -e 'CREATE TABLE cars(id int primary key auto_increment);' -u${{ env.DB_MYSQL_USER }} ${{ env.DB_MYSQL_DATABASE }}
mysql -e 'SHOW TABLES;' -u${{ env.DB_MYSQL_USER }} ${{ env.DB_MYSQL_DATABASE }}
- name: Test
run: dotnet test -c Release
env:
SQLKATA_MYSQL_HOST: ${{ env.DB_MYSQL_HOST }}
SQLKATA_MYSQL_USER: ${{ env.DB_MYSQL_USER }}
SQLKATA_MYSQL_DB: ${{ env.DB_MYSQL_DATABASE }}
- name: Pack QueryBuilder
if: matrix.os == 'ubuntu-latest'
run: dotnet pack -v normal -c Release --no-restore --include-symbols --include-source --version-suffix=$GITHUB_RUN_ID QueryBuilder/QueryBuilder.csproj
- name: Pack SqlKata.Execution
if: matrix.os == 'ubuntu-latest'
run: dotnet pack -v normal -c Release --no-restore --include-symbols --include-source --version-suffix=$GITHUB_RUN_ID SqlKata.Execution/SqlKata.Execution.csproj
- name: Upload QueryBuilder Artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v2
with:
name: nupkg
path: ./QueryBuilder/bin/Release/*.nupkg
- name: Upload SqlKata.Execution Artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v2
with:
name: nupkg
path: ./SqlKata.Execution/bin/Release/*.nupkg
prerelease:
needs: build
if: github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
steps:
- name: Download Artifact
uses: actions/download-artifact@v1
with:
name: nupkg
- name: Push to GitHub Feed
run: |
for f in ./nupkg/*.nupkg
do
if [[ ${f} != *".symbols."* ]];then
echo "Uploading package $f" to $GITHUB_FEED
dotnet nuget push $f --api-key=$GITHUB_TOKEN --source=$GITHUB_FEED
fi
# curl -X PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
done
deploy:
needs: build
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Create Release NuGet package (QueryBuilder)
run: |
arrTag=(${GITHUB_REF//\// })
VERSION="${arrTag[2]}"
echo Version: $VERSION
VERSION="${VERSION//v}"
echo Clean Version: $VERSION
dotnet pack -v normal -c Release --include-symbols --include-source -p:Version=$VERSION -p:PackageVersion=$VERSION -o nupkg QueryBuilder/QueryBuilder.csproj
- name: Create Release NuGet package (SqlKata.Execution)
run: |
arrTag=(${GITHUB_REF//\// })
VERSION="${arrTag[2]}"
echo Version: $VERSION
VERSION="${VERSION//v}"
echo Clean Version: $VERSION
dotnet pack -v normal -c Release --include-symbols --include-source -p:Version=$VERSION -p:PackageVersion=$VERSION -o nupkg SqlKata.Execution/SqlKata.Execution.csproj
- name: Push to GitHub Feed
run: dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --source $GITHUB_FEED --api-key $GITHUB_TOKEN
- name: Push to NuGet Feed
run: dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --source $NUGET_FEED --api-key $NUGET_KEY