GithubHelp home page GithubHelp logo

un-ts / changesets-gitlab Goto Github PK

View Code? Open in Web Editor NEW
78.0 2.0 32.0 1.01 MB

GitLab CI cli for changesets like its GitHub Action.

Home Page: https://opencollective.com/unts/projects/changesets-gitlab

License: MIT License

JavaScript 2.35% TypeScript 97.65%
changeset changesets gitlab

changesets-gitlab's Introduction

changesets-gitlab

GitHub Actions npm GitHub Release

Conventional Commits Renovate enabled JavaScript Style Guide Code Style: Prettier changesets

GitLab CI cli for changesets like its GitHub Action, it creates a merge request with all of the package versions updated and changelogs updated and when there are new changesets on master, the MR will be updated. When you're ready, you can merge the merge request and you can either publish the packages to npm manually or setup the action to do it for you.

Usage

Inputs

Note: environment variables are case-sensitive

  • INPUT_PUBLISH - The command to use to build and publish packages
  • INPUT_VERSION - The command to update version, edit CHANGELOG, read and delete changesets. Default to changeset version if not provided
  • INPUT_COMMIT - The commit message to use. Default to Version Packages
  • INPUT_TITLE - The merge request title. Default to Version Packages

Only available in changesets-gitlab

  • INPUT_PUBLISHED - Command executed after published
  • INPUT_ONLY_CHANGESETS - Command executed on only changesets detected
  • INPUT_REMOVE_SOURCE_BRANCH - Enables the merge request "Delete source branch" checkbox. Default false.
  • INPUT_TARGET_BRANCH -> The merge request target branch. Defaults to current branch
  • INPUT_CREATE_GITLAB_RELEASES - A boolean value to indicate whether to create Gitlab releases after publish or not. Default true.
  • INPUT_LABELS - A comma separated string of labels to be added to the version package Gitlab Merge request

Outputs

  • PUBLISHED - A boolean value to indicate whether a publishing is happened or not
  • PUBLISHED_PACKAGES - A JSON array to present the published packages. The format is [{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]

Environment Variables

GLOBAL_AGENT_HTTP_PROXY  # optional, if you're using custom GitLab service under proxy
GLOBAL_AGENT_HTTPS_PROXY # As above but for https requests
GLOBAL_AGENT_NO_PROXY    # Like above but for no proxied requests

# http_proxy, https_proxy, no_proxy environment variables are supported at the same time

GITLAB_HOST # optional, if you're using custom GitLab host, will fallback to `CI_SERVER_URL` if not provided

GITLAB_TOKEN                 # required, token with accessibility to push
GITLAB_TOKEN_TYPE            # optional, type of the provided token in GITLAB_TOKEN. defaults to personal access token. can be `job` if you provide the Gitlab CI_JOB_TOKEN or `oauth` if you use Gitlab Oauth token
GITLAB_CI_USER_NAME          # optional, username with accessibility to push, used in pairs of the above token (if it was personal access token). If not set read it from the Gitlab API
GITLAB_CI_USER_EMAIL         # optional, default `gitlab[bot]@users.noreply.gitlab.com`
GITLAB_COMMENT_TYPE          # optional, type of the comment. defaults to `discussion`. can be set to `note` to not create a discussion instead of a thread
GITLAB_ADD_CHANGESET_MESSAGE # optional, default commit message for adding changesets on GitLab Web UI
DEBUG_GITLAB_CREDENTIAL      # optional, default `false`

Example workflow

Without Publishing

Create a file at .gitlab-ci.yml with the following content.

stages:
  - comment
  - release

before_script: yarn --frozen-lockfile

comment:
  image: node:lts-alpine
  stage: comment
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  script: yarn changesets-gitlab comment # comment automatically like https://github.com/changesets/bot

release:
  image: node:lts-alpine
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  script: yarn changesets-gitlab

With Publishing

Before you can setup this action with publishing, you'll need to have an npm token that can publish the packages in the repo you're setting up the action for and doesn't have 2FA on publish enabled (2FA on auth can be enabled). You'll also need to add it as a custom environment variable on your GitLab repo with the name NPM_TOKEN. Once you've done that, you can create a file at .gitlab-ci.yml with the following content.

stages:
  - comment
  - release

before_script: yarn --frozen-lockfile

comment:
  image: node:lts-alpine
  stage: comment
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  script: yarn changesets-gitlab comment

release:
  image: node:lts-alpine
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  script: yarn changesets-gitlab
  variables:
    INPUT_PUBLISH: yarn release

By default the GitLab CI cli creates a .npmrc file with the following content:

//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}

However, if a .npmrc file is found, the GitLab CI cli does not recreate the file. This is useful if you need to configure the .npmrc file on your own. For example, you can add a step before running the Changesets GitLab CI cli:

script: |
  cat << EOF > "$HOME/.npmrc"
    [email protected]
    //registry.npmjs.org/:_authToken=$NPM_TOKEN
  EOF

With version script

If you need to add additional logic to the version command, you can do so by using a version script.

If the version script is present, this action will run that script instead of changeset version, so please make sure that your script calls changeset version at some point. All the changes made by the script will be included in the MR.

stages:
  - comment
  - release

before_script: yarn --frozen-lockfile

comment:
  image: node:lts-alpine
  stage: comment
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  script: yarn changesets-gitlab comment

release:
  image: node:lts-alpine
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  script: yarn changesets-gitlab
  variables:
    INPUT_VERSION: yarn version

With Yarn 2 / Plug'n'Play

If you are using Yarn Plug'n'Play, you should use a custom version command so that the action can resolve the changeset CLI:

stages:
  - comment
  - release

before_script: yarn --frozen-lockfile

comment:
  image: node:lts-alpine
  stage: comment
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  script: yarn changesets-gitlab comment

release:
  image: node:lts-alpine
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  script: yarn changesets-gitlab
  variables:
    INPUT_VERSION: yarn changeset version

You may also want to run yarn install after the changeset verion command to update the yarn.lock in the version MR. You need to disable immutable lock file setting using an env variable:

release:
  image: node:lts-alpine
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  script: yarn changesets-gitlab
  variables:
    YARN_ENABLE_IMMUTABLE_INSTALLS: 'false'
    INPUT_VERSION: yarn update-versions

And your update-versions script would be:

{
  "update-versions": "changeset version && yarn install"
}

Sponsors

1stG RxTS UnTS
1stG Open Collective backers and sponsors RxTS Open Collective backers and sponsors UnTS Open Collective backers and sponsors

Backers

Backers

1stG RxTS UnTS
1stG Open Collective backers and sponsors RxTS Open Collective backers and sponsors UnTS Open Collective backers and sponsors

Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT © JounQin@1stG.me

changesets-gitlab's People

Contributors

adriellimanthie avatar alan910127 avatar angleshe avatar awxalbert avatar devtribe avatar e110c0 avatar f3n67u avatar github-actions[bot] avatar godiagonal avatar hosseinagha avatar jounqin avatar lluiscab avatar meesvandongen avatar pmjhonwang avatar quiibz avatar renovate-bot avatar renovate[bot] avatar rkaede avatar theholywaffle avatar vinnymac avatar wingnorepeat avatar wxh16144 avatar zwaittt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

changesets-gitlab's Issues

Link to create changesets does not set file name and contents

In our GitLab, the query strings are ignored. When I click the link which looks like {BASE}/new/gzip?file_name=.changeset/ninety-parrots-divide.md&file=---%0A%22%40zazuko%2Fmymuseum-pipeline%22%3A%20patch%0A---%0A%0Afeat%3A%20gzipping%20output%0A

The editor opens blank

Is there a way to use a `tag` command?

Recently changeset added a tag command where you can make a full release without publishing to npm (incase of using packages directly in a monorepo).

What is the easiest way to use something like this?

(and thanks for the awesome work 🚀 )

Running CLI, changesets-gitlab comment produces 401 response

Hello -

I'm not sure if this is an actual issue, probably something I have incorrectly setup in my use of changesets-gitlab. If you could provide any guidance it would be appreciated though, I've tried numerous things but no luck :)

#gitlab-ci.yml

comment:
  stage: comment
  only:
    refs:
      - merge_requests
    variables:
      - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
  script:
    - npm install 
    - npx changesets-gitlab comment
  variables:
    GITLAB_TOKEN: $GITLAB_TOKEN
    GITLAB_CI_USER_NAME: $GITLAB_CI_USER_NAME
    DEBUG_GITLAB_CREDENTIAL: 'true'

The problem is running the comment job in Gitlab produces a 401 error:

HTTPError: Response code 401 (Unauthorized)
    at Request.<anonymous> (/builds/zywave/content/playground/web-components/content-components/node_modules/got/dist/source/as-promise/index.js:118:42)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_NON_2XX_3XX_RESPONSE',
  timings: {
    start: 1662857996689,
    socket: 1662857996693,
    lookup: 1662857996694,
    connect: 1662857996854,
    secureConnect: 1662857997215,
    upload: 1662857997215,
    response: 1662857997309,
    end: 1662857997312,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 4,
      dns: 1,
      tcp: 1[60](https://gitlab.com/zywave/content/playground/web-components/content-components/-/jobs/3010216532#L60),
      tls: 3[61](https://gitlab.com/zywave/content/playground/web-components/content-components/-/jobs/3010216532#L61),
      request: 0,
      firstByte: 94,
      download: 3,
      total: [62](https://gitlab.com/zywave/content/playground/web-components/content-components/-/jobs/3010216532#L62)3
    }
  },
  description: '401 Unauthorized'
}

I setup GITLAB_TOKEN as a Personal Access Token, from my own user and have them defined as project CI/CD variables. My user has Owner privileges on the project. As a sanity check I made another Personal Access Token and updated project variable, still hitting the same snag. Also the project is under a private group, not sure if additional config is needed for that.

If you would like more information please let me know, happy to provide, and thank you for the help!

Create MR with a custom target branch

Right now, the MR is created with the target branch being the same as the one that's running the CI.

In our case, we use a branch dev for development and we'd like to merge all changes into main using the MR that changeset created. Problem is as I said, the target branch is always dev as it's using CI_COMMIT_REF_NAME. Could an option be added to specify a custom target branch? (Similar to how changeset has a baseBranch configuration option for comparisons)

As this is a quite simple change, I'd be uo tp opening a PR with such changes, maybe with a new INPUT_TARGET_BRANCH env variable?

Response code 401 (Unauthorized) code: 'ERR_NON_2XX_3XX_RESPONSE',

I tried a lot of solutions, but in the end they didn't work. Can you help me?

.gitlab-ci.yml

stages:
  - install
  - lint
  - comment
  - release

image: node:16.20.0

cache:
  key:
    files:
      - pnpm-lock.yaml
  paths:
    - .pnpm-store
    - "**/node_modules/"
    - node_modules/

before_script: &global_before_script
  - corepack enable
  - corepack prepare pnpm@latest-7 --activate
  - pnpm config set store-dir .pnpm-store

install:
  stage: install
  before_script:
    - *global_before_script
    - pnpm config set registry https://registry.npmmirror.com/
  script:
    - pnpm install # install dependencies
  tags:
    - builder-wxh
  only: &common_only
    - master
    - /^feature\/.*$/
    - /^hotfix\/.*$/
    - merge_requests

lint:
  stage: lint
  script:
    - npm run lint # lint code
  only: *common_only
  tags:
    - builder-wxh

pre_compile:
  stage: lint
  tags:
    - builder-wxh
  script:
    - npm run build # compile code
  only: *common_only

comment:
  stage: comment
  tags:
    - builder-wxh
  only:
    - merge_requests
  # comment automatically like https://github.com/changesets/bot
  script: pnpm dlx changesets-gitlab comment

create_MR:
  stage: release
  tags:
    - builder-wxh
  when: manual
  variables:
    GITLAB_TOKEN: $CI_JOB_TOKEN
    INPUT_PUBLISH: npm run build
    INPUT_TITLE: "chore(release): publish"
    TARGET_BRANCH: refactor # TODO: change to master
  script:
    - |
      cat << EOF > "$HOME/.npmrc"
        email = [email protected]
        //${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}
      EOF
    - echo "Created the following .npmrc:"; cat "$HOME/.npmrc"
    - pnpm dlx changesets-gitlab
  only: *common_only
  except:
    - merge_requests
logs

�[0KRunning with gitlab-runner 16.0.2 (85586bd1)�[0;m
�[0K on builder-wxh _5z-vVyu6, system ID: s_6965a954eb78�[0;m
section_start:1691047484:prepare_executor
�[0K�[0K�[36;1mPreparing the "docker" executor�[0;m�[0;m
�[0KUsing Docker executor with image node:16.20.0 ...�[0;m
�[0KPulling docker image node:16.20.0 ...�[0;m
�[0KUsing docker image sha256:c56ec223ce193f5e085a073b727aa63e01f1d31f9d9b5baddab4523389db5f6d for node:16.20.0 with digest node@sha256:07ac708c46cc7136db9d54749c541ba1dc516dc316e126a94136083b842c2db9 ...�[0;m
section_end:1691047487:prepare_executor
�[0Ksection_start:1691047487:prepare_script
�[0K�[0K�[36;1mPreparing environment�[0;m�[0;m
Running on runner-5z-vvyu6-project-31-concurrent-0 via szq-ubuntu...
section_end:1691047488:prepare_script
�[0Ksection_start:1691047488:get_sources
�[0K�[0K�[36;1mGetting source from Git repository�[0;m�[0;m
�[32;1mFetching changes with git depth set to 20...�[0;m
Reinitialized existing Git repository in /builds/common-editor-toolkit/editor/.git/
�[32;1mChecking out 263b27a5 as detached HEAD (ref is feature/ci)...�[0;m
Removing .pnpm-store/
Removing node_modules/
Removing packages/browser/node_modules/
Removing packages/components-pro/node_modules/
Removing packages/components/node_modules/
Removing packages/core/node_modules/
Removing packages/desktop/node_modules/
Removing playground/node_modules/

�[32;1mSkipping Git submodules setup�[0;m
section_end:1691047491:get_sources
�[0Ksection_start:1691047491:restore_cache
�[0K�[0K�[36;1mRestoring cache�[0;m�[0;m
�[32;1mChecking cache for 0_pnpm-lock-91d8e5d408686549482d3a90dde9877a734df4bb-non_protected...�[0;m
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted.�[0;m
�[0;33mWARNING: node_modules/.pnpm/@[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/react-dom/node_modules/: mkdir node_modules/.pnpm/@[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/react-dom: file exists (suppressing repeats)�[0;m
�[32;1mSuccessfully extracted cache�[0;m
section_end:1691047505:restore_cache
�[0Ksection_start:1691047505:step_script
�[0K�[0K�[36;1mExecuting "step_script" stage of the job script�[0;m�[0;m
�[0KUsing docker image sha256:c56ec223ce193f5e085a073b727aa63e01f1d31f9d9b5baddab4523389db5f6d for node:16.20.0 with digest node@sha256:07ac708c46cc7136db9d54749c541ba1dc516dc316e126a94136083b842c2db9 ...�[0;m
�[32;1m$ corepack enable�[0;m
�[32;1m$ corepack prepare pnpm@latest-7 --activate�[0;m
Preparing pnpm@latest-7 for immediate activation...
�[32;1m$ pnpm config set store-dir .pnpm-store�[0;m
�[32;1m$ cat << EOF > "$HOME/.npmrc" # collapsed multi-line command�[0;m
�[32;1m$ echo "Created the following .npmrc:"; cat "$HOME/.npmrc"�[0;m
Created the following .npmrc:
email = [email protected]
//git.aquilainteractive.cn/api/v4/projects/31/packages/npm/:_authToken=[MASKED]
�[32;1m$ pnpm dlx changesets-gitlab�[0;m
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 1, reused 0, downloaded 0, added 0
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 8, reused 8, downloaded 0, added 0
../../.pnpm-store/v3/tmp/dlx-59 |  WARN  deprecated @gitbeaker/[email protected]
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 20, reused 20, downloaded 0, added 0
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 23, reused 23, downloaded 0, added 0
 WARN  GET https://registry.npmjs.org/@changesets%2Fread error (ERR_SOCKET_TIMEOUT). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@sentry%2Fnode error (ERR_SOCKET_TIMEOUT). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@changesets%2Ferrors error (ERR_SOCKET_TIMEOUT). Will retry in 10 seconds. 2 retries left.
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 24, reused 23, downloaded 0, added 0
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 25, reused 25, downloaded 0, added 0
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 28, reused 28, downloaded 0, added 0
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 44, reused 43, downloaded 0, added 0
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 59, reused 59, downloaded 0, added 0
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 92, reused 92, downloaded 0, added 0
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 117, reused 117, downloaded 0, added 0
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 153, reused 150, downloaded 0, added 0
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 190, reused 190, downloaded 0, added 0
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 226, reused 226, downloaded 0, added 0
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 235, reused 235, downloaded 0, added 0
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 239, reused 238, downloaded 0, added 0
../../.pnpm-store/v3/tmp/dlx-59 | +239 ++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
Content-addressable store is at: /builds/.pnpm-store/v3
Virtual store is at: ../../.pnpm-store/v3/tmp/dlx-59/node_modules/.pnpm

::set-output name=published::false

::set-output name=publishedPackages::[]
setting git user
[command]/usr/bin/git config user.name Wu Xiaohong
[command]/usr/bin/git config user.email "gitlab[bot]@users.noreply.gitlab.com"
setting GitLab credentials
../../.pnpm-store/v3/tmp/dlx-59 | Progress: resolved 239, reused 239, downloaded 0, added 239, done
HTTPError: Response code 401 (Unauthorized)
at Request. (/builds/.pnpm-store/v3/tmp/dlx-59/node_modules/.pnpm/[email protected]/node_modules/got/dist/source/as-promise/index.js:118:42)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: 'ERR_NON_2XX_3XX_RESPONSE',
timings: {
start: 1691047607638,
socket: 1691047607639,
lookup: 1691047607640,
connect: 1691047607833,
secureConnect: 1691047608278,
upload: 1691047608278,
response: 1691047608635,
end: 1691047608641,
error: undefined,
abort: undefined,
phases: {
wait: 1,
dns: 1,
tcp: 193,
tls: 445,
request: 0,
firstByte: 357,
download: 6,
total: 1003
}
},
description: '401 Unauthorized'
}
 ERROR  Command failed with exit code 1: /builds/.pnpm-store/v3/tmp/dlx-59/node_modules/.bin/changesets-gitlab

pnpm: Command failed with exit code 1: /builds/.pnpm-store/v3/tmp/dlx-59/node_modules/.bin/changesets-gitlab
at makeError (/root/.cache/node/corepack/pnpm/7.9.5/dist/pnpm.cjs:22289:17)
at handlePromise (/root/.cache/node/corepack/pnpm/7.9.5/dist/pnpm.cjs:22860:33)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.handler [as dlx] (/root/.cache/node/corepack/pnpm/7.9.5/dist/pnpm.cjs:191714:7)
at async /root/.cache/node/corepack/pnpm/7.9.5/dist/pnpm.cjs:199078:21
at async run (/root/.cache/node/corepack/pnpm/7.9.5/dist/pnpm.cjs:199049:34)
at async runPnpm (/root/.cache/node/corepack/pnpm/7.9.5/dist/pnpm.cjs:199270:5)
at async /root/.cache/node/corepack/pnpm/7.9.5/dist/pnpm.cjs:199262:7
section_end:1691047609:step_script
�[0Ksection_start:1691047609:cleanup_file_variables
�[0K�[0K�[36;1mCleaning up project directory and file based variables�[0;m�[0;m
section_end:1691047609:cleanup_file_variables
�[0K�[31;1mERROR: Job failed: exit code 1
�[0;m

logs.txt

Help: running a script to edit files in the merge request

Hey, I want to write the version of the packages in my monorepo to an additional file.

I have a (pnpm) Monorepo with 3 packages and I would like to change not only the package.json with the new version but also a file for the deployment of the new version. Is there a way to run a script with the new version?

In the Readme I found

If you need to add additional logic to the version command, you can do so by using a version script.

If the version script is present, this action will run that script instead of changeset version, so please make sure that your script calls changeset version at some point. All the changes made by the script will be included in the MR.

But i can't figure out what the "version script" is. I tried to write a "version" and a "update-versions" script in my package.json, but it seems as if it didn't run...

...
 "scripts": {
    "version": "changeset version && echo 'test' > test",
    "update-versions": "changeset version && echo 'test' > test",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
...

Could anyone help me, please?

In my dreamworld, changeset-gitlab changes the versions in the packages, calls my custom script (where I can edit my file with the correct version from the package.json's) and after this, changeset-gitlab pushes all changes to the branch

Error: when SSH Port different from 22

Hi I'm trying to release my monorepo library using changesets-gitlab, comment stage goes well, but when it comes to release stage it results into an error.
I'm trying to debug this issue since in the .git/config I have

pushurl = git@HOST:PORT/REPO.git

where HOST is not gitlab, PORT is not 22 and REPO is ofc the repo

after pnpm changesets-gitlab command I got this:

[command]/usr/bin/git push origin HEAD:changeset-release/master --force
ssh: connect to host HOST port 22: Connection refused
fatal: Could not read from remote repository.

This happen here, run.ts:292

await gitUtils.push(versionBranch, { force: true })

This is the ci yaml

stages:
  - comment
  - release

before_script:
  - corepack enable
  - corepack prepare pnpm@latest --activate
  - pnpm i --no-frozen-lockfile

comment:
  image: node:lts-alpine
  stage: comment
  only:
    - merge_requests
  script: pnpm changesets-gitlab comment
  variables:
    GITLAB_TOKEN: '${GITLAB_TOKEN}'

release:
  image: node:lts-alpine
  stage: release
  only:
    - master
  script:
    - apk --no-cache add git openssh
    - cat .git/config
    - pnpm changesets-gitlab
  variables:
    INPUT_ONLY_CHANGESETS: 'true'
    INPUT_REMOVE_SOURCE_BRANCH: 'true'
    INPUT_CREATE_GITLAB_RELEASES: 'false'
    GITLAB_TOKEN: '${GITLAB_TOKEN}'
    INPUT_PUBLISH: pnpm build && pnpm run publish

Monorepo support

Are there any plans to support monorepos like Turborepo on the roadmap?

Usage of outputs

The readme currently states outputs:

Outputs
published - A boolean value to indicate whether a publishing is happened or not
publishedPackages - A JSON array to present the published packages. The format is [{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]

As I understand, this only makes sense in the context of github (github actions / set-output cli command).

However, internally the script also does

exportVariable('PUBLISHED', true)
exportVariable('PUBLISHED_PACKAGES', result.publishedPackages)

which is far more useful in the context of gitlab. Thus, I would suggest to update the readme to reflect this.

Which brings me to another point, the variable PUBLISHED is used as both input and output, which is problematic.
Edit: this is of course not the case due to the INPUT_ prefix.

Here is a merge request which should clarify things #165

Clarify internal usage of environment variables with an exported `env` variable

Description

Currently, environment variables are used in several places in the project to determine the behavior.
However, it might be unclear for developers who are new to this codebase whether an environment variable is defined or not.
It should be helpful to have an exported env variable with the "actual" types for the variables or even with pre-validation.

Proposed Solution

We could either use:

  1. a separate module, or
  2. a validation library like zod

to validate the environment variables and export the object.

v0.11.1 includes breaking change for environment variables

The upgrade from 0.11.0 to 0.11.1 broke some environment variable usage.

For example, previously the host would fallback to process.env.CI_SERVER_URL, but with this latest update I receive 401 unauthorized because I rely on the built-in gitlab CI CI_SERVER_URL environment variable instead of the explicit GITLAB_HOST environment variable this CLI is looking for.

For more information on CI_SERVER_URL see https://docs.gitlab.com/ee/ci/variables/predefined_variables.html

Release merge request triggers pipelines without jobs

I have a weird issue, where when running changeset-gitlab there are two pipelines created without jobs which fail immediately. It happens when using for GITLAB_TOKEN:

  • A personal access token of a newly created accout
  • A project access token

But not if I use a personal access token of my regular account. For the projekt access token the api scope is used. For the newly created account all roles etc. are set like my regular account. It‘s really weird and I don‘t know why this happens.

Screenshots of the pipelines:
image

image

.gitlab-ci.yml in example has syntax error

Hi, i guess the current example of .gitlab-ci.yml has syntax errors
스크린샷 2024-05-26 오후 11 42 32

스크린샷 2024-05-26 오후 11 43 26
stages:
  - comment
  - release

before_script: yarn --frozen-lockfile

comment:
  image: node:lts-alpine
  stage: comment 
  # only: merge_requests #fixed
  only:
    - merge_requests
  script: yarn changesets-gitlab comment

release:
  image: node:lts-alpine
  stage: release # added
  # only: main # fixed
  only: 
    - main
  script: yarn changesets-gitlab
  variables:
    INPUT_PUBLISH: yarn release

Fixing this way solved syntax errors for me. I can create a PR for this if you don't mind

"comment" command throws 403 error

I use a maintainer personal access token with full API and Repository access.
After running the commit command I get:

HTTPError: Response code 403 (Forbidden)
    at Request.<anonymous> (./node_modules/got/dist/source/as-promise/index.js:117:42)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  code: 'ERR_NON_2XX_3XX_RESPONSE',
  description: '403 Forbidden'
}

[Feature Request] Exception details

Hi! In the process of configuring CI/CD, I encountered exceptions. All network errors are not very informative:

🦋  Creating git tag...
🦋  New tag:  @***/***@0.0.5
[command]/usr/bin/git push origin --tags
To https://gitlab.com/***/***/***.git
 * [new tag]         @***/***@0.0.5 -> @***/***@0.0.5
HTTPError: Response code 403 (Forbidden)
    at Request.<anonymous> (/builds/***/***/***/node_modules/got/dist/source/as-promise/index.js:118:42)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_NON_2XX_3XX_RESPONSE',
  timings: {
    start: 169332[73](https://gitlab.com/***/***/***/-/jobs/0000000000#L73)1[77](https://gitlab.com/***/***/***/-/jobs/0000000000#L77)94,
    socket: 1693327317796,
    lookup: 1693327317799,
    connect: 169332731[78](https://gitlab.com/***/***/***/-/jobs/0000000000#L78)02,
    secureConnect: 1693327317810,
    upload: 1693327317811,
    response: 169332731[80](https://gitlab.com/***/***/***/-/jobs/0000000000#L80)64,
    end: 1693327318067,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 2,
      dns: 3,
      tcp: 3,
      tls: 8,
      request: 1,
      firstByte: 253,
      download: 3,
      total: 273
    }
  },
  description: '403 Forbidden'
}
error Command failed with exit code 1.

It is unclear which part of the process the problem occurred with. It would be cool to see the details about the error 👉👈

Add @changesets/* packages to package dependencies

According to the NodeJS module resolution standard, you have to add packages that you require in your modules to the package dependencies. Otherwise, you rely on the hoisting of modules in the node_modules.
In my case yarn v3 errors that @changesets/errors, @changesets/pre, and @changesets/read do not exist. Yarn pnp strictly requires this standard module resolution rule.

SyntaxError: The requested module '@gitbeaker/requester-utils' does not provide an export named 'GitbeakerRequestError'

Hi! When trying to migrate from "changesets-gitlab": "^0.10.3" to latest version, I get an error:

$ ./builds/node_modules/.bin/changesets-gitlab
file:///builds/node_modules/@gitbeaker/rest/dist/index.mjs:2
import { createRequesterFn, presetResourceArguments, getMatchingRateLimiter, GitbeakerTimeoutError, GitbeakerRetryError, GitbeakerRequestError } from '@gitbeaker/requester-utils';
                                                                                                                         ^^^^^^^^^^^^^^^^^^^^^
SyntaxError: The requested module '@gitbeaker/requester-utils' does not provide an export named 'GitbeakerRequestError'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:122:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:188:5)
    at async DefaultModuleLoader.import (node:internal/modules/esm/loader:228:24)
    at async loadESM (node:internal/process/esm_loader:[40](https://gitlab.com/noname/repo/frontend-libs/-/jobs/6580017729#L40):7)
    at async handleMainPromise (node:internal/modules/run_main:66:12)
Node.js v20.5.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn run v1.22.19

Is there a problem with dependencies?

Publish package on gitlab registry

There is a ticket on changeset itself to "fix" this, but since the ticket is 1,5 years open, maybe there is chance to implement a own publish command in this lib, since its handling gitlab already.

changesets/changesets#530

Problem is changesets doesnt detect packages on the gitlab package registry or gives wrong output.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Using npm packages for Renovate presets is now deprecated. Please migrate to repository-based presets instead.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • fix(deps): update dependency unified to ^11.0.5
  • fix(deps): update dependency @changesets/errors to ^0.2.0
  • fix(deps): update dependency @changesets/parse to ^0.4.0
  • fix(deps): update dependency @changesets/read to ^0.6.0
  • fix(deps): update dependency @gitbeaker/rest to ^39.34.3
  • fix(deps): update dependency @sentry/node to ^7.118.0
  • fix(deps): update dependency dotenv to ^16.4.5
  • fix(deps): update dependency fs-extra to ^11.2.0
  • fix(deps): update dependency semver to ^7.6.2
  • chore(deps): update dependency @1stg/lib-config to v13
  • chore(deps): update node.js to v20
  • fix(deps): update dependency @changesets/assemble-release-plan to v6
  • fix(deps): update dependency @changesets/config to v3
  • fix(deps): update dependency @changesets/pre to v2
  • fix(deps): update dependency @gitbeaker/rest to v40
  • fix(deps): update dependency @manypkg/get-packages to v2
  • fix(deps): update dependency @sentry/node to v8
  • fix(deps): update dependency commander to v12
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/release.yml
  • actions/checkout v4
  • actions/setup-node v4
npm
package.json
  • @actions/core ^1.10.1
  • @actions/exec ^1.1.1
  • @changesets/assemble-release-plan ^5.2.4
  • @changesets/config ^2.3.1
  • @changesets/errors ^0.1.4
  • @changesets/parse ^0.3.16
  • @changesets/pre ^1.0.14
  • @changesets/read ^0.5.9
  • @gitbeaker/rest ^39.23.0
  • @manypkg/get-packages ^1.1.3
  • @sentry/node ^7.80.1
  • commander ^11.1.0
  • dotenv ^16.3.1
  • fs-extra ^11.1.1
  • global-agent ^3.0.0
  • human-id ^4.1.0
  • js-yaml ^4.1.0
  • markdown-table ^3.0.3
  • mdast-util-to-string ^4.0.0
  • micromatch ^4.0.5
  • remark-parse ^11.0.0
  • remark-stringify ^11.0.0
  • resolve-from ^5.0.0
  • semver ^7.5.4
  • unified ^11.0.4
  • @1stg/lib-config ^12.0.1
  • @changesets/changelog-github ^0.4.8
  • @changesets/cli ^2.26.2
  • @types/global-agent ^2.1.3
  • @types/jest ^29.5.11
  • @types/js-yaml ^4.0.9
  • @types/micromatch ^4.0.6
  • @types/web ^0.0.128
  • jest ^29.7.0
  • ts-jest ^29.1.1
  • ts-node ^10.9.2
  • type-coverage ^2.27.0
  • typescript ^5.3.3
  • yarn-deduplicate ^6.0.2
  • node >=18.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

changesets-gitlab comment logs Gitlab deprecation warning

In my Gitlab workflow the comment stage job runs the following script
pnpm changesets-gitlab comment

(node:49) DeprecationWarning: This endpoint was deprecated in Gitlab API 15.7 and will be removed in API v5. Please use the "allDiffs" function instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

So I got the deprecation warning from Gitlab, see above. I think Gitlab 15.7 was released on December 2022.

INPUT_ variables need to be all uppercase to work

when setting INPUT_ variables, the documentation states those variables are case insensitive. Turns out, they aren't INPUT_title is not working, only INPUT_TITLE is. Same for all other INPUT_ variables.

remove usage of `@actions/core`

In my previous issue I suggested changing the documentation to reflect the environment variables, but after some testing it seems that the environment variables are not set. Moreover, setting the environment variables is not possible from a child process (nodeJS) as far as I am aware.

For that problem specifically, I would suggest moving to files; e.g. changesets-gitlab-output.json

{
  "published": true,
  "publishedPackages": [
    { "name": "@xx/xx", "version": "1.2.0" },
    { "name": "@xx/xy", "version": "0.8.9" }
  ]
}

Then, a suggestion could be added to add the file to .gitignore.

More generally, @actions packages should not be used at all in this repo since it is only meant for Github actions.

If you are fine with such changes I can look into making a PR.

Error: Have you forgotten to install `@changesets/cli` in

When install it globaly, not found @changesets/cli

$ yarn global add [email protected] @changesets/[email protected]
$ changesets-gitlab
::set-output name=published::false
::set-output name=publishedPackages::[]
setting git user
[command]/usr/bin/git config user.name ******
[command]/usr/bin/git config user.email "******"
setting GitLab credentials
[command]/usr/bin/git checkout changeset-release/master
error: pathspec 'changeset-release/master' did not match any file(s) known to git
[command]/usr/bin/git checkout -b changeset-release/master
Switched to a new branch 'changeset-release/master'
[command]/usr/bin/git fetch origin master
From ******
 * branch            master     -> FETCH_HEAD
[command]/usr/bin/git reset --hard origin/master
HEAD is now at f07e379 Merge branch 'testComment' into 'master'
Error: Have you forgotten to install `@changesets/cli` in "******"?

comment adds new comment with every commit

since we updated changesets-gitlab we have now the issue that with every commit the changesets-gitlab comment command creates a new comment in our merge request. before the update it only created one comment for a merge request.

Create tags

We are using changesets-gitlab without publishing

It would be very useful if the repository got tagged when the "Version Packages" MR is merged

No Changeset found comment should only appears once

If there is a commit in a branch with open Merge Request and a "No Changeset found" comment is already there, the application should not add another one. It quickly gets confusing with all the other comments.

Add support for providing CI_JOB_TOKEN

Using the current options lib users can only provide personal access token. I want to use the Gitlab's CI_JOB_TOKEN in my comment stage as it is much safer.
According to gitbeaker docs the job token should be provided in another config.
Can we add an option to provide a job token? Are you open to a PR on this?

npx changesets-gitlab - git fetch origin main - unable to access URL using bad/illegal format or missing URL

Running npx changesets-gitlab I'm having this error, and I couldn't find any info about what could be the reason.

URL https://gitlab.company.com/project/path/name.git is correct and I could access by the browser.

Could you help us with any clue to look for a solution?

$ npx changesets-gitlab
::set-output name=published::false
::set-output name=publishedPackages::[]
setting git user
[command]/usr/bin/git config user.name Bot
[command]/usr/bin/git config user.email [email protected]
setting GitLab credentials
[command]/usr/bin/git checkout changeset-release/main
error: pathspec 'changeset-release/main' did not match any file(s) known to git
[command]/usr/bin/git checkout -b changeset-release/main
Switched to a new branch 'changeset-release/main'
[command]/usr/bin/git fetch origin main
fatal: unable to access 'https://gitlab.company.com/project/path/name.git/': URL using bad/illegal format or missing URL
Error: The process '/usr/bin/git' failed with exit code 128
    at ExecState._setResult (/builds/project/path/name/node_modules/@actions/exec/lib/toolrunner.js:592:25)
    at ExecState.CheckComplete (/builds/project/path/name/node_modules/@actions/exec/lib/toolrunner.js:575:18)
    at ChildProcess.<anonymous> (/builds/project/path/name/node_modules/@actions/exec/lib/toolrunner.js:469:27)
    at ChildProcess.emit (node:events:514:28)
    at ChildProcess.emit (node:domain:489:12)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)

[command]/usr/bin/git fetch origin main
fatal: unable to access 'https://gitlab.company.com/project/path/name.git/': URL using bad/illegal format or missing URL
Error: The process '/usr/bin/git' failed with exit code 128

When does changesets-gitlab create merge request?

I have set up release job but without publishing step. Didn't add INPUT_PUBLISH var. Despite successful build the job doesn't create merge request.
Configuration looks like this:

stages:
  - Publish

publish:
  rules:
    - if: $CI_COMMIT_BRANCH == "release"
  stage: Publish
  when: manual
  script:
    - echo "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> ~/.npmrc
    - yarn run changeset
  variables:
    INPUT_VERSION: yarn run version
    INPUT_COMMIT: "Version Packages"
    INPUT_TITLE: "Version Packages"
    GITLAB_HOST: $CI_REPOSITORY_URL
    GITLAB_TOKEN_TYPE: "job"
    GITLAB_TOKEN: $CI_JOB_TOKEN
    TARGET_BRANCH: "development"
    CREATE_GITLAB_RELEASES: "false"
    GITLAB_CI_USER_EMAIL: $GITLAB_USER_EMAIL
  needs:
    - job: install
      artifacts: true
    - job: build
      artifacts: true

package.json scripts:

{
  "scripts": {
    "build": "rollup -c",
    "prerelease": "yarn build",
    "release": "changesets-gitlab publish",
    "changeset": "changesets-gitlab",
    "version": "changesets-gitlab version",
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.