Skip to content

Commit

Permalink
Updated workflows.
Browse files Browse the repository at this point in the history
  • Loading branch information
syntax-tm committed Nov 21, 2023
1 parent 891df57 commit 74c7b80
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 29 deletions.
47 changes: 31 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,59 @@ name: Build

env:
ARTIFACT: SAM
PACKAGES: ${{ github.workspace }}/.nuget/packages

on:
workflow_call:
outputs:
artifact:
description: "The name of the artifact"
value: ${{ jobs.build.outputs.artifact }}
workflow_dispatch:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]

jobs:
build:

checkout:
runs-on: windows-latest
outputs:
artifact: ${{ steps.write_output.outputs.artifact }}

steps:
- uses: actions/checkout@v3
setup:
runs-on: windows-latest
needs: [checkout]
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
restore:
runs-on: windows-latest
needs: [setup]
steps:
- id: cache-restore
uses: actions/cache/restore@v3
with:
path: ${{ env.PACKAGES }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore .\src\SAM.sln
run: dotnet restore .\src\SAM.sln --packages ${{ env.PACKAGES }}
- id: cache-save
uses: actions/cache/save@v3
with:
path: ${{ env.PACKAGES }}
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
publish:
runs-on: windows-latest
needs: [restore]
steps:
- name: Publish
run: dotnet publish .\src\SAM\SAM.csproj -c Debug -a x86 -o publish
# - name: Test
# run: dotnet test --no-build --verbosity normal
run: dotnet publish .\src\SAM\SAM.csproj -c Debug -a x86 -o publish --no-restore
upload:
runs-on: windows-latest
needs: [publish]
steps:
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: ${{ env.ARTIFACT }}
path: publish
if-no-files-found: error
- id: write_output
name: Write Output
run: echo "artifact=${{ env.ARTIFACT }}.zip" >> $GITHUB_OUTPUT
14 changes: 4 additions & 10 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,15 @@ on:

jobs:

build:
uses: ./.github/workflows/build.yml
download:
runs-on: windows-latest
needs: build
steps:
- uses: actions/download-artifact@v3
with:
path: artifacts
create-release:
runs-on: windows-latest
needs: [build, download]
permissions:
contents: write
steps:
- uses: ./.github/workflows/build.yml
- uses: actions/download-artifact@v3
with:
path: artifacts
- uses: ncipollo/release-action@v1
with:
artifacts: artifacts/*
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Test

on:
workflow_dispatch:
push:
branches: [ "main", "master" ]

jobs:
test:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,6 @@ paket-files/

# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
*.pyc

**/packages.lock.json
2 changes: 2 additions & 0 deletions src/SAM.API/SAM.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<RestoreLockedMode Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</RestoreLockedMode>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
Expand Down
2 changes: 2 additions & 0 deletions src/SAM.Core/SAM.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<RestoreLockedMode Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</RestoreLockedMode>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
Expand Down
2 changes: 2 additions & 0 deletions src/SAM.Manager/SAM.Manager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
<SelfContained>true</SelfContained>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<RestoreLockedMode Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</RestoreLockedMode>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
Expand Down
2 changes: 2 additions & 0 deletions src/SAM/SAM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
<SelfContained>true</SelfContained>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<RestoreLockedMode Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</RestoreLockedMode>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
Expand Down

0 comments on commit 74c7b80

Please sign in to comment.