Skip to content

Commit

Permalink
Update release script
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhoan-axonivy committed Aug 6, 2024
1 parent 53b5546 commit 10cef02
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
description: 'Version is used to create a git tag when releasing'
required: true
type: string
default: ''

jobs:
cleanup:
Expand All @@ -40,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 @@ -87,5 +90,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,4 +1,4 @@
name: Docker Release
name: Release Build

on:
push:
Expand All @@ -19,9 +19,28 @@ 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: 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 }}
Expand All @@ -36,17 +55,6 @@ jobs:
contents: read

steps:
- name: Create release tag
continue-on-error: true
run: |
git config user.name "$(git log -n 1 --pretty=format:%an)"
git config user.email "$(git log -n 1 --pretty=format:%ae)"
git push --delete origin ${{ inputs.release_version }} || true
git tag -d ${{ inputs.release_version }} || true
git commit -a -m "update projects 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 }}
- name: Wait for containers to be up and running
working-directory: ./marketplace-build
run: |
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

0 comments on commit 10cef02

Please sign in to comment.