Skip to content

Publish

Publish #28

Workflow file for this run

name: Publish
on:
workflow_dispatch:
inputs:
release_nuget:
description: 'Publish Nuget.org ?'
type: boolean
required: false
default: false
release_github:
description: 'Publish GitHub Packages ?'
type: boolean
required: false
default: true
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
GITHUB_ACTIONS: true
jobs:
build:
name: Build and pack
runs-on: ubuntu-latest
outputs:
Version: ${{ steps.gitversion.outputs.SemVer }}
IsNewVersion: ${{ steps.gitversion.outputs.CommitsSinceVersionSource > 0 }}
PreReleaseTag: ${{ steps.gitversion.outputs.NuGetPreReleaseTagV2 }}
steps:
- name: Checkout Branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: 5.x
- name: Determine Version
uses: gittools/actions/gitversion/[email protected]
id: gitversion
- name: Tool Restore
run: dotnet tool restore
- name: Test
run: dotnet nuke test
- name: Build and Pack NuGet package
run: |
dotnet pack src/Backdash --configuration Release --include-symbols -p:Version='${{ steps.gitversion.outputs.SemVer }}' --output ./build_artifacts
dotnet pack src/Backdash.Utils --configuration Release --include-symbols -p:Version='${{ steps.gitversion.outputs.SemVer }}' --output ./build_artifacts
dotnet pack src/Backdash.Analyzers --configuration Release --include-symbols -p:Version='${{ steps.gitversion.outputs.SemVer }}' --output ./build_artifacts
- name: Upload lib NuGet package artifact to GitHub
uses: actions/upload-artifact@v3
with:
name: buildArtifacts
path: ./build_artifacts
release_github:
name: Publish Github Packages
runs-on: ubuntu-latest
if: github.event.inputs.release_github == 'true' && github.ref == 'refs/heads/master' && needs.build.outputs.IsNewVersion
needs: build
steps:
- name: Download lib nuget package artifact
uses: actions/download-artifact@v3
with:
name: buildArtifacts
path: ./build_artifacts
- name: Add NuGet source
run: dotnet nuget add source --username lucasteles --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/lucasteles/index.json"
- name: Release GitHub package
run: dotnet nuget push build_artifacts/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "github"
release_nuget:
name: Publish Nuget
runs-on: ubuntu-latest
if: github.event.inputs.release_nuget == 'true' && github.ref == 'refs/heads/master' # && needs.build.outputs.CommitsSinceVersionSource > 0
needs: build
steps:
- name: Download lib nuget package artifact
uses: actions/download-artifact@v3
with:
name: buildArtifacts
path: ./build_artifacts
- name: Push package to Nuget
run: |
dotnet nuget push build_artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
- name: Create Release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.build.outputs.Version }}
prerelease: ${{ needs.build.outputs.PreReleaseTag }}
name: Release ${{ needs.build.outputs.Version }}
artifacts: "build_artifacts/*"
token: ${{ secrets.GITHUB_TOKEN }}