Commit 0da9dafc authored by Watchtek's avatar Watchtek
Browse files

Update .gitlab-ci.yml file

parent e4278302
Loading
Loading
Loading
Loading
Loading
+9 −99
Original line number Diff line number Diff line
# https://to-be-continuous.gitlab.io/kicker/
# included templates
include:
  # Gitleaks template
  - component: "$CI_SERVER_FQDN/to-be-continuous/gitleaks/gitlab-ci-gitleaks@2.8"
  # Python template
  - component: "$CI_SERVER_FQDN/to-be-continuous/python/gitlab-ci-python@7.11"
    inputs:
      pylint-enabled: true
  # Bash template
  - component: "$CI_SERVER_FQDN/to-be-continuous/bash/gitlab-ci-bash@3.9"
    inputs:
      shellcheck-files: "scripts/*.sh"

# your pipeline stages
stages:
  - build
  - test
  - package-build
  - package-test
  - infra
  - deploy
  - acceptance
  - publish
  - infra-prod
  - production

variables:
  TZ: "Asia/Seoul"
  BINARY_NAME: "load_check"   # ✅ set only once here
  BINARY_NAME: "load_check"

.default_build_template: &build_template
  stage: package-build
  needs:
    - job: py-lint
      artifacts: false
r95:
  stage: build
  image: rockylinux/rockylinux:9.5-minimal
  script:
    - echo "Creating artifact for $TARGET_OS"
    - export HOME=/tmp
    - pip install -r requirements.txt
    - pyinstaller --onefile ${BINARY_NAME}.py
    - export TS=$(date +%Y-%m-%d_%H%M)
    - |
      if [ "$TARGET_OS" = "windows" ]; then
      mv dist/$DIST_FILE "${BINARY_NAME}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHORT_SHA}_${TS}_${TARGET_OS}_amd64.exe"
      else
      mv dist/$DIST_FILE "${BINARY_NAME}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHORT_SHA}_${TS}_${TARGET_OS}_amd64"
      fi
    - dnf install -y python3 python3-pip
    - pip3 install -r requirements.txt
    - pyinstaller --onefile --noconfirm ${BINARY_NAME}.py ${CI_JOB_NAME}.py
  artifacts:
    paths:
      - "${BINARY_NAME}_*"
      - dist/${CI_JOB_NAME}.py
    expire_in: 1 week
 No newline at end of file
  rules:
    - if: '$CI_COMMIT_TAG'
      when: never
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
      when: on_success
    - if: '$CI_COMMIT_BRANCH =~ /dev|test|ci|pre|production/'
      when: on_success
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
      when: never
    - when: manual

windows_bin:
  <<: *build_template
  image:
    name: batonogov/pyinstaller-windows:latest
    entrypoint: ['']
  variables:
    TARGET_OS: "windows"
    DIST_FILE: "${BINARY_NAME}.exe"

linux_slim_bin:
  <<: *build_template
  image:
    name: batonogov/pyinstaller-linux:latest-slim
    entrypoint: ['']
  variables:
    TARGET_OS: "linux"
    DIST_FILE: "${BINARY_NAME}"

release_job:
  stage: publish
  image: registry.gitlab.com/gitlab-org/cli
  needs:
    - job: windows_bin
      artifacts: true
    - job: linux_slim_bin
      artifacts: true
    - job: bash-shellcheck
      artifacts: false
  before_script:
    - apk add --no-cache curl
  script:
    - sh scripts/release.sh
  rules:
    - if: '$CI_COMMIT_TAG'
      when: never
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
      when: on_success
    - if: '$CI_COMMIT_BRANCH =~ /dev|test|ci|pre|production/'
      when: on_success
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
      when: never
    - when: manual
 No newline at end of file