Skip to content

Commit

Permalink
Feature/add releases (#233)
Browse files Browse the repository at this point in the history
* Create GitVersion.yml

* Update aspnetcore.yml
  • Loading branch information
samsmithnz authored Dec 16, 2020
1 parent 1152c1b commit 9f754b7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
51 changes: 34 additions & 17 deletions .github/workflows/aspnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,38 @@ on:

jobs:
build:

runs-on: windows-latest

runs-on: windows-latest
env:
buildVersion: 1.0.0.0 #The initial build version, but this is updated below
dotNetVersion: net5.0
dotNetConfiguration: Release
runtimeTarget: win-x86

outputs: # https://stackoverflow.com/questions/59175332/using-output-from-a-previous-job-in-a-new-one-in-a-github-action
version: ${{ steps.gitversion.outputs.nuGetVersionV2 }}
steps:
# checkout the repo
- uses: actions/checkout@v1

- name: Check variables
- uses: actions/checkout@v2
with:
fetch-depth: 0 #fetch-depth is needed for GitVersion

#Install and calculate the new version with GitVersion
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Determine Version
uses: gittools/actions/gitversion/[email protected]
id: gitversion # step id used as reference for output values
- name: Display GitVersion outputs
run: |
Write-Host "buildVersion: ${{ env.buildVersion }}"
Write-Host "dotNetVersion: ${{ env.dotNetVersion }}"
Write-Host "dotNetConfiguration: ${{ env.dotNetConfiguration }}"
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}"
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"
# install dependencies, build, and test
- name: Setup Dotnet for use with actions
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.100'
- name: Custom script to create a unique application version number for this build
run: FeatureFlags/BuildVersion.ps1 -ProjectFile "FeatureFlags/FeatureFlags.Web/FeatureFlags.Web.csproj"
shell: powershell

#Test service
- name: Variable Substitution appsettings file for tests
Expand All @@ -46,9 +51,9 @@ jobs:

#Publish dotnet objects
- name: DotNET Publish Web Service
run: dotnet publish FeatureFlags/FeatureFlags.Service/FeatureFlags.Service.csproj --configuration ${{ env.dotNetConfiguration }} -p:Version=${{env.buildVersion}} --self-contained true --runtime ${{env.runtimeTarget}}
run: dotnet publish FeatureFlags/FeatureFlags.Service/FeatureFlags.Service.csproj --configuration ${{ env.dotNetConfiguration }} -p:Version=${{ steps.gitversion.outputs.nuGetVersionV2 }} --self-contained true --runtime ${{env.runtimeTarget}}
- name: DotNET Publish Web Site
run: dotnet publish FeatureFlags/FeatureFlags.Web/FeatureFlags.Web.csproj --configuration ${{ env.dotNetConfiguration }} -p:Version=${{env.buildVersion}} --self-contained true --runtime ${{env.runtimeTarget}}
run: dotnet publish FeatureFlags/FeatureFlags.Web/FeatureFlags.Web.csproj --configuration ${{ env.dotNetConfiguration }} -p:Version=${{ steps.gitversion.outputs.nuGetVersionV2 }} --self-contained true --runtime ${{env.runtimeTarget}}
- name: DotNET Publish functional tests
run: dotnet publish FeatureFlags/FeatureFlags.FunctionalTests/FeatureFlags.FunctionalTests.csproj --configuration ${{ env.dotNetConfiguration }} --self-contained true --runtime ${{env.runtimeTarget}}
- name: Copy chromedriver for functional test
Expand Down Expand Up @@ -136,9 +141,21 @@ jobs:
runs-on: ubuntu-latest # Note, Azure CLI requires a Linux runner...
needs: [build, preDeploy]
#Only deploy if running off the master branch - we don't want to deploy off feature branches
#if: github.ref == 'refs/heads/master'
if: github.ref == 'refs/heads/master'

steps:
- name: Display GitVersion outputs
run: |
echo "version: ${{ needs.build.outputs.version }}"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ needs.build.outputs.version }}
release_name: Release ${{ needs.build.outputs.version }}

# Login with the secret SP details
- name: Log into Azure
uses: azure/login@v1
Expand Down
1 change: 1 addition & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
next-version: 1.2.0

0 comments on commit 9f754b7

Please sign in to comment.