Skip to content

Publish

Publish #556

Workflow file for this run

name: Publish
on:
workflow_dispatch:
release:
types: [released]
workflow_run:
workflows: [Scheduled release]
types:
- completed
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ['8.0.x']
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install GitVersion # https://github.com/GitTools/actions/blob/main/docs/examples/github/gitversion/setup/usage-examples.md
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion # id to later be referenced
uses: gittools/actions/gitversion/execute@v0
with:
useConfigFile: true
additionalArguments: '/updateprojectfiles'
- name: Get Latest NuGet Version
id: nuget_version
run: |
VERSION=$(curl -s https://api.nuget.org/v3-flatcontainer/nox.lib/index.json | jq -r '.versions[-1]')
echo "Latest NuGet Version: $VERSION"
echo "nuget_version=$VERSION" >> $GITHUB_ENV
- name: Check Version
run: |
if [ "${{ steps.gitversion.outputs.nuGetVersion }}" = "${{ env.nuget_version }}" ]; then
echo "The determined version is the same as the current NuGet version. Cancelling the workflow."
exit 0
fi
- name: Display GitVersion outputs (step output)
run: |
echo "Branch: ${{ github.ref }}"
echo "Major: ${{ steps.gitversion.outputs.major }}"
echo "Minor: ${{ steps.gitversion.outputs.minor }}"
echo "Patch: ${{ steps.gitversion.outputs.patch }}"
echo "PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}"
echo "PreReleaseTagWithDash: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}"
echo "PreReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}"
echo "PreReleaseNumber: ${{ steps.gitversion.outputs.preReleaseNumber }}"
echo "WeightedPreReleaseNumber: ${{ steps.gitversion.outputs.weightedPreReleaseNumber }}"
echo "BuildMetaData: ${{ steps.gitversion.outputs.buildMetaData }}"
echo "BuildMetaDataPadded: ${{ steps.gitversion.outputs.buildMetaDataPadded }}"
echo "FullBuildMetaData: ${{ steps.gitversion.outputs.fullBuildMetaData }}"
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}"
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
echo "LegacySemVer: ${{ steps.gitversion.outputs.legacySemVer }}"
echo "LegacySemVerPadded: ${{ steps.gitversion.outputs.legacySemVerPadded }}"
echo "AssemblySemVer: ${{ steps.gitversion.outputs.assemblySemVer }}"
echo "AssemblySemFileVer: ${{ steps.gitversion.outputs.assemblySemFileVer }}"
echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}"
echo "InformationalVersion: ${{ steps.gitversion.outputs.informationalVersion }}"
echo "BranchName: ${{ steps.gitversion.outputs.branchName }}"
echo "EscapedBranchName: ${{ steps.gitversion.outputs.escapedBranchName }}"
echo "Sha: ${{ steps.gitversion.outputs.sha }}"
echo "ShortSha: ${{ steps.gitversion.outputs.shortSha }}"
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"
echo "NuGetVersion: ${{ steps.gitversion.outputs.nuGetVersion }}"
echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}"
echo "NuGetPreReleaseTag: ${{ steps.gitversion.outputs.nuGetPreReleaseTag }}"
echo "VersionSourceSha: ${{ steps.gitversion.outputs.versionSourceSha }}"
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}"
echo "CommitsSinceVersionSourcePadded: ${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}"
echo "UncommittedChanges: ${{ steps.gitversion.outputs.uncommittedChanges }}"
echo "CommitDate: ${{ steps.gitversion.outputs.commitDate }}"
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Restore
run: dotnet restore Nox.sln
- name: Build
run: |
dotnet build ./src/Nox.Generator.Tasks --no-restore
dotnet build Nox.sln --warnaserror --configuration Release --no-restore --no-incremental /p:ContinuousIntegrationBuild=true
- name: Pack Nox (Solution)
run: dotnet pack --no-build Nox.sln --configuration Release -o ./artifacts
- name: Pack Nox (Tasks)
run: |
dotnet build ./src/Nox.Generator.Tasks --warnaserror --configuration Release --no-restore --no-incremental /p:ContinuousIntegrationBuild=true
dotnet pack --no-build ./src/Nox.Generator.Tasks --configuration Release -o ./artifacts
- name: Publish Nox
if: contains(github.ref,'refs/tags/v') || contains(github.ref,'refs/heads/main')
run: dotnet nuget push ./artifacts/Nox.*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json
- name: Publish Nox.Lib Warning
if: contains(github.ref,'refs/tags/v') == false && contains(github.ref,'refs/heads/main') == false
run: echo "Skipping publishing, not in main branch or not building a tag. Current ${{ github.ref }}"