Skip to content

Commit

Permalink
fix: caching and workflow_dispatch for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
lodicolo committed Mar 25, 2023
1 parent e7ebf3b commit ad42c54
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions .github/workflows/build.0.7.2-beta.yml
Expand Up @@ -5,6 +5,12 @@ on:
branches: [ "main" ]
paths-ignore:
- '.github/**'
workflow_dispatch:
inputs:
workflowDebug:
description: 'If the workflow should be debugged (skip release)'
default: true
type: boolean

permissions:
contents: write
Expand All @@ -24,31 +30,39 @@ jobs:
uses: actions/cache@v3
id: cache-binaries
with:
key: ${{ runner.os }}-binaries-${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}-${{ hashFiles('Intersect*/**/*.cs*') }}
path: |
Intersect*/bin/Release/**/Intersect*
key: ${{ runner.os }}-nuget-${{ hashFiles('Intersect.*/**/*.cs') }}
- name: Cache binaries result
if: inputs.workflowDebug == true
run: echo "steps.cache-binaries.outputs.cache-hit='${{ steps.cache-binaries.outputs.cache-hit }}'"

- name: Cache NuGet dependencies
if: steps.cache-binaries.outputs.cache-hit == 'false'
uses: actions/cache@v3.2.6
if: steps.cache-binaries.outputs.cache-hit != 'true'
uses: actions/cache@v3
id: cache-nuget
with:
key: ${{ runner.os }}-nuget-${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}-${{ hashFiles('Intersect*/*.csproj') }}
path: |
~/.nuget/packages
Intersect*/obj/project.assets.json
key: ${{ runner.os }}-nuget-${{ hashFiles('Intersect.*/*.csproj') }}
- name: Cache nuget result
if: inputs.workflowDebug == true
run: echo "steps.cache-nuget.outputs.cache-hit='${{ steps.cache-nuget.outputs.cache-hit }}'"

- name: Add msbuild to PATH
if: steps.cache-binaries.outputs.cache-hit == 'false' || steps.cache-nuget.outputs.cache-hit == 'false'
uses: microsoft/setup-msbuild@v1.3.1
if: steps.cache-binaries.outputs.cache-hit != 'true' && steps.cache-nuget.outputs.cache-hit != 'true'
uses: microsoft/setup-msbuild@v1
with:
msbuild-architecture: x64

- name: Setup NuGet.exe for use with actions
if: steps.cache-binaries.outputs.cache-hit == 'false' || steps.cache-nuget.outputs.cache-hit == 'false'
if: steps.cache-binaries.outputs.cache-hit != 'true' && steps.cache-nuget.outputs.cache-hit != 'true'
# You may pin to the exact commit or the version.
# uses: NuGet/setup-nuget@fd9fffd6ca4541cf4152a9565835ca1a88a6eb37
uses: NuGet/setup-nuget@v1.1.1
uses: NuGet/setup-nuget@v1
with:
# NuGet version to install. Can be `latest`, `preview`, a concrete version like `5.3.1`, or a semver range specifier like `5.x`.
nuget-version: latest # optional, default is latest
Expand All @@ -58,11 +72,11 @@ jobs:
# nuget-api-key-source: # optional

- name: Restore NuGet Packages
if: steps.cache-binaries.outputs.cache-hit == 'false' || steps.cache-nuget.outputs.cache-hit == 'false'
if: steps.cache-binaries.outputs.cache-hit != 'true' && steps.cache-nuget.outputs.cache-hit != 'true'
run: nuget restore Intersect.sln

- name: Build solution
if: steps.cache-binaries.outputs.cache-hit == 'false' || steps.cache-nuget.outputs.cache-hit == 'false'
if: steps.cache-binaries.outputs.cache-hit != 'true' && steps.cache-nuget.outputs.cache-hit != 'true'
run: msbuild Intersect.sln /p:Configuration=Release /p:PackageVersion=${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}+build.${{ github.sha }} /p:Version=0.7.2.${{ github.run_number }}

- name: Checkout assets main_upgrade branch
Expand All @@ -89,7 +103,16 @@ jobs:
bundle: .github/bundles/*.json
version: ${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}+build.${{ github.sha }}

- name: Upload artifacts for workflow debugging
if: inputs.workflowDebug == true
uses: actions/upload-artifact@v3
with:
name: workflow-debug
path: "dist/*.zip"


- name: Publish GitHub Release
if: inputs.workflowDebug != true
uses: softprops/action-gh-release@v0.1.15
with:
files: "dist/*.zip"
Expand All @@ -100,6 +123,7 @@ jobs:
target_commitish: ${{ github.sha }}

publish:
if: inputs.workflowDebug != true
needs: build
runs-on: ubuntu-latest
steps:
Expand Down

0 comments on commit ad42c54

Please sign in to comment.