Create Release #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create release workflow. | |
# gets sources | |
# Bump build version | |
# builds, tests and publish nuget package to artifacts | |
# commmit updated version to the repository | |
name: Create Release | |
# Controls when the action will run. Workflow runs when manually triggered using the UI | |
# or API. | |
on: | |
workflow_dispatch: | |
# Inputs the workflow accepts. | |
inputs: | |
publish_nuget: | |
type: boolean | |
description: 'Publish nuget package to github' | |
default: true | |
required: true | |
publish_nuget_org: | |
type: boolean | |
description: 'Publish nuget package to nuget.org' | |
default: false | |
required: true | |
checkin_version: | |
type: boolean | |
description: 'Check in version update' | |
default: true | |
required: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.BUILD_SVC_PAT }} | |
- name: Validate user | |
if: ${{ github.triggering_actor != 'bjornbouetsmith' }} | |
run: exit 1 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 6.0.x | |
- name: Restore dependencies | |
run: | | |
dotnet nuget add source --username ${{ github.triggering_actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/bjornbouetsmith/index.json" | |
dotnet restore Source/ROOT.Zfs.sln | |
- name: Update version | |
id: update_version | |
uses: vers-one/[email protected] | |
with: | |
file: Source/Directory.Build.props | |
version: bump-build | |
- name: Build | |
run: dotnet build Source/ROOT.Zfs.sln --no-restore --configuration Release | |
- name: Test | |
run: dotnet test Source/**/*.Tests.csproj --no-build --verbosity normal --configuration Release --filter "TestCategory!=Integration" | |
- name: check in version update | |
id: run_git_commit | |
if: ${{ inputs.checkin_version }} | |
run: | | |
git config user.name "${{ github.triggering_actor }}" | |
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" | |
git add . | |
git commit -m "Update version to ${{ steps.update_version.outputs.newVersion }}" | |
git push -f | |
git tag "v${{ steps.update_version.outputs.newVersion }}" | |
git push --tags -f | |
- name: publish nuget to github repository | |
if: ${{ inputs.publish_nuget }} | |
run: dotnet nuget push Source/**/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate --source "github" | |
- name: publish nuget to nuget.org repository | |
if: ${{ inputs.publish_nuget_org }} | |
run: dotnet nuget push Source/**/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate --source https://api.nuget.org/v3/index.json |