Commit c59d8a17 authored by Cédric OLIVIER's avatar Cédric OLIVIER
Browse files

Merge branch 'feat/component' into 'master'

feat: migrate to CI/CD component

See merge request to-be-continuous/gitlab-package!6
parents ab4407ee 30cb585e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ include:
    file: '/templates/validation.yml'
  - project: 'to-be-continuous/bash'
    ref: '3.3'
    file: 'templates/gitlab-ci-bash.yml'
    file: '/templates/gitlab-ci-bash.yml'
  - project: 'to-be-continuous/semantic-release'
    ref: '3.7'
    file: '/templates/gitlab-ci-semrel.yml'    
+29 −6
Original line number Diff line number Diff line
@@ -4,22 +4,45 @@ This project implements a GitLab CI/CD template to publish artifacts to GitLab's

## Usage

In order to include this template in your project, add the following to your `gitlab-ci.yml`:
This template can be used both as a [CI/CD component](https://docs.gitlab.com/ee/ci/components/#use-a-component-in-a-cicd-configuration) 
or using the legacy [`include:project`](https://docs.gitlab.com/ee/ci/yaml/index.html#includeproject) syntax.

### Use as a CI/CD component

Add the following to your `gitlab-ci.yml`:

```yaml
include:
  # 1: include the component
  - component: gitlab.com/to-be-continuous/gitlab-package/gitlab-ci-gitlab-package@1.1.0
    # 2: set/override component inputs
    inputs:
      files: "build/*.tgz" # ⚠ this is only an example
```

### Use as a CI/CD template (legacy)

Add the following to your `gitlab-ci.yml`:

```yaml
include:
  # 1: include the template
  - project: 'to-be-continuous/gitlab-package'
    ref: '1.1.0'
    file: '/templates/gitlab-ci-gitlab-package.yml'

variables:
  # 2: set/override template variables
  GLPKG_FILES: "build/*.tgz" # ⚠ this is only an example
```

## Global configuration

The GitLab Package template uses some global configuration used throughout all jobs.

| Name                  | Description                            | Default value     |
| Input / Variable | Description                            | Default value     |
| --------------------- | -------------------------------------- | ----------------- |
| `GLPKG_IMAGE`         | The Docker image used to publish GitLab packages  | `registry.hub.docker.com/curlimages/curl:latest` |
| `image` / `GLPKG_IMAGE` | The Docker image used to publish GitLab packages  | `registry.hub.docker.com/curlimages/curl:latest` |

## Jobs

@@ -31,7 +54,7 @@ This job is bound to the `publish` stage and is executed on a Git tag with a sem

It uses the following variables:

| Name                  | Description                              | Default value     |
| Input / Variable | Description                              | Default value     |
| --------------------- | ---------------------------------------- | ----------------- |
| `GLPKG_FILES`         | Glob patterns matching files to include in the GitLab package (:warning: does not support double star). | _none_ (mandatory) |
| `GLPKG_PACKAGE`       | Name of the package to publish           | `$CI_PROJECT_NAME` |
| `files` / `GLPKG_FILES` | Glob patterns matching files to include in the GitLab package (:warning: does not support double star). | _none_ (mandatory) |
| `package` / `GLPKG_PACKAGE` | Name of the package to publish           | `$CI_PROJECT_NAME` |
+2 −2
Original line number Diff line number Diff line
@@ -27,13 +27,13 @@ if [[ "$curVer" ]]; then
  log_info "Bump version from \\e[33;1m${curVer}\\e[0m to \\e[33;1m${nextVer}\\e[0m (release type: $relType)..."

  # replace in README
  sed -e "s/ref: '$curVer'/ref: '$nextVer'/" README.md > README.md.next
  sed -e "s/ref: *'$curVer'/ref: '$nextVer'/" -e "s/ref: *\"$curVer\”/ref: \”$nextVer\”/" -e "s/component: *\(.*\)@$curVer/component: \1@$nextVer/" README.md > README.md.next
  mv -f README.md.next README.md

  # replace in template and variants
  for tmpl in templates/*.yml
  do
    sed -e "s/\"$curVer\"/\"$nextVer\"/" "$tmpl" > "$tmpl.next"
    sed -e "s/command: *\[\"--service\", \"\(.*\)\", \"$curVer\"\]/command: [\"--service\", \"\1\", \"$nextVer\"]/" "$tmpl" > "$tmpl.next"
    mv -f "$tmpl.next" "$tmpl"
  done
else
+2 −0
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@
  "description": "Publish artifacts to GitLab's [Generic Package Registry](https://docs.gitlab.com/ee/user/packages/generic_packages/)",
  "template_path": "templates/gitlab-ci-gitlab-package.yml",
  "kind": "build",
  "prefix": "glpkg",
  "is_component": true,
  "variables": [
    {
      "name": "GLPKG_IMAGE",
+5.39 KiB (21.1 KiB)
Loading image diff...
Loading