Skip to content

Commit

Permalink
Update GHA and AZP workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
mayuki committed Apr 16, 2024
1 parent 28257ec commit 1db11ed
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 106 deletions.
144 changes: 43 additions & 101 deletions .azure-pipelines/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,49 +24,15 @@ jobs:
inputs:
packageType: 'sdk'
version: 8.0.x
- script: dotnet restore
displayName: dotnet restore

- script: dotnet build -c Release
displayName: dotnet build

- script: dotnet test -c Release --no-build --logger trx
- script: dotnet test -c Release --logger trx
displayName: dotnet test
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: VSTest
testResultsFiles: '**/*.trx'

- script: |
cd samples/GettingStarted.SubCommandApp
shellcheck <(dotnet run -- --completion bash)
displayName: Shellcheck for Bash completion
# NOTE: Currently, Shellcheck doesn't support zsh script.
#- script: |
# cd samples/GettingStarted.SubCommandApp
# shellcheck <(dotnet run -- --completion zsh)
# displayName: Shellcheck for Zsh completion

- script: dotnet pack -c Release --no-build --version-suffix "$(versionSuffix)" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output $BUILD_ARTIFACTSTAGINGDIRECTORY ./src/Cocona/Cocona.csproj
displayName: dotnet pack Cocona
- script: dotnet pack -c Release --no-build --version-suffix "$(versionSuffix)" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output $BUILD_ARTIFACTSTAGINGDIRECTORY ./src/Cocona.Core/Cocona.Core.csproj
displayName: dotnet pack Cocona.Core
- script: dotnet pack -c Release --no-build --version-suffix "$(versionSuffix)" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output $BUILD_ARTIFACTSTAGINGDIRECTORY ./src/Cocona.Lite/Cocona.Lite.csproj
displayName: dotnet pack Cocona.Lite

# Publish to Azure Artifacts
- task: NuGetAuthenticate@0
displayName: 'NuGet Authenticate'
- task: NuGetCommand@2
displayName: 'NuGet push'
inputs:
command: 'push'
nuGetFeedType: 'internal'
publishVstsFeed: 'fb5f5542-197b-4b74-85dc-e7028e5541de/72ea1975-d994-41bf-b517-185b51130c29'
allowPackageConflicts: true

# ========================================
- job: Build_PullRequest
condition: startsWith(variables['Build.SourceBranch'], 'refs/pull')
Expand All @@ -79,76 +45,52 @@ jobs:
inputs:
packageType: 'sdk'
version: 8.0.x
- script: dotnet restore
displayName: dotnet restore

- script: dotnet build -c Release
displayName: dotnet build

- script: dotnet test -c Release --no-build --logger trx
- script: dotnet test -c Release --logger trx
displayName: dotnet test
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: VSTest
testResultsFiles: '**/*.trx'

- script: |
cd samples/GettingStarted.SubCommandApp
shellcheck <(dotnet run -- --completion bash)
displayName: Shellcheck for Bash completion
# NOTE: Currently, Shellcheck doesn't support zsh script.
#- script: |
# cd samples/GettingStarted.SubCommandApp
# shellcheck <(dotnet run -- --completion zsh)
# displayName: Shellcheck for Zsh completion

- script: dotnet pack -c Release --no-build --version-suffix "$(versionSuffix)" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output $BUILD_ARTIFACTSTAGINGDIRECTORY ./src/Cocona/Cocona.csproj
displayName: dotnet pack
- script: dotnet pack -c Release --no-build --version-suffix "$(versionSuffix)" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output $BUILD_ARTIFACTSTAGINGDIRECTORY ./src/Cocona.Core/Cocona.Core.csproj
displayName: dotnet pack Cocona.Core
- script: dotnet pack -c Release --no-build --version-suffix "$(versionSuffix)" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output $BUILD_ARTIFACTSTAGINGDIRECTORY ./src/Cocona.Lite/Cocona.Lite.csproj
displayName: dotnet pack Cocona.Lite

# ========================================
- job: Release
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
useGlobalJson: true

- script: |
echo "##vso[task.setvariable variable=versionSuffix]"
displayName: Unset version suffix
condition: not(contains(variables['Build.SourceBranchName'], '-preview'))
- script: |
VERSION_SUFFIX=$(echo $BUILD_SOURCEBRANCHNAME | sed 's|^v[^-]*-||')
echo "VersionSuffix: $VERSION_SUFFIX"
echo "##vso[task.setvariable variable=versionSuffix]$VERSION_SUFFIX"
displayName: Set version suffix for preview
condition: contains(variables['Build.SourceBranchName'], '-preview')
- script: dotnet restore
displayName: dotnet restore

- script: dotnet build -c Release
displayName: dotnet build

- script: dotnet pack -c Release --no-build --version-suffix "$(versionSuffix)" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output $BUILD_ARTIFACTSTAGINGDIRECTORY ./src/Cocona/Cocona.csproj
displayName: dotnet pack Cocona
- script: dotnet pack -c Release --no-build --version-suffix "$(versionSuffix)" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output $BUILD_ARTIFACTSTAGINGDIRECTORY ./src/Cocona.Core/Cocona.Core.csproj
displayName: dotnet pack Cocona.Core
- script: dotnet pack -c Release --no-build --version-suffix "$(versionSuffix)" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output $BUILD_ARTIFACTSTAGINGDIRECTORY ./src/Cocona.Lite/Cocona.Lite.csproj
displayName: dotnet pack Cocona.Lite

# Publish to NuGet.org
- task: NuGetCommand@2
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.snupkg'
nuGetFeedType: 'external'
publishFeedCredentials: 'NuGet.org (mayuki)'
# # ========================================
# - job: Release
# condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
# steps:
# - task: UseDotNet@2
# inputs:
# packageType: 'sdk'
# useGlobalJson: true
#
# - script: |
# echo "##vso[task.setvariable variable=versionSuffix]"
# displayName: Unset version suffix
# condition: not(contains(variables['Build.SourceBranchName'], '-preview'))
#
# - script: |
# VERSION_SUFFIX=$(echo $BUILD_SOURCEBRANCHNAME | sed 's|^v[^-]*-||')
# echo "VersionSuffix: $VERSION_SUFFIX"
# echo "##vso[task.setvariable variable=versionSuffix]$VERSION_SUFFIX"
# displayName: Set version suffix for preview
# condition: contains(variables['Build.SourceBranchName'], '-preview')
#
# - script: dotnet restore
# displayName: dotnet restore
#
# - script: dotnet build -c Release
# displayName: dotnet build
#
# - script: dotnet pack -c Release --no-build --version-suffix "$(versionSuffix)" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output $BUILD_ARTIFACTSTAGINGDIRECTORY ./src/Cocona/Cocona.csproj
# displayName: dotnet pack Cocona
# - script: dotnet pack -c Release --no-build --version-suffix "$(versionSuffix)" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output $BUILD_ARTIFACTSTAGINGDIRECTORY ./src/Cocona.Core/Cocona.Core.csproj
# displayName: dotnet pack Cocona.Core
# - script: dotnet pack -c Release --no-build --version-suffix "$(versionSuffix)" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output $BUILD_ARTIFACTSTAGINGDIRECTORY ./src/Cocona.Lite/Cocona.Lite.csproj
# displayName: dotnet pack Cocona.Lite
#
# # Publish to NuGet.org
# - task: NuGetCommand@2
# inputs:
# command: 'push'
# packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.snupkg'
# nuGetFeedType: 'external'
# publishFeedCredentials: 'NuGet.org (mayuki)'
29 changes: 24 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,32 @@ on:
- 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
env:
DOTNET_NOLOGO: true
steps:
- uses: actions/checkout@v1
- uses: actions/setup-dotnet@v1
# Load secrets from 1Password
- uses: 1password/load-secrets-action/configure@v1
id: op-load-secret
with:
export-env: false
service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN_PUBLIC }}
env:
NUGET_AUTH_TOKEN: "op://GitHub Actions - Public/NuGet - Azure Artifacts/credential"

- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
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
Expand All @@ -43,7 +56,13 @@ jobs:
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@master
- uses: actions/upload-artifact@v4
with:
name: Packages
path: artifacts

- 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

0 comments on commit 1db11ed

Please sign in to comment.