Skip to content

Commit

Permalink
ci: split jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Dec 19, 2022
1 parent ab15ec4 commit a30bf02
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 61 deletions.
82 changes: 21 additions & 61 deletions .github/workflows/build.yml
Expand Up @@ -4,55 +4,25 @@ on:
push:

env:
CONFIGURATION: Release
DOTNET_NOLOGO: true # https://github.com/actions/setup-dotnet#environment-variables-to-use-with-dotnet



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


permissions:
contents: read

jobs:
test:

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2

- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: 6.0.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal

- name: Codecov
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
if: always()
with:
files: '*.cobertura.xml'

publish:
runs-on: windows-latest
needs: test

steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
with:
fetch-depth: 0
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2

- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
Expand All @@ -62,33 +32,23 @@ jobs:
- uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props') }}

- name: restore packages
run: dotnet restore EPPlus
# Look to see if there is a cache hit for the corresponding requirements file
# key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets') }}
# restore-keys: |
# ${{ runner.os }}-nuget

- name: build
run: dotnet build EPPlus --no-restore
- name: Restore dependencies
run: dotnet restore

- name: pack
run: dotnet pack EPPlus --no-build
- name: Build
run: dotnet build --no-restore

- name: publish to github
if: startsWith(github.ref, 'refs/tags/v')
run: |
dotnet nuget push *.nupkg \
-s https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json \
-k ${{ secrets.GITHUB_TOKEN }} \
--skip-duplicate
working-directory: EPPlus/bin/${{ env.CONFIGURATION }}
shell: bash
- name: Test
run: dotnet test --no-build --verbosity normal

- name: publish to nuget
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-')
run: |
dotnet nuget push *.nupkg \
-s nuget.org \
-k ${{ secrets.NUGET_API_KEY }} \
--skip-duplicate
working-directory: EPPlus/bin/${{ env.CONFIGURATION }}
shell: bash
- name: Codecov
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
if: always()
with:
files: '*.cobertura.xml'
74 changes: 74 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,74 @@
name: release

on:
push:
tags:
- v*

env:
CONFIGURATION: Release
DOTNET_NOLOGO: true

permissions:
contents: read

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

jobs:
release:
runs-on: windows-latest
timeout-minutes: 15
permissions:
packages: write
contents: write

steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0

- uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
# key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets') }}
# restore-keys: |
# ${{ runner.os }}-nuget

- name: restore
run: dotnet restore

- name: build
run: dotnet build --no-restore

- name: pack
run: dotnet pack -o bin

- uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
with:
name: packages
path: bin/*.nupkg

- name: deploy github.com
run: |
dotnet nuget add source --username $NUGET_USR --password $NUGET_PSW --store-password-in-clear-text --name github $NUGET_SOURCE
find bin -name '*.nupkg' | xargs dotnet nuget push -s github --skip-duplicate --force-english-output
shell: bash
env:
NUGET_SOURCE: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
NUGET_USR: ${{ github.repository_owner }}
NUGET_PSW: ${{ secrets.GITHUB_TOKEN }}

- name: deploy nuget.org
run: find bin -name '*.nupkg' | xargs dotnet nuget push -s $NUGET_SOURCE -k $NUGET_KEY --skip-duplicate --force-english-output
shell: bash
env:
NUGET_SOURCE: https://api.nuget.org/v3/index.json
NUGET_KEY: ${{ secrets.NUGET_API_KEY }}

- uses: marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0 # v1.2.1
if: ${{ !contains(github.ref_name, '-') }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
#prerelease: ${{ contains(github.ref_name, '-') }}

0 comments on commit a30bf02

Please sign in to comment.