release-it icon indicating copy to clipboard operation
release-it copied to clipboard

Problems running Release-IT in a GitLab pipeline.

Open hickey opened this issue 2 years ago • 2 comments

I am having problems with getting Release-IT to orchestrate releases in GitLab pipeline. I have followed the GitLab pipeline recipe and this may be a case of just needing more documentation on how Release-IT is expecting to handle the release.

What I have done is to create a MR from the main branch to the release branch. When I merge the MR into release I have a CI job that run to handle the release. The following is the job definition:

release-package:
  stage: release
  image: registry.gitlab.com/wt0f/gitlab-runner-images/node:latest
  rules:
    - if: $CI_COMMIT_BRANCH == "release"
  needs:
    - build-openwrt-package
    - build-debian-package
  variables:
    CI_USERNAME: "Gerard Hickey"
    CI_EMAIL: "[email protected]"
  before_script:
    - eval `ssh-agent -s`
    - echo "${SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add - > /dev/null # add ssh key
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
    - git checkout $CI_COMMIT_REF_NAME
    - git remote set-url origin "[email protected]:$CI_PROJECT_PATH.git"
    - git config --global user.name "${CI_USERNAME}"
    - git config --global user.email "${CI_EMAIL}"
    - npm install -g release-it @release-it/conventional-changelog @commitlint/config-conventional @commitlint/cli auto-changelog
  script:
    - npx release-it --ci

This sort of works and sort of does not work.

What works:

  • The version to be released is correctly determined
  • The change log is generated, commited to the release branch and pushed back to GitLab
  • The version tag is created and pushed back to GitLab
  • GitLab release is created with artifacts uploaded

What seems not to work:

  • The change log commit set does not get applied to main branch. This may be a bit out of the scope of Release-IT and may be able to be done with a git checkout main; git rebase release after the run of Release-IT.
  • The packages for the release get generated before Release-IT executes so the package names do not have the updated version strings added to the name. So I got package names like aamm_20231007-release-5bfa0be_all.ipk instead of aamm_0.2.0_all.ipk.
  • GitLab release does not get the change log

Given the point about the incorrect package names, it seems that Release-IT needs to be run in 2 stages so that the version information can be generated, paused for the build to be created with the version information and then resumed to create the GitLab release and upload the build artifacts.

For completeness, the following is the Release-It configuration that is being used:

git:
  commit: true
  commitMessage: "chore(release): ${version}"
  commitArgs: ""
  tag: true
  tagName: "v${version}"
  tagAnnotation: "Automated release: ${version}"
  push: true
  requireBranch: release
  requireCommits: true
  changelog: "npx auto-changelog --stdout --commit-limit false"

gitlab:
  release: true
  releaseName: "v${version}"
  assets: ["*.ipk", "*.deb"]

npm:
  publish: false

plugins:
  "@release-it/conventional-changelog":
    infile: CHANGELOG.md
    preset:
      name: conventionalcommits
      types:
        - type: feat
          section: Features
        - type: fix
          section: Bug Fixes

Any suggestions or corrections to my assumptions would appreciated.

hickey avatar Oct 07 '23 18:10 hickey

If it helps any here is the GitLab job that ran Release-It: https://gitlab.com/aredn-apps/aamm/-/jobs/5244511719

hickey avatar Oct 07 '23 18:10 hickey

Sorry for the late reply. Is there still interest in advice here?

webpro avatar Jul 08 '24 17:07 webpro