메인 콘텐츠로 바로 가기
CI/CD

GitLab을 사용하여 자동으로 빌드 및 릴리스하는 앱을 만듭니다.

GitLab을 사용하여 무료로 CI/CD pipeline을 만들고 Ionic Capacitor JS 앱을 매번 main으로 푸시할 때마다 배포합니다.

아니크 다발 바부

Anik Dhabal Babu

컨텐츠 마케터

GitLab과 함께 자동 빌드 및 릴리즈 앱

이 기사에서는 GitLab과 함께 CI/CD pipeline 설정 방법을 안내합니다.

소개

Be sure you have added your Capacitor app first to Capgo, this tutorial just focuses on the upload phase. If you need to add your app to Capgo, you can follow this 튜토리얼.

커밋 규칙

커밋 규칙을 따르기 시작하세요. conventional commits이 규칙을 따르면 도구가 버전 번호를 업그레이드하는 방법을 이해할 수 있습니다. 5분만 투자하면 끝납니다.

Conventional commits

GitLab CI/CD for Tag

Create a .gitlab-ci.yml file in the root of your GitLab repository with the following content

 stages:
      - tag

 bump_version:
   stage: tag
   only:
     - main
  except:
    variables:
  - $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
  script:
   - git config --global user.email "gitlab@yourdomain.com"
   - git config --global user.name "GitLab CI/CD"
   - git checkout $CI_COMMIT_REF_NAME
   - git pull origin $CI_COMMIT_REF_NAME
   - npx capacitor-standard-version
   - git push origin $CI_COMMIT_REF_NAME --tags

Replace “gitlab@yourdomain.com” and “GitLab CI/CD” with your GitLab email and username in the script section. This configuration triggers the job only on pushes to the main branch and excludes commits with messages starting with “chore(release):”.

GitLab CI/CD for Build

Add another stage to your .gitlab-ci.yml file for the build:

    stages:
      - deploy

   deploy:
     stage: deploy
     only:
       - tags  # This job will only run for tag pushes
     script:
       - apt-get update -qy && apt-get install -y nodejs npm
       - npm install -g @capgo/cli
       - npm ci
       - npm run build
       - npx @capgo/cli bundle upload -a $CAPGO_TOKEN -c production
     variables:
       FIREBASE_CONFIG: $FIREBASE_CONFIG  # Define this in your GitLab project settings
     environment:
       name: production

Ensure you have your Capgo API key (CAPGO_TOKEN) added as a CI/CD variable in your GitLab project. Go to your project in GitLab, navigate to Settings > CI/CD > Variables, and add a variable named CAPGO_TOKEN with your API key value.

Customize the build script to match your specific project’s build process, such as changing the npm run build command.

결론

우리는 기술 여정을 한 걸음 더 나아갔습니다. 현대 소프트웨어 개발에서 CICD는 고려해야 할 중요한 요소입니다. 따라서 이 안내서가 모든 사람에게 의미가 있기를 바랍니다.

실시간 업데이트 Capacitor 앱

웹层 버그가 실시간으로 활성화되면, 앱 스토어 승인 대기 없이 Capgo를 통해 패치를 배포합니다. 사용자는 배경에서 업데이트를 받으며, 네이티브 변경 사항은 일반적인 검토 경로에 남아 있습니다.

시작하기

최신 블로그 글

Capgo은 전문적인 모바일 앱을 만들기 위해 필요한 최고의洞察력을 제공합니다.