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

Problems running Release-IT in a GitLab pipeline. #1048

Open
hickey opened this issue Oct 7, 2023 · 1 comment
Open

Problems running Release-IT in a GitLab pipeline. #1048

hickey opened this issue Oct 7, 2023 · 1 comment

Comments

@hickey
Copy link

hickey commented Oct 7, 2023

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: "hickey@kinetic-compute.com"
  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 "git@gitlab.com:$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
Copy link
Author

hickey commented Oct 7, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant