Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish to CodeArtifact fails for Nuget packages #3561

Open
mtahir-cloudkitect opened this issue May 7, 2024 · 2 comments
Open

Publish to CodeArtifact fails for Nuget packages #3561

mtahir-cloudkitect opened this issue May 7, 2024 · 2 comments
Labels
needs-investigation Resolving this issue required further investigation

Comments

@mtahir-cloudkitect
Copy link

This is release YML

  release_nuget:
    name: Publish to NuGet Gallery
    needs: release
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write
    if: needs.release.outputs.tag_exists != 'true' && needs.release.outputs.latest_commit == github.sha
    steps:
      - uses: actions/setup-node@v4
        with:
          node-version: 18.x
      - uses: actions/setup-dotnet@v3
        with:
          dotnet-version: 3.x
      - name: Download build artifacts
        uses: actions/download-artifact@v4
        with:
          name: build-artifact
          path: dist
      - name: Restore build artifact permissions
        run: cd dist && setfacl --restore=permissions-backup.acl
        continue-on-error: true
      - name: Configure AWS Credentials via GitHub OIDC Provider
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::ACCOUNT_ID:role/GithubRole
          aws-region: us-west-2
      - name: Login
        run: echo CODE_ARTIFACT_CREDS=$(aws codeartifact get-authorization-token --domain domain --domain-owner ACCOUNT_ID --query authorizationToken --output text --region us-west-2) >> $GITHUB_ENV
      - name: Setup pnpm
        uses: pnpm/action-setup@v3
        with:
          version: "9"
      - name: Prepare Repository
        run: mv dist .repo
      - name: Install Dependencies
        run: cd .repo && pnpm i --no-frozen-lockfile
      - name: Create dotnet artifact
        run: cd .repo && npx projen package:dotnet
      - name: Collect dotnet Artifact
        run: mv .repo/dist dist
      - name: Release
        env:
          NUGET_API_KEY: ${{ env.CODE_ARTIFACT_CREDS }}
          NUGET_SERVER: SERVER_URL/
        run: npx -p publib@latest publib-nuget

And this is the error I am getting

Publishing ./Constructs.1.1.19.nupkg to NuGet
Pushing Constructs.1.1.19.nupkg to 'SERVER_URL/'...
PUT SERVER_URL
NotFound SERVER_URL 411ms
error: Response status code does not indicate success: 404 (Not Found)

SERVER_URL = https://domain-account_id.d.codeartifact.us-west-2.amazonaws.com/nuget/construct-artifacts/

If I use
SERVER_URL = https://domain-account_id.d.codeartifact.us-west-2.amazonaws.com/nuget/construct-artifacts/v3/index.json

Then I get different error

error: Unable to load the service index for source SERVER_URL.
error: Response status code does not indicate success: 401 (Unauthorized)

I have verified the NUGET_KEY gets the correct token assigned.

@mrgrain
Copy link
Contributor

mrgrain commented May 8, 2024

I'm not very familiar with this setup. Have you already double checked the publib docs?

https://github.com/cdklabs/publib?tab=readme-ov-file#nuget

@mrgrain
Copy link
Contributor

mrgrain commented May 8, 2024

Also from what you've posted I can't tell if SERVER_URL is being replaced be the actual value, or if it's used as it is a string.

@mrgrain mrgrain added the needs-investigation Resolving this issue required further investigation label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-investigation Resolving this issue required further investigation
Projects
None yet
Development

No branches or pull requests

2 participants