npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pubgcorp/semantic-release-gitlabmonorepo

v1.3.1

Published

<h1 align="center" style="border-bottom: none;">🦊 @pubgcorp/semantic-release-gitlabmonorepo</h1>

Downloads

139

Readme


| Step | Description | |--------------------|---------------------------------------------------------------------------| | verifyConditions | Verify the presence of some requirements environment and config variable. | | publish | Push a Git Assets for the package. |

Install

npm install -D @pubgcorp/semantic-release-gitlabmonorepo

Usage

The plugin can be used by adding it to the plugins field in the release configuration of your package.json.

.releaserc

{
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    [
      "@semantic-release/changelog",
      {
        "changelogFile": "CHANGELOG.md"
      }
    ],
    "@semantic-release/npm",
    [
      "@pubgcorp/semantic-release-gitlabmonorepo",
      {
        "gitlabUrl": "https://gitlab.tythonic.com",
        "assets": [
          {
            "path": "CHANGELOG.md"
          },
          {
            "path": "package.json"
          }
        ]
      }
    ]
  ]
}

Root CI configuration:

stages:
  - publish

.publish:
  stage: publish
  before_script:
    - npm ci
  script:
    - cd ${PACKAGE_PATH}
    - npx semantic-release
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      changes:
        paths:
          - $PACKAGE_PATH/**/*

include:
  - local: "**/.gitlab-ci.yml"

Each package CI configuration:

my-package.publish:
  extends: .publish
  variables:
    PACKAGE_PATH: my-package

With this configurations, the plugin will push the CHANGELOG.md and package.json files to the GitLab repository.

Configuration

Gitlab authentication

The GitLab authentication is done using the GITLAB_TOKEN or GITLAB_ACCESS_TOKEN environment variable. The token must have the api scope.

Environment variables

| Variable | Description | |-----------------------------------------|---------------------------------------------------------| | GITLAB_TOKEN or GITLAB_ACCESS_TOKEN | Required. The token used to authenticate with GitLab. | | CI_SERVER_URL | Optional. The gitlab endpoint. | | CI_PROJECT_ID or CI_PROJECT_PATH | Optional. The project identifier. |

The above environment variables are automatically set by GitLab CI/CD.

If you are using this plugin on GitLab CI/CD, you don't need to set any environment variables.

GitLab Monorepo Plugin Options

| Option | Description | Default | |--------------------|--------------------------------------------------------|------------------------------------------------------------------------------------------| | gitlabUrl | Optional. The GitLab URL. | CI_SERVER_URL environment variable or https://gitlab.com | | projectId | Optional. The GitLab project ID. | CI_PROJECT_ID or CI_PROJECT_PATH environment variable or read from git origin url. | | commitTitle | Optional. The commit title message to pushed assets. | chore(release): ${nextRelease.name} [skip ci] | | branchName | Optional. The branch name to merge each assets. | assets/${commit.short} | | assets | Optional. The assets to be pushed. | [] | | ignorePrerelease | Optional. Ignore prerelease version. | true |

commitTitle and branchName template

The commitTitle and branchName options support the following template variables:

| Variable | Description | |------------------------|------------------------| | nextRelease.name | The release version. | | nextRelease.type | The release type. | | nextRelease.notes | The release notes. | | lastRelease.version | The release version. | | lastRelease.gitTag | The release git tag. | | lastRelease.channels | The release channels. | | lastRelease.gitHead | The release git head. | | lastRelease.name | The release name. | | branch | The branch name. | | commit.full | The full commit hash. | | commit.short | The short commit hash. |

Example Monorepo Pipeline

With this plugin, you can run multiple semantic-release in a single pipeline like below.

img_1.png

Add a merge-published-assets stage at the end of the Gitlab CI to merge the releases of each package.

merge-published-assets:
  stage: merge-published-assets
  when: on_success
  variables:
  script:
    - npm install --global @pubgcorp/semantic-release-gitlabmonorepo
    - export SHORT_COMMIT_HASH=$(git rev-parse --short HEAD)
    - set -x
    - semantic-release-gitlabmonorepo-helper create --project-id $CI_PROJECT_ID --source-branch "assets/${SHORT_COMMIT_HASH}" --target-branch $CI_COMMIT_BRANCH --title "chore(release): Merge published assets from ${CI_COMMIT_MESSAGE} [skip ci]"
    - export MERGE_REQUEST_IID=$(gitbeaker merge-requests create --project-id $CI_PROJECT_ID --source-branch "assets/${SHORT_COMMIT_HASH}" --target-branch $CI_COMMIT_BRANCH --title "Merge published assets from ${CI_COMMIT_MESSAGE} [skip ci]" | jq -r '.iid')
    - sleep 5
    - semantic-release-gitlabmonorepo-helper merge --project-id $CI_PROJECT_ID --merge-request-iid $MERGE_REQUEST_IID
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH