Skip to content

Commit

Permalink
Merge pull request #6 from LykkeBusiness/add-release-workflow
Browse files Browse the repository at this point in the history
Merge release workflow
  • Loading branch information
PaterSantyago authored Apr 9, 2020
2 parents 35d56a8 + 529578f commit 1f846d8
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 25 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/build-and-test.yml

This file was deleted.

104 changes: 104 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: release

on:
release:
types:
- published

env:
RELEASE_CLIENT: true
RELEASE_CONTRACT: true
RELEASE_JOB: true
RELEASE_SERVICE: true

CLIENT_PROJECT: ./client/MAVN.Service.Staking.Client/MAVN.Service.Staking.Client.csproj
CONTRACT_PROJECT: ./contract/MAVN.Service.Staking.Contract/MAVN.Service.Staking.Contract.csproj
JOB_DOCKER_IMAGE: staking-job
JOB_PROJECT: ./src/MAVN.Job.Staking/MAVN.Job.Staking.csproj
SERVICE_DOCKER_IMAGE: staking-service
SERVICE_PROJECT: ./src/MAVN.Service.Staking/MAVN.Service.Staking.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: 2.2.207
- 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: calculate coverage
name: test

on:
pull_request:
branches: [ master ]
push:
branches: [ master ]

Expand All @@ -22,6 +24,7 @@ jobs:
- name: Test
run: dotnet test --no-restore --verbosity normal /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov
- name: Publish coverage report
if: github.event_name == 'push'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MAVN.Service.Staking

![calculate coverage](https://github.com/OpenMAVN/MAVN.Service.Staking/workflows/calculate%20coverage/badge.svg)
![test](https://github.com/OpenMAVN/MAVN.Service.Staking/workflows/test/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/OpenMAVN/MAVN.Service.Staking/badge.svg?branch=master)](https://coveralls.io/github/OpenMAVN/MAVN.Service.Staking?branch=master)

0 comments on commit 1f846d8

Please sign in to comment.