Commit c55d774f authored by GridexX's avatar GridexX Committed by Thomas Boni
Browse files

feat(template_release): export release files artifact



Signed-off-by: default avatarGridexX <arsene582@gmail.com>
parent 5b2ef74a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
# Changelog
All notable changes to this job will be documented in this file.

## [0.2.0] - 2023-03-02
* Create files for each release and export them as artifacts
* Add the variable `RELEASE_PATH` 

## [0.1.1] - 2023-02-28
* Fix broken documentation links

+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ A `CHANGELOG.md` file as explained in the previous example, is required to creat
| `IMAGE_TAG` | The default tag for the docker image [alpine/httpie](https://hub.docker.com/r/alpine/httpie) | `3.2.1` |
| `GITLAB_API_URL` | The domain of GitLab instance. ⚠️ It should be changed if you using a self-hosted version | `gitlab.com` |
| `METADATA_FILE_EXTENSION` | The extension of metadata files | `.r2.yml` |
| `RELEASE_PATH` | The path where releases files are exposed as artifacts | `${CI_PROJECT_DIR}/releases` |

## Author
This resource is an **[official job](https://docs.r2devops.io/get-started/faq/#use-a-template)** added in [**R2Devops repository**](https://gitlab.com/r2devops/hub) by [@GridexX](https://gitlab.com/GridexX)
+11 −1
Original line number Diff line number Diff line
@@ -12,10 +12,12 @@ template_release:
    IMAGE_TAG: "3.2.1"
    GITLAB_API_URL: "${CI_SERVER_HOST}"
    METADATA_FILE_EXTENSION: ".r2.yml"
    RELEASE_PATH: "${CI_PROJECT_DIR}/releases"
  before_script:
    - apk update && apk add --no-cache bash
  script:
    # Url encode the project name
    - mkdir -p $RELEASE_PATH
    - PROJECT_ENCODED=$(/bin/bash -c "$(http --ignore-stdin --body https://gitlab.com/r2devops/hub/-/snippets/2462394/raw/92c7e820e5b7ce468d8031748e1a57c24c67f6a4/_encode.sh) && _encode '$CI_PROJECT_PATH'")
    # Search for all changelog files
    - METADATA_JOBS="$(find . -iname "*$METADATA_FILE_EXTENSION")"
@@ -92,7 +94,9 @@ template_release:
    -           exit 1;
    -         else
    -           if [ $(echo ${result} | grep "Release already exists" | wc -l) -eq 0 ]; then
    -             echo "New version detected for $JOB_NAME-$VERSION"
    -             echo "New version detected for ${JOB_RELEASE}"
    -             JOB_RELEASE_STRIP=$(echo ${JOB_RELEASE} | sed -e 's/\//|/g')
    -             echo "${CHANGELOG}" > ${RELEASE_PATH}/${JOB_RELEASE_STRIP}.md
    -           fi
    -   |
              echo "Processed ${JOB_RELEASE} : ${result}"
@@ -101,3 +105,9 @@ template_release:
    - done
  rules:
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
  artifacts:
    expose_as: "template_release"
    paths:
    - "${RELEASE_PATH}"
    expire_in: 3 days
    when: always