diff --git a/.azure-pipelines/build.yml b/.azure-pipelines/build.yml index 6e7582c..f709555 100644 --- a/.azure-pipelines/build.yml +++ b/.azure-pipelines/build.yml @@ -24,13 +24,8 @@ 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() @@ -38,35 +33,6 @@ jobs: 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') @@ -79,13 +45,7 @@ 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() @@ -93,62 +53,44 @@ jobs: 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)' diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 036d4c7..84c6b24 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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 @@ -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