Skip to content

Commit

Permalink
refactored expected gitlab_release input
Browse files Browse the repository at this point in the history
  • Loading branch information
feskol committed Nov 28, 2024
1 parent 9fecb45 commit 54e9490
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
gitlab_release:
description: "GitLab Release (e.g., 17.6.1+ce.0 or 17.6.1+ee.0)"
description: "GitLab Release Docker-Tag (e.g., 17.6.1-ce.0 or 17.6.1-ee.0)"
required: true
docker_push_tags:
description: "Additional Docker tags (comma-separated, e.g., 'beta,stable')"
Expand Down Expand Up @@ -38,29 +38,20 @@ jobs:
- name: Define ENV variables
id: define-variables
run: |
GITLAB_RELEASE="${{ github.event.inputs.gitlab_release }}"
# Replace "+" with "-" in the release
NORMALIZED_RELEASE=$(echo "$GITLAB_RELEASE" | sed 's/+/-/g')
# Define Release-Version
echo "GITLAB_RELEASE_VERSION=$NORMALIZED_RELEASE" >> $GITHUB_ENV
# Extract suffix (-ce or -ee)
SUFFIX=$(echo "$NORMALIZED_RELEASE" | sed -E 's/.*-(ce|ee).*/\1/')
SUFFIX=$(echo "${{ github.event.inputs.gitlab_release }}" | sed -E 's/.*-(ce|ee).*/\1/')
echo "GITLAB_EDITION=$SUFFIX" >> $GITHUB_ENV
- name: Parse Tags
id: parse-tags
run: |
# Replace "+" with "-" in the release
NORMALIZED_RELEASE="${{ env.GITLAB_RELEASE_VERSION }}"
GITLAB_RELEASE="${{ github.event.inputs.gitlab_release }}"
# Extract suffix (ce or ee)
SUFFIX="${{ env.GITLAB_EDITION }}"
# Strip version-specific parts to generate base tags
BASE_TAG=$(echo "$NORMALIZED_RELEASE" | sed -E "s/(\.0)?-${SUFFIX}.0$//")
BASE_TAG=$(echo "$GITLAB_RELEASE" | sed -E "s/(\.0)?-${SUFFIX}.0$//")
TAG_MAJOR=$(echo "$BASE_TAG" | cut -d. -f1)
TAG_MAJOR_MINOR=$(echo "$BASE_TAG" | cut -d. -f1-2)
TAG_MAJOR_MINOR_PATCH=$(echo "$BASE_TAG" | cut -d. -f1-3)
Expand All @@ -79,7 +70,7 @@ jobs:
fi
# Default tags
DEFAULT_TAGS="$NORMALIZED_RELEASE $TAG_MAJOR_MINOR_PATCH-$SUFFIX $DEFAULT_NEW_TAGS"
DEFAULT_TAGS="$GITLAB_RELEASE $TAG_MAJOR_MINOR_PATCH-$SUFFIX $DEFAULT_NEW_TAGS"
# Append user-provided tags if any
if [ -n "${{ github.event.inputs.docker_push_tags }}" ]; then
Expand Down Expand Up @@ -110,9 +101,11 @@ jobs:
- name: Download GitLab Build Files
run: |
GITLAB_RELEASE=${{ github.event.inputs.gitlab_release }}
# Replace "-" with "+" in the release
GITLAB_OMNIBUS_RELEASE=$(echo "${{ github.event.inputs.gitlab_release }}" | sed 's/-/+/g')
mkdir -p build
curl -sL "https://gitlab.com/gitlab-org/omnibus-gitlab/-/archive/${GITLAB_RELEASE}/omnibus-gitlab-${GITLAB_RELEASE}.tar.gz" | tar xz --strip-components=2 -C build "omnibus-gitlab-${GITLAB_RELEASE}/docker"
curl -sL "https://gitlab.com/gitlab-org/omnibus-gitlab/-/archive/${GITLAB_OMNIBUS_RELEASE}/omnibus-gitlab-${GITLAB_OMNIBUS_RELEASE}.tar.gz" | tar xz --strip-components=2 -C build "omnibus-gitlab-${GITLAB_OMNIBUS_RELEASE}/docker"
- name: List contents of build directory
run: |
Expand All @@ -121,7 +114,7 @@ jobs:
- name: Create needed /RELEASE file
run: |
RELEASE_PACKAGE=gitlab-${{ env.GITLAB_EDITION }}
RELEASE_VERSION=${{ env.GITLAB_RELEASE_VERSION }}
RELEASE_VERSION=${{ github.event.inputs.gitlab_release }}
echo "DOWNLOAD_URL_amd64=https://packages.gitlab.com/gitlab/${RELEASE_PACKAGE}/packages/ubuntu/jammy/${RELEASE_PACKAGE}_${RELEASE_VERSION}_amd64.deb/download.deb" > build/RELEASE
echo "DOWNLOAD_URL_arm64=https://packages.gitlab.com/gitlab/${RELEASE_PACKAGE}/packages/ubuntu/jammy/${RELEASE_PACKAGE}_${RELEASE_VERSION}_arm64.deb/download.deb" >> build/RELEASE
Expand Down

0 comments on commit 54e9490

Please sign in to comment.