-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (67 loc) · 2.63 KB
/
check-version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: CI/CD Pipeline
on:
push:
branches:
- release # 릴리즈 브랜치에 푸시할 때만 실행
pull_request:
branches:
- release # 릴리즈 브랜치로 PR이 올라올 때만 실행
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 2 # 최소 2개 커밋을 가져와 비교할 수 있도록 설정
- name: Get previous versionCode and versionName
id: prev_versions
run: |
# Fetch previous commit's build.gradle file
git show HEAD~1:app/build.gradle > prev_build.gradle
# Extract versionCode and versionName from the previous build.gradle
PREV_VERSION_CODE=$(grep 'versionCode' prev_build.gradle | awk '{print $2}')
PREV_VERSION_NAME=$(grep 'versionName' prev_build.gradle | awk '{print $2}')
echo "PREV_VERSION_CODE=${PREV_VERSION_CODE}" >> $GITHUB_ENV
echo "PREV_VERSION_NAME=${PREV_VERSION_NAME}" >> $GITHUB_ENV
- name: Get current versionCode and versionName
id: curr_versions
run: |
# Extract versionCode and versionName from the current build.gradle
CURR_VERSION_CODE=$(grep 'versionCode' app/build.gradle | awk '{print $2}')
CURR_VERSION_NAME=$(grep 'versionName' app/build.gradle | awk '{print $2}')
echo "CURR_VERSION_CODE=${CURR_VERSION_CODE}" >> $GITHUB_ENV
echo "CURR_VERSION_NAME=${CURR_VERSION_NAME}" >> $GITHUB_ENV
- name: Compare versions and fail if they are the same
run: |
if [ "${{ env.PREV_VERSION_CODE }}" = "${{ env.CURR_VERSION_CODE }}" ] && [ "${{ env.PREV_VERSION_NAME }}" = "${{ env.CURR_VERSION_NAME }}" ]; then
echo "Error: versionCode and versionName are identical to the previous commit."
exit 1
else
echo "Version check passed."
fi
build:
runs-on: ubuntu-latest
needs: check-version # 'check-version' 작업이 성공해야만 실행됨
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '17' # 사용 중인 Java 버전에 맞게 설정
- name: Build with Gradle
run: ./gradlew build
- name: Run tests
run: ./gradlew test
deploy:
runs-on: ubuntu-latest
needs: build # 'build' 작업이 성공해야만 실행됨
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Deploy
run: |
echo "Deploying application..."
# 배포 스크립트 또는 명령어를 여기에 추가
# 예: ./deploy.sh