-
Notifications
You must be signed in to change notification settings - Fork 3
104 lines (88 loc) · 3.77 KB
/
release.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
name: release
on:
release:
types:
- published
env:
RELEASE_CLIENT: true
RELEASE_CONTRACT: true
RELEASE_JOB: false
RELEASE_SERVICE: true
CLIENT_PROJECT: ./client/MAVN.Service.OperationsHistory.Client/MAVN.Service.OperationsHistory.Client.csproj
CONTRACT_PROJECT: ./contract/MAVN.Service.OperationsHistory.Contract/MAVN.Service.OperationsHistory.Contract.csproj
JOB_DOCKER_IMAGE:
JOB_PROJECT:
SERVICE_DOCKER_IMAGE: operations-history-service
SERVICE_PROJECT: ./src/MAVN.Service.OperationsHistory/MAVN.Service.OperationsHistory.csproj
jobs:
publish-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Set release version
- name: Get release version from tag
id: version
uses: LykkeBusiness/[email protected]
with:
tag: ${{ github.ref }}
- name: Set version for release
uses: allenevans/[email protected]
with:
VERSION: ${{ steps.version.outputs.non-prefixed }}
# Login to Docker Hub
- name: Login to docker hub
if: env.RELEASE_JOB == 'true' || env.RELEASE_SERVICE == 'true'
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
# Build solution
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.302
- name: Install dependencies
run: dotnet restore
- name: Build solution
run: dotnet build --configuration Release --no-restore /p:Version=$VERSION
# Build Docker images
- name: Build docker image for a job
if: env.RELEASE_JOB == 'true'
run: |
dotnet publish $JOB_PROJECT --configuration Release --output ../../docker/job --no-build /p:Version=$VERSION
docker build --tag openmavn/$JOB_DOCKER_IMAGE:$VERSION ./docker/job
- name: Build docker image for a service
if: env.RELEASE_SERVICE == 'true'
run: |
dotnet publish $SERVICE_PROJECT --configuration Release --output ../../docker/service --no-build /p:Version=$VERSION
docker build --tag openmavn/$SERVICE_DOCKER_IMAGE:$VERSION ./docker/service
# Pack NuGet packages
- name: Pack client NuGet package
if: env.RELEASE_CLIENT == 'true'
run: dotnet pack $CLIENT_PROJECT --configuration Release --output ../../packages --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg /p:Version=$VERSION
- name: Pack contract NuGet package
if: env.RELEASE_CONTRACT == 'true'
run: dotnet pack $CONTRACT_PROJECT --configuration Release --output ../../packages --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg /p:Version=$VERSION
# Push Docker Images
- name: Push job docker image
if: env.RELEASE_JOB == 'true'
run: docker push openmavn/$JOB_DOCKER_IMAGE:$VERSION
- name: Push service docker image
if: env.RELEASE_SERVICE == 'true'
run: docker push openmavn/$SERVICE_DOCKER_IMAGE:$VERSION
# Push NuGet packages
- name: Push NuGet packages
if: env.RELEASE_CLIENT == 'true' || env.RELEASE_CONTRACT == 'true'
env:
API_KEY: ${{ secrets.NUGET_ORG_API_KEY }}
run: dotnet nuget push ./packages/**/*.nupkg --source https://api.nuget.org/v3/index.json --api-key $API_KEY
# Create next release draft
- name: Create next release draft
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: next
release_name: next
body:
draft: true