Skip to content
View .md

Release on GitLab ​

Manually releasing your extension can be time-consuming and error-prone. In this guide, you'll configure your extension to use GitLab CI/CD to automatically create a release when you create a new tag.

Why use GitLab releases ​

GitLab lets you publish a public extension release while keeping your source code private.

For this setup, your project and releases are public, but the repository source is visible only to project members.

Configure project visibility ​

  1. Open your project settings page:

Replace example-group/azot-extension-example with your repository in the link below

https://gitlab.com/example-group/azot-extension-example/edit#js-shared-permissions

  1. Configure the following values:
  • Project Visibility: Public
  • Releases: Everyone With Access
  • Repository: Only Project Members (use this if you want to keep source code private)

Add GitLab CI workflow ​

INFO

If your repository was created from a ready template that already includes .gitlab-ci.yml, you can keep that file and only verify it matches the workflow below.

  1. In the root directory of your extension, create a .gitlab-ci.yml file (or update your existing one) with the following content:
yml
stages:
  - build
  - release

build_and_pack:
  stage: build
  image: node:24
  cache:
    key:
      files:
        - package-lock.json
    paths:
      - node_modules/
    policy: pull-push
  script:
    - npm ci
    - npm run build
    - npx azot check --release
    - npm pack
  artifacts:
    paths:
      - "*.tgz"
      - "*.zip"
      - "*.azt"
      - "package.json"
      - "manifest.json"
      - "README.md"
    expire_in: 1 week

release_job:
  stage: release
  image: registry.gitlab.com/gitlab-org/cli:latest
  script:
    - glab auth login --hostname gitlab.com --token "$GLAB_TOKEN" --api-protocol https
    - |
      set -e
      assets_list=""
      for f in *.tgz *.zip *.azt package.json manifest.json README.md; do
        if [ -f "$f" ]; then
          assets_list="$assets_list $f"
        fi
      done
      assets_list=$(echo $assets_list)
      if [ -n "$assets_list" ]; then
        old_ifs="$IFS"
        IFS=' '
        # shellcheck disable=SC2046
        set -- $assets_list
        IFS="$old_ifs"
        glab release create "$CI_COMMIT_TAG" "$@" --name "$CI_COMMIT_TAG"
      else
        glab release create "$CI_COMMIT_TAG" --name "$CI_COMMIT_TAG"
      fi
  needs:
    - job: build_and_pack
      artifacts: true

workflow:
  rules:
    - if: $CI_COMMIT_TAG =~ /^v.*/
  1. Commit and push the workflow:
sh
git add .gitlab-ci.yml
git commit -m "Add GitLab release workflow"
git push origin main

Create a Personal Access Token ​

The workflow uses glab and requires a Personal Access Token (PAT) to publish a release.

  1. Open your GitLab Personal Access Tokens page:

GitLab Personal Access Tokens

  1. Create a token with an api and write_registry scope.
  2. Copy the token value and keep it safe. You will add it as a CI/CD variable.

Add GLAB_TOKEN CI/CD variable ​

  1. Open project CI/CD variables settings:

Replace example-group/azot-extension-example with your repository in the link below

https://gitlab.com/example-group/azot-extension-example/-/settings/ci_cd#js-cicd-variables-settings

  1. Select Add variable and configure:
  • Key: GLAB_TOKEN
  • Value: your PAT
  • Masked: enabled
  • Hidden: enabled
  • Expanded: enabled
  • Protected: disabled

Publish the first release ​

  1. Create a tag that matches the version in package.json.
sh
git tag -a v1.0.1 -m "v1.0.1"
git push origin v1.0.1
  1. After the tag is pushed, GitLab detects the new tag and starts the pipeline automatically because of:
yml
if: $CI_COMMIT_TAG =~ /^v.*/
  1. When the pipeline finishes, open Deploy > Releases in your GitLab project and verify your release assets were uploaded.

You've successfully set up automatic GitLab releases for your extension.

  • If this is the first release for this extension, you're now ready to Submit your extension.
  • If this is an update to an already published extension, your users can now update to the latest version.
  • Users who installed your extension from the repository link get the new release too: Azot checks GitLab releases periodically and, with automatic extension updates on, installs it for them in the background.

Released under the MIT License.