【发布时间】:2023-01-14 00:35:30
【问题描述】:
我按照这些资源设置了 GitHub Actions 工作流来构建、测试 dotnet 库并将其发布到 GitHub 包:
- Working with the NuGet registry
- A NuGet package workflow using GitHub Actions
- Publishing a NuGet package to GitHub Packages
这些文章真的很有帮助,但是我遇到了一个他们都没有讨论过的问题:
将 MagicLibrary.0.1.3.nupkg 推送到“https://nuget.pkg.github.com/vivere-dally”... 放https://nuget.pkg.github.com/vivere-dally/ 警告:GitHub Packages 服务无法验证您的请求。请确保您的访问令牌有效并且配置了适当的范围。 禁止 https://nuget.pkg.github.com/vivere-dally/ 218ms 错误:响应状态代码不表示成功:403(禁止访问)。
这是我的工作流程文件:
# This workflow will build a .NET project # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net name: Release on: push: tags: - "v[0-9]+.[0-9]+.[0-9]+" jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Verify commit exists in origin/main run: | git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* git branch --remote --contains | grep origin/main - name: Set VERSION env var from tag run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: 6.0.x - name: Restore dependencies run: dotnet restore working-directory: ./MagicLibrary - name: Build run: dotnet build --configuration Release /p:Version=${VERSION} --no-restore working-directory: ./MagicLibrary - name: Test run: dotnet test --configuration Release /p:Version=${VERSION} --no-build --verbosity normal working-directory: ./MagicLibrary - name: Pack run: dotnet pack --configuration Release /p:Version=${VERSION} --no-build --output . working-directory: ./MagicLibrary - name: Push run: dotnet nuget push MagicLibrary.${VERSION}.nupkg --source "https://nuget.pkg.github.com/vivere-dally/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} working-directory: ./MagicLibrary为什么
GITHUB_TOKEN没有所需的权限?
【问题讨论】:
标签: c# github nuget github-actions