Skip to content

Commit

Permalink
Update workflow template.
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenCleary committed Dec 2, 2023
1 parent 4ab1447 commit 6f27e72
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# build.yml v1.4
# build.yml v1.5
# 1.5:
# - Use bash syntax
# - Avoid set-output
# - Updates: actions/cache@v3, actions/checkout@v3, actions/upload-artifact@v3, codecov/codecov-action@v3, WyriHaximus/github-action-get-previous-tag@v1
# - Work around SDK bug (https://github.com/dotnet/sdk/issues/17461)
# - Use pre-release ProjProps.
# 1.4 - Avoid set-env.
# 1.3 - Include tag workflow in this file.
# 1.2 - Define DOTNET_SKIP_FIRST_TIME_EXPERIENCE/NUGET_XMLDOC_MODE.
Expand All @@ -15,6 +21,7 @@ env:
DOTNET_CLI_TELEMETRY_OPTOUT: 'true'
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 'true'
NUGET_XMLDOC_MODE: 'skip'
MSBuildEnableWorkloadResolver: 'false' # Work around SDK bug https://github.com/dotnet/sdk/issues/17461

jobs:
build:
Expand All @@ -25,35 +32,36 @@ jobs:
env:
CONTEXT: ${{ toJson(github) }}
run: |
echo "Context: $Env:CONTEXT"
echo "Context is available above"
- name: Determine cache fallbacks
if: github.event_name != 'push'
id: cache_fallbacks
run: |
echo "::set-output name=nuget::nuget-"
echo "name=nuget::nuget-" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 0 # Required by WyriHaximus/github-action-get-previous-tag@v1

- name: Cache nuget
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: nuget-${{ hashFiles('**/*.csproj') }}-${{ hashFiles('**/*.props') }}
restore-keys: ${{ steps.cache_fallbacks.outputs.nuget }}

- name: Get existing tag
id: existingtag
uses: WyriHaximus/github-action-get-previous-tag@0.2.0
uses: WyriHaximus/github-action-get-previous-tag@v1
continue-on-error: true

- name: Get current version
run: |
dotnet tool install --global Nito.ProjProps
echo "NEWTAG=v$(projprops --name version --output-format SingleValueOnly --project src --project-search)" >> $GITHUB_ENV
dotnet tool install --global Nito.ProjProps --version 2.0.0-pre01
echo "NEWTAG=v$(projprops --name version --project src)"
echo "NEWTAG=v$(projprops --name version --project src)" >> $GITHUB_ENV
- name: Build
run: |
Expand All @@ -62,15 +70,15 @@ jobs:
dotnet pack --configuration Release --no-build
- name: Upload package artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: nuget-packages
path: |
**/*.nupkg
**/*.snupkg
- name: Publish code coverage
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3

- name: Publish packages
if: env.NEWTAG != steps.existingtag.outputs.tag
Expand Down

0 comments on commit 6f27e72

Please sign in to comment.