Skip to content

Commit

Permalink
ci: add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Jan 5, 2023
1 parent 751a508 commit dab693c
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ name: build

on:
push:
branches:
- main
- 'renovate/**'
pull_request:
branches: [main]

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

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
Expand All @@ -21,6 +19,7 @@ jobs:

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

- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
Expand All @@ -35,7 +34,9 @@ jobs:

- name: Restore dependencies
run: dotnet restore

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

- name: Test
run: dotnet test --no-build --verbosity normal
70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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@4723a57e26efda3a62cbde1812113b730952852d # v3.2.2
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 --no-build -o bin

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

- name: deploy github.com
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://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
NUGET_KEY: ${{ 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
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: ${{ contains(github.ref_name, '-') }}

0 comments on commit dab693c

Please sign in to comment.