Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/MARP-792 create sprint release s20 #81

Merged
merged 11 commits into from
Aug 6, 2024
9 changes: 8 additions & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ on:
description: 'Build environment'
required: true
type: string
release_version:
description: 'Release version'
required: true
type: string
default: ''

jobs:
cleanup:
Expand All @@ -36,6 +41,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.release_version || github.ref }}

- name: Update environment variables for .env
env:
Expand Down Expand Up @@ -73,5 +80,5 @@ jobs:
- name: Build and bring up containers without cache
working-directory: ./marketplace-build
run: |
docker compose build --no-cache --build-arg BUILD_ENV=${{ inputs.build_env }}
docker compose build --no-cache --build-arg BUILD_ENV=${{ inputs.build_env }} --build-arg BUILD_VERSION=${{ inputs.release_version }}
docker compose up --force-recreate -d
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Docker Release
name: Release Build

on:
push:
branches: [ "master" ]
workflow_dispatch:
inputs:
image_version:
description: 'Marketplace Docker image version'
release_version:
description: 'Release version'
required: true
default: 'latest'
build_env:
Expand All @@ -19,11 +19,40 @@ env:
SERVICE_IMAGE_NAME: marketplace-service

jobs:
tagging_source:
name: Create new GH Tag for release
runs-on: self-hosted

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Update version
if: ${{ inputs.release_version != '' }}
env:
POM_FILE: './marketplace-service/pom.xml'
PACKAGE_FILE: './marketplace-ui/package.json'
run: |
xml ed -L -u "//_:project/_:version" -v "${{ inputs.release_version }}" $POM_FILE
sed -i 's/"version": "[^"]*"/"version": "${{ inputs.release_version }}"/' $PACKAGE_FILE

- name: Create release tag
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git fetch --tags
git push origin :refs/tags/${{ inputs.release_version }}
git tag -d ${{ inputs.release_version }}
git tag -a ${{ inputs.release_version }} -m "Released ${{ inputs.release_version }} by ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
git push origin ${{ inputs.release_version }}

build:
name: Build Docker images
needs: tagging_source
uses: ./.github/workflows/docker-build.yml
with:
release_version: ${{ inputs.release_version }}
build_env: ${{ inputs.build_env }}

release:
Expand Down Expand Up @@ -58,7 +87,7 @@ jobs:
- name: Refine release version
run: |
# This strips the git ref prefix from the version.
VERSION=${{ github.event.inputs.image_version }}
VERSION=${{ github.event.inputs.release_version }}
# This uses the Docker `latest` tag convention.
[ "$VERSION" == "main" ] && VERSION=latest
echo "VERSION=$VERSION" >> $GITHUB_ENV
Expand Down
2 changes: 2 additions & 0 deletions marketplace-build/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ services:
build:
context: ../marketplace-service
dockerfile: Dockerfile
args:
- BUILD_VERSION=${BUILD_VERSION}
ports:
- "8080:8080"
depends_on:
Expand Down
3 changes: 2 additions & 1 deletion marketplace-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ WORKDIR /app
RUN rm -rf /usr/local/tomcat/webapps/ROOT

# Copy the WAR file to the webapps directory in Tomcat
COPY --from=build-api /app/target/marketplace-service-0.0.1-SNAPSHOT.war /usr/local/tomcat/webapps/marketplace-service.war
ARG BUILD_VERSION
COPY --from=build-api /app/target/marketplace-service-${BUILD_VERSION}.war /usr/local/tomcat/webapps/marketplace-service.war

# Expose port 8080
EXPOSE 8080
Expand Down
Loading