Skip to content

Push Canary build only when building the main branch #182

Push Canary build only when building the main branch

Push Canary build only when building the main branch #182

Workflow file for this run

name: Build-Development
on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize
env:
AZURE_ARTIFACTS_FEED_URL: https://pkgs.dev.azure.com/misuzilla/Cocona/_packaging/Cocona-Canary/nuget/v3/index.json
DOTNET_NOLOGO: true
jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
source-url: ${{ env.AZURE_ARTIFACTS_FEED_URL }}
dotnet-version: |
3.1.x
6.0.x
8.0.x
env:
NUGET_AUTH_TOKEN: ${{ steps.op-load-secret.outputs.NUGET_AUTH_TOKEN }}
# Build
- run: dotnet restore
- run: dotnet build -c Release
# Run Unit tests
- run: dotnet test -c Release --no-build --logger trx --results-directory $GITHUB_WORKSPACE/artifacts
- name: Shellcheck for Bash completion
run: |
cd samples/GettingStarted.SubCommandApp
shellcheck <(dotnet run -- --completion bash)
# Packaging
- name: dotnet pack Cocona
run: dotnet pack -c Release --no-build --version-suffix "$(versionSuffix)" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output $GITHUB_WORKSPACE/artifacts ./src/Cocona/Cocona.csproj
- name: dotnet pack Cocona.Core
run: dotnet pack -c Release --no-build --version-suffix "$(versionSuffix)" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output $GITHUB_WORKSPACE/artifacts ./src/Cocona.Core/Cocona.Core.csproj
- name: dotnet pack Cocona.Lite
run: dotnet pack -c Release --no-build --version-suffix "$(versionSuffix)" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output $GITHUB_WORKSPACE/artifacts ./src/Cocona.Lite/Cocona.Lite.csproj
# Upload & Publish
- uses: actions/upload-artifact@v4
with:
name: Packages
path: artifacts
# Load secrets from 1Password
- uses: 1password/load-secrets-action@v2
if: ${{ github.event_name != 'pull_request' }}
id: op-load-secret
with:
export-env: false
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN_PUBLIC }}
NUGET_AUTH_TOKEN: "op://GitHub Actions - Public/NuGet - Azure Artifacts/credential"
- name: Publish NuGet packages to Azure Artifacts
if: ${{ github.event_name != 'pull_request' }}
run: |
dotnet nuget push --api-key AzureArtifacts $GITHUB_WORKSPACE/artifacts/*.nupkg
dotnet nuget push --api-key AzureArtifacts $GITHUB_WORKSPACE/artifacts/*.snupkg