mooltiverse / nyx

The one stop semantic release tool
https://github.com/mooltiverse/nyx
Apache License 2.0
116 stars 8 forks source link

How to setup `nyx` to release with Gitlab CI/CD? #291

Closed sh-cau closed 9 months ago

sh-cau commented 9 months ago

I want to have a scheduled release, say, each week using a Gitlab pipeline. Unfortunately, there's no real example on how to do this. I want nyx to take care of that by setting up my .gitlab_ci.yml as follows:

image: 
  name: "mooltiverse/nyx:latest"
  entrypoint: [""]

variables:
  GIT_STRATEGY: clone
  GIT_DEPTH: "0"

stages:
  - release

release:
  stage: release
  tags:
    - docker
  rules:
    - if: '$CI_COMMIT_BRANCH=="master"'
  script:
    - git config --global user.name $GITLAB_USER_LOGIN
    - git config --global user.email $GITLAB_USER_EMAIL
    - nyx --debug publish

I had to include the git config bits because otherwise nyx complained that an author must be configured in order to push back to gitlab.

Unfortunately, I get the error

time="2024-02-26T13:20:20Z" level=debug msg="attempting push to 'origin' using user name and password credentials."
time="2024-02-26T13:20:20Z" level=debug msg="pushing changes to remote repository 'origin' using username and password"
time="2024-02-26T13:20:20Z" level=debug msg="username and password authentication will use custom authentication options"
an error occurred when trying to push: authentication required

in the Gitlab pipeline with a gitlab runner. I've set up the .nyx.yaml as described in #289, i.e., it should authenticate with a token GITLAB_TOKEN that I define in Gitlab and that is passed as an environment variable. It seems that nyx ignores that part in the .nyx.yaml file? It is also possible that I am missing something here? I think the error message (or the debug messages) could be more enlightening, e.g., it would be nice to confirm that a TOKEN is used and not really a user-password combination.

sh-cau commented 9 months ago

Ok, I finally got it working. So there were two issues:

I wish there would have been a few examples in the docs. But they seem to be centered around using Git Hub. So please consider extending the docs to a few use cases and workflows, maybe, to do your amazing tool justice.

flelli commented 9 months ago

I'm closing this issue as it's been sorted out. Feel free to reopen if needed.