xoofx / dotnet-releaser

Easily build, run tests and coverage, cross-compile, package and publish your .NET library or application to NuGet and GitHub.
BSD 2-Clause "Simplified" License
698 stars 25 forks source link

Unable to find a git repository from the folder .../src. This is required by the current action. #32

Closed panmona closed 2 years ago

panmona commented 2 years ago

I upgraded to the latest version of dotnet-releaser, but am now running into the following error when trying to publish a new version:

2022/03/01 23:20:36.887 fail: [9] Unable to find a git repository from the folder /Users/runner/work/switchtube-dl/switchtube-dl/src. This is required by the current action.

I tried using checkout-depth: 0 as indicated instead of 5 but it didn't help to solve it.

This is my toml file:

[msbuild]
project = "SwitchTubeDl/SwitchTubeDl.fsproj"
[github]
user = "panmau"
repo = "switchtube-dl"

[nuget]
publish = false

[brew]
home = "homebrew-panmau"

Am I missing anything obvious here that changed from 0.1. to 0.3.? Apart from the version upgrade and different action triggers I didn't change anything with my dotnet-releaser / project setup.

Thanks in advance for your help and continuous improvements of this amazing tool :yellow_heart:

Full build output:

── Configuring ─────────────────────────────────────────────────────────────────
  2022/03/01 23:20:31.236 info: [2] Running from GitHub: user = panmau, repo = switchtube-dl, event = release, ref_name = 0.0.7, ref_type = tag
  2022/03/01 23:20:31.243 info: [3] Loading configuration from /Users/runner/work/switchtube-dl/switchtube-dl/src/dotnet-releaser.toml
  2022/03/01 23:20:31.379 info: [5] Loading 1 projects
  2022/03/01 23:20:36.[12](https://github.com/panmau/switchtube-dl/runs/5383643751?check_suite_focus=true#step:7:12)1 info: [6] Packages and Projects
  ┌───────────────┬──────┬─────────┬────────────────────┬─────────┬───────────┬───────┐
  │ Project       │ Kind │ Version │ TargetFramework(s) │ License │ Packable? │ Test? │
  ├───────────────┼──────┼─────────┼────────────────────┼─────────┼───────────┼───────┤
  │ …             │      │         │                    │         │           │       │
  │ switchtube-dl │ exe  │ 0.0.7   │ net6.0             │ MIT     │     x     │       │
  └───────────────┴──────┴─────────┴────────────────────┴─────────┴───────────┴───────┘
  [20](https://github.com/panmau/switchtube-dl/runs/5383643751?check_suite_focus=true#step:7:20)[22](https://github.com/panmau/switchtube-dl/runs/5383643751?check_suite_focus=true#step:7:22)/03/01 [23](https://github.com/panmau/switchtube-dl/runs/5383643751?check_suite_focus=true#step:7:23):20:36.[24](https://github.com/panmau/switchtube-dl/runs/5383643751?check_suite_focus=true#step:7:24)2 info: [7] Connecting to GitHub
  2022/03/01 23:20:36.886 fail: [8] Unable to retrieve the current branch from the commit 5405988556a4deb2e6fda81077d7f96cc82c2da3. The current action requires it. Please make sure that:
  1) The current commit is a checkout on a valid branch.
  2) If running on GitHub Action, you are using `actions/checkout@v2` and not v1, but also that the property `fetch-depth: 0` is correctly setup.
  3) We have found the following branches containing this commit []. 

  2022/03/01 23:20:36.887 fail: [9] Unable to find a git repository from the folder /Users/runner/work/switchtube-dl/switchtube-dl/src. This is required by the current action.

Version Info

dotnet-releaser v0.3.4 .NET SDK v6.0.2 macOS

xoofx commented 2 years ago

It seems that your latest GitHub action went through on your repository? (the version 0.8.0-alpha.1 was published with 0.3.4?)

Also in your ci.yml, you should not need to perform the restore, build, run anymore on your own, as dotnet-releaser run should handle this entirely (it automatically do a publish only if there is a tag, otherwise it is a regular build). You should have something like this:

        steps:
            -   name: Checkout 🛎️
                uses: actions/checkout@v2
                with:
                    fetch-depth: 0

            -   name: Install .NET 6.0 🧳
                uses: actions/setup-dotnet@v1
                with:
                    dotnet-version: '6.0.x'

            -   name: Restore, Build, Tests, Publish (on tag) 🚀
                shell: bash
                run: |
                    dotnet tool install --global dotnet-releaser
                    dotnet-releaser run --github-token "${{secrets.GITHUB_TOKEN}}" --github-token-extra "${{secrets.TOKEN_GITHUB}}" src/dotnet-releaser.toml

Notice that there is --github-token which is using the default GITHUB_TOKEN created by GitHub Action, and the --github-token-extra with TOKEN_GITHUB that should be used for creating repository outside of your repo (e.g homebrew)

panmona commented 2 years ago

Thanks for taking a look. I'm not quite sure I understand how this tag got pushed, I didn't create it. Did dotnet-releaser push it? Why is that?

Thanks for making me aware that I can change the pipeline to this simpler version, which I will do, but I assume it won't change something about this behavior. Quick question about that: Would I need to provide the path to the sln file for the Tests to be automatically detected?

xoofx commented 2 years ago

Thanks for taking a look. I'm not quite sure I understand how this tag got pushed, I didn't create it. Did dotnet-releaser push it? Why is that?

You pushed a tag likely, dotnet-releaser doesn't do that.

Thanks for making me aware that I can change the pipeline to this simpler version, which I will do, but I assume it won't change something about this behavior.

No, it's just that now dotnet-releaser is handling the full build pipeline (build, test, coverage, packaging...)

Quick question about that: Would I need to provide the path to the sln file for the Tests to be automatically detected?

If the test is part of the solution, it should find it automatically. If it is not, you can add it as a list in [msbuild] project = ["your.sln", "your/test.csproj"]

panmona commented 2 years ago

I think the push of this tag was caused by the fact that I mistakenly still used 'dotnet-releaser publish ...' instead of 'dotnet-releaser run ...'.

I now updated the pipeline, as recommended, to the following:

name: ci

on:
    push:
        paths-ignore:
            - 'README.md'
            - 'RELEASE.md'
            - 'CONTRIBUTING.md'
    pull_request:

jobs:
    build:
        runs-on: macos-latest

        steps:
            -   name: Checkout 🛎️
                uses: actions/checkout@v2
                with:
                    fetch-depth: 0

            -   name: Install .NET 6.0 🧳
                uses: actions/setup-dotnet@v1
                with:
                    dotnet-version: '6.0.x'

            -   name: Restore, Build, Tests, Publish (on tag) 🚀
                run: |
                    dotnet tool install --global dotnet-releaser --version "0.3.*"
                    dotnet-releaser run --github-token "${{secrets.GITHUB_TOKEN}}" --github-token-extra "${{secrets.TOKEN_GITHUB}}" src/dotnet-releaser.toml

I now receive the following error:

  2022/03/02 22:30:40.737 info: [57] The configured homebrew destination repository is `panmau/homebrew-panmau`.
  2022/03/02 22:30:40.737 warn: [58] Warning, publishing a new Homebrew formula requires to use --github-token-extra. Using --github-token as a fallback but it might fail!
  2022/03/02 22:30:40.889 info: [59] Homebrew repository found panmau/homebrew-panmau
  2022/03/02 22:30:41.024 info: [60] Updating Homebrew Formula panmau/homebrew-panmau

Unexpected error Resource not accessible by integration
Error: Process completed with exit code 1.

I don't quite understand why this is happening. I provided github-token-extra, it is the same as before I updated dotnet-releaser but still it doesn't seem to correctly detect that it is there. It seems that the homebrew update is the step where it's failing. Do you have an idea what could be happening here?

xoofx commented 2 years ago

I don't quite understand why this is happening. I provided github-token-extra, it is the same as before I updated dotnet-releaser but still it doesn't seem to correctly detect that it is there. It seems that the homebrew update is the step where it's failing. Do you have an idea what could be happening here?

It is a stupid bug. Fixed by commit e4513d174ba838da54eebc332bdecd14fc048735. Should be available soon in 0.3.5+

panmona commented 2 years ago

Thanks for fixing this 💛 I now reran the pipeline but still receive this error:

  2022/03/03 19:36:55.867 info: [57] The configured homebrew destination repository is `panmau/homebrew-panmau`.
  2022/03/03 19:36:56.003 info: [58] Homebrew repository found panmau/homebrew-panmau
  2022/03/03 19:36:56.126 info: [59] Updating Homebrew Formula panmau/homebrew-panmau

Unexpected error Resource not accessible by integration
Error: Process completed with exit code 1.

It used the new version: Tool 'dotnet-releaser' (version '0.3.5') was successfully installed. And the warning is now gone. Do you have an idea what this could be?

xoofx commented 2 years ago

Do you have an idea what this could be?

Wow, ok, I must be very tired and/or I'm really stupid to fix this bug. This should be hopefully fixed by commit e2e0ac0a26aa407fb5ea5ac668bb35ee9bf28bea and available in 0.3.6. My apologize for this regression.

panmona commented 2 years ago

No worries it happens to the best of us. (the more code you write, the more bugs you write :)) Thanks for the fix, everything works now! 🎉