FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 253e434a authored by Ryan Kowalewski's avatar Ryan Kowalewski :man_dancing:
Browse files

feat: add release-it image

parent 5f106165
No related branches found
No related tags found
1 merge request!107feat: add release-it image
......@@ -284,3 +284,14 @@ commitlint:
NODE_VERSION: "18"
BUILD_ARGS: "NODE_VERSION"
WHEN_TO_RUN: "weekly"
release-it-16:
extends: .build_and_push
variables:
IMAGE_TYPE: release-it
IMAGE_NAME: release-it
TAGS: latest 16 16.2
NODE_VERSION: "18"
ALPINE_VERSION: "3.18"
RELEASE_IT_VERSION: "16.2.1"
WHEN_TO_RUN: "weekly"
......@@ -26,6 +26,7 @@ directory for more details.
* [photo-api-base](photo-api-base/README.md)
* [pre-commit](pre-commit/README.md)
* [prometheus-remote-writer](prometheus-remote-writer/README.md)
* [release-it](release-it/README.md)
## Configuration
......
ARG NODE_VERSION=18
ARG ALPINE_VERSION=3.18
ARG RELEASE_IT_VERSION=16.2.1
ARG BUMPER_VERSION=5.1.0
ARG CONVENTIONAL_CHANGELOG_VERSION=7.0.2
ARG KEEP_A_CHANGELOG_VERSION=4.0.0
ARG REGEX_BUMPER_VERSION=5.0.0
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION}
RUN apk add --update --no-cache \
coreutils git jq curl python3 bash
RUN npm install -g \
release-it@${RELEASE_IT_VERSION} \
@release-it/bumper@${BUMPER_VERSION} \
@release-it/conventional-changelog@${CONVENTIONAL_CHANGELOG_VERSION} \
@release-it/keep-a-changelog@${KEEP_A_CHANGELOG_VERSION} \
@j-ulrich/release-it-regex-bumper@${REGEX_BUMPER_VERSION}
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install python-gitlab
ADD update-merge-request.sh /opt/devops/
ADD release.sh /opt/devops/
# Release It
This builds a container with
[release-it](https://github.com/release-it/release-it) and associated plugins
installed. It also includes some scripts specific to the [UIS DevOps release
automation
processes](https://guidebook.devops.uis.cam.ac.uk/en/latest/explanations/gitlab-release-automation/).
#! /usr/bin/env bash
set -e
MAGENTA="\e[35m"
CLEAR="\e[0m"
log() {
echo -e "${MAGENTA}${1}${CLEAR}"
}
if ! git log --pretty=format:%s "$(git describe --tags --abbrev=0)..HEAD" | grep -E '^(feat|fix)'; then
log "A new release is not required."
exit 0
fi
log "Running release-it to generate a new release..."
if [[ -n "$USE_MERGE_REQUEST_RELEASE_FLOW" ]]; then
npx release-it --ci --no-npm --no-git.commit
else
npx release-it --ci
fi
#! /usr/bin/env bash
set -e
MAGENTA="\e[35m"
CLEAR="\e[0m"
log() {
echo -e "${MAGENTA}${1}${CLEAR}"
}
branch=$(git rev-parse --abbrev-ref HEAD)
release_branch="release-it--${branch}"
if ! git log --pretty=format:%s "$(git describe --tags --abbrev=0)..HEAD" | grep -E '^(feat|fix)'; then
log "A new release is not required."
exit 0
fi
log "Checking out ${release_branch}..."
git checkout -B "$release_branch"
log "Running release-it..."
npx release-it --ci --no-git.tag --no-git.requireUpstream --git.pushArgs=--force --no-gitlab
log "Generating merge request title and description..."
title="Draft: $(git show -s --format=%s)"
changelog=$(npx release-it --changelog)
description=$(cat << EOF
:rocket: _This is an automated release merge request. For more information, see the [GitLab Release Automation](https://guidebook.devops.uis.cam.ac.uk/en/latest/explanations/gitlab-release-automation/) section in the Guidebook._
$changelog
EOF
)
log "Attempting to retrieve existing merge request..."
mr=$(gitlab --private-token "$GITLAB_TOKEN" --output json --fields iid project-merge-request list \
--project-id "$CI_PROJECT_ID" \
--state "opened" \
--source-branch "$release_branch" \
--target-branch "$branch"
)
if echo "$mr" | jq -e ". == []"; then
log "Couldn't find an existing merge request for '${release_branch} -> ${branch}'."
log "Creating merge request..."
gitlab --private-token "$GITLAB_TOKEN" project-merge-request create \
--project-id "$CI_PROJECT_ID" \
--source-branch "$release_branch" \
--target-branch "$branch" \
--title "$title" \
--description "$description"
else
iid=$(echo "$mr" | jq -r ".[0].iid")
log "Found existing merge request for ${release_branch} -> ${branch} with iid '${iid}'."
log "Updating merge request..."
gitlab --private-token "$GITLAB_TOKEN" project-merge-request update \
--project-id "$CI_PROJECT_ID" \
--iid "$iid" \
--title "$title" \
--description "$description"
fi
git checkout "$branch"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment