Skip to content

Commit

Permalink
Move to GitHub actions (#9)
Browse files Browse the repository at this point in the history
* move to gha, package and x-plat updates
  • Loading branch information
TimHess authored Feb 7, 2024
1 parent 9643ce7 commit 15ab821
Show file tree
Hide file tree
Showing 19 changed files with 165 additions and 271 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/build-and-stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Build and stage
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_VERSION: '8.0'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
checks: write
contents: read
statuses: write

jobs:
build:
name: Build and publish app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.

- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Set up dependency caching for faster builds
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: dotnet restore
run: dotnet restore

- name: dotnet build
run: dotnet build --no-restore /p:TreatWarningsAsErrors=True

- name: dotnet test
run: dotnet test --logger trx --results-directory "${{ runner.temp }}" --no-build

- name: dotnet test
uses: NasAmin/[email protected]
with:
TRX_PATH: "${{ runner.temp }}"
REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: dotnet publish
run: dotnet publish src/NetCoreToolService/Steeltoe.NetCoreToolService.csproj -o publish

- name: Upload artifact for deployment job
if: ${{ github.event_name != 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: published-app
path: publish

deploy:
name: Deploy
environment: production
needs:
- build
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: published-app

- name: Log into Azure CLI with service principal
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: ${{ vars.AZURE_WEBAPP_NAME }}
package: '.'
slot-name: 'production'
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project>

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Condition="!Exists('packages.config')">
<Version>3.4.*</Version>
<Version>3.6.*</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
8 changes: 2 additions & 6 deletions Steeltoe.NetCoreToolService.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.6.30114.105
# Visual Studio Version 17
VisualStudioVersion = 17.9.34414.90
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C742A7B8-80CA-4365-85CA-C29AA744CE54}"
EndProject
Expand All @@ -20,11 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Build.props = Directory.Build.props
docker-compose.yaml = docker-compose.yaml
Dockerfile = Dockerfile
kubernetes.yaml = kubernetes.yaml
stylecop.json = stylecop.json
Version.props = Version.props
azure-pipelines.yaml = azure-pipelines.yaml
setversion.sh = setversion.sh
EndProjectSection
EndProject
Global
Expand Down
15 changes: 7 additions & 8 deletions Version.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
</PropertyGroup>

<PropertyGroup>
<MicrosoftExtensionsVersion>5.0.*</MicrosoftExtensionsVersion>
<SteeltoeVersion>3.2.*</SteeltoeVersion>
<SwashbuckleVersion>6.1.*</SwashbuckleVersion>
<SwashbuckleVersion>6.5.0</SwashbuckleVersion>
</PropertyGroup>

<PropertyGroup>
<CoverletCollectorVersion>1.3.*</CoverletCollectorVersion>
<CoverletMsBuildVersion>2.9.*</CoverletMsBuildVersion>
<FluentAssertionsVersion>5.10.*</FluentAssertionsVersion>
<FluentAssertionsJsonVersion>5.5.*</FluentAssertionsJsonVersion>
<MicrosoftAspNetCoreMvcTestingVersion>3.1.*</MicrosoftAspNetCoreMvcTestingVersion>
<MicrosoftNetTestSdkVersion>16.7.*</MicrosoftNetTestSdkVersion>
<MoqVersion>4.14.*</MoqVersion>
<XunitVersion>2.4.*</XunitVersion>
<FluentAssertionsVersion>6.12.0</FluentAssertionsVersion>
<FluentAssertionsJsonVersion>6.1.0</FluentAssertionsJsonVersion>
<MicrosoftAspNetCoreMvcTestingVersion>8.0.1</MicrosoftAspNetCoreMvcTestingVersion>
<MicrosoftNetTestSdkVersion>17.9.0</MicrosoftNetTestSdkVersion>
<MoqVersion>4.18.4</MoqVersion>
<XunitVersion>2.6.6</XunitVersion>
</PropertyGroup>

</Project>
81 changes: 0 additions & 81 deletions azure-pipelines.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions global.json

This file was deleted.

12 changes: 0 additions & 12 deletions kubernetes/defaults.yaml

This file was deleted.

42 changes: 0 additions & 42 deletions kubernetes/net-core-tool-service.yaml

This file was deleted.

39 changes: 0 additions & 39 deletions src/Directory.Build.props

This file was deleted.

6 changes: 3 additions & 3 deletions src/NetCoreToolService/Controllers/NewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public async Task<ActionResult> GetTemplateProject(
var start = newCommand.Error.IndexOf(invalidOptionError, StringComparison.Ordinal) +
invalidOptionError.Length;
start = newCommand.Error.IndexOf("--", start, StringComparison.Ordinal) + "--".Length;
var end = newCommand.Error.IndexOf('\n', start);
var end = newCommand.Error.IndexOf(Environment.NewLine, start, StringComparison.Ordinal);
return NotFound($"Switch '{newCommand.Error[start..end]}' not found.");
}

Expand All @@ -218,7 +218,7 @@ public async Task<ActionResult> GetTemplateProject(
var start = newCommand.Error.IndexOf(invalidSwitchError, StringComparison.Ordinal) +
invalidSwitchError.Length;
start = newCommand.Error.IndexOf("--", start, StringComparison.Ordinal) + "--".Length;
var end = newCommand.Error.IndexOf('\n', start);
var end = newCommand.Error.IndexOf(Environment.NewLine, start, StringComparison.Ordinal);
return NotFound($"Switch '{newCommand.Error[start..end]}' not found.");
}

Expand All @@ -228,7 +228,7 @@ public async Task<ActionResult> GetTemplateProject(
var start = newCommand.Error.IndexOf(invalidParameterError, StringComparison.Ordinal) +
invalidParameterError.Length;
start = newCommand.Error.IndexOf("--", start, StringComparison.Ordinal) + "--".Length;
var end = newCommand.Error.IndexOf('\n', start);
var end = newCommand.Error.IndexOf(Environment.NewLine, start, StringComparison.Ordinal);
var nvp = newCommand.Error[start..end].Split(' ', 2);
return NotFound($"Option '{nvp[0]}' parameter '{nvp[1]}' not found.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/NetCoreToolService/Packagers/ZipPackager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void AddPathToArchive(ZipArchive archive, string rootPath, string path =
var directory = new DirectoryInfo(path);
if (path != rootPath)
{
var entry = archive.CreateEntry($"{Path.GetRelativePath(rootPath, path)}/");
var entry = archive.CreateEntry($"{Path.GetRelativePath(rootPath, path)}{Path.DirectorySeparatorChar}");
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
entry.ExternalAttributes = UnixDirectoryPermissions;
Expand Down
Loading

0 comments on commit 15ab821

Please sign in to comment.