Skip to content

Commit fccaebc

Browse files
committed
ci: 초기 프로젝트 설정(버전관리, git hook)
1 parent 26412dd commit fccaebc

File tree

12 files changed

+8029
-33
lines changed

12 files changed

+8029
-33
lines changed

.github/workflows/changelog.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Changelog
3+
4+
on: [push]
5+
6+
jobs:
7+
changelog:
8+
name: Make changelog
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
with:
13+
fetch-depth: 0
14+
- uses: actions/setup-node@v1
15+
with:
16+
node-version: 10.20.1
17+
- name: Show current changelog
18+
run: |
19+
npm ci
20+
make current_changelog

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
name: Release
3+
4+
on:
5+
pull_request:
6+
types: [closed]
7+
branches:
8+
- main
9+
10+
jobs:
11+
release:
12+
if: github.event.pull_request.merged == true
13+
name: Release
14+
runs-on: macos-10.15
15+
steps:
16+
- uses: actions/checkout@v2
17+
- run: |
18+
git fetch --prune --unshallow
19+
- name: Install dependencies
20+
run: |
21+
npm ci
22+
- name: Commit files
23+
run: |
24+
git config --local user.email "[email protected]"
25+
git config --local user.name "GitHub Action"
26+
export VERSION=$(npx next-standard-version)
27+
export DESCRIPTION=$(npx standard-version --dry-run --silent | grep -v yarn | grep -v Done | grep -v "\-\-\-" | grep -v standard-version)
28+
echo >>$GITHUB_ENV DESCRIPTION=$DESCRIPTION
29+
echo >>$GITHUB_ENV VERSION=$VERSION
30+
make release
31+
git add Sticky.xcodeproj/project.pbxproj
32+
git commit --no-verify -m "chore(release): ${VERSION}"
33+
npx standard-version
34+
git tag -d v$VERSION
35+
git reset --soft HEAD~~ && git commit --no-verify --no-edit -m "chore(release): ${VERSION}"
36+
git tag v$VERSION
37+
- name: Push changes
38+
uses: ad-m/github-push-action@master
39+
with:
40+
github_token: ${{ secrets.GITHUB_TOKEN }}
41+
tags: true
42+
- name: Create Github Release
43+
id: create_release
44+
uses: actions/create-release@v1
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
with:
48+
tag_name: v${{ env.VERSION }}
49+
release_name: Release v${{ env.VERSION }}
50+
body: |
51+
${{ env.DESCRIPTION }}
52+
draft: false
53+
prerelease: false

.github/workflows/swift.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Swift
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
# https://github.com/actions/virtual-environments
12+
runs-on: macos-10.15
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Swiftlint
16+
run: make lint
17+
- name: Build
18+
run: make build

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,5 @@ fastlane/test_output
8888
# https://github.com/johnno1962/injectionforxcode
8989

9090
iOSInjectionProject/
91+
92+
node_modules

Sticky.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@
418418
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
419419
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
420420
CODE_SIGN_STYLE = Automatic;
421+
CURRENT_PROJECT_VERSION = 1;
421422
DEVELOPMENT_ASSET_PATHS = "\"Sticky/Preview Content\"";
422423
DEVELOPMENT_TEAM = M75SXEJ86F;
423424
ENABLE_PREVIEWS = YES;
@@ -427,6 +428,7 @@
427428
"$(inherited)",
428429
"@executable_path/Frameworks",
429430
);
431+
MARKETING_VERSION = 1.0.0;
430432
PRODUCT_BUNDLE_IDENTIFIER = com.nexters.18th.adng.Sticky;
431433
PRODUCT_NAME = "$(TARGET_NAME)";
432434
SWIFT_VERSION = 5.0;
@@ -440,6 +442,7 @@
440442
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
441443
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
442444
CODE_SIGN_STYLE = Automatic;
445+
CURRENT_PROJECT_VERSION = 1;
443446
DEVELOPMENT_ASSET_PATHS = "\"Sticky/Preview Content\"";
444447
DEVELOPMENT_TEAM = M75SXEJ86F;
445448
ENABLE_PREVIEWS = YES;
@@ -449,6 +452,7 @@
449452
"$(inherited)",
450453
"@executable_path/Frameworks",
451454
);
455+
MARKETING_VERSION = 1.0.0;
452456
PRODUCT_BUNDLE_IDENTIFIER = com.nexters.18th.adng.Sticky;
453457
PRODUCT_NAME = "$(TARGET_NAME)";
454458
SWIFT_VERSION = 5.0;

Sticky/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<key>CFBundlePackageType</key>
1616
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0</string>
18+
<string>$(MARKETING_VERSION)</string>
1919
<key>CFBundleVersion</key>
20-
<string>1</string>
20+
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>LSRequiresIPhoneOS</key>
2222
<true/>
2323
<key>UIApplicationSceneManifest</key>

StickyTests/StickyTests.swift

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,17 @@
55
// Created by deo on 2021/01/13.
66
//
77

8-
import XCTest
98
@testable import Sticky
9+
import XCTest
1010

1111
class StickyTests: XCTestCase {
12+
override func setUpWithError() throws {}
1213

13-
override func setUpWithError() throws {
14-
// Put setup code here. This method is called before the invocation of each test method in the class.
15-
}
14+
override func tearDownWithError() throws {}
1615

17-
override func tearDownWithError() throws {
18-
// Put teardown code here. This method is called after the invocation of each test method in the class.
19-
}
20-
21-
func testExample() throws {
22-
// This is an example of a functional test case.
23-
// Use XCTAssert and related functions to verify your tests produce the correct results.
24-
}
16+
func testExample() throws {}
2517

2618
func testPerformanceExample() throws {
27-
// This is an example of a performance test case.
28-
self.measure {
29-
// Put the code you want to measure the time of here.
30-
}
19+
self.measure {}
3120
}
32-
3321
}

StickyUITests/StickyUITests.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,19 @@
88
import XCTest
99

1010
class StickyUITests: XCTestCase {
11-
1211
override func setUpWithError() throws {
13-
// Put setup code here. This method is called before the invocation of each test method in the class.
14-
15-
// In UI tests it is usually best to stop immediately when a failure occurs.
1612
continueAfterFailure = false
17-
18-
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
1913
}
2014

21-
override func tearDownWithError() throws {
22-
// Put teardown code here. This method is called after the invocation of each test method in the class.
23-
}
15+
override func tearDownWithError() throws {}
2416

2517
func testExample() throws {
26-
// UI tests must launch the application that they test.
2718
let app = XCUIApplication()
2819
app.launch()
29-
30-
// Use recording to get started writing UI tests.
31-
// Use XCTAssert and related functions to verify your tests produce the correct results.
3220
}
3321

3422
func testLaunchPerformance() throws {
3523
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) {
36-
// This measures how long it takes to launch your application.
3724
measure(metrics: [XCTApplicationLaunchMetric()]) {
3825
XCUIApplication().launch()
3926
}

install_swiftlint.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
SWIFTLINT_VERSION=0.42.0
6+
SWIFTLINT_PKG_PATH="/tmp/SwiftLint.pkg"
7+
SWIFTLINT_PKG_URL="https://github.com/realm/SwiftLint/releases/download/${SWIFTLINT_VERSION}/SwiftLint.pkg"
8+
wget --output-document=$SWIFTLINT_PKG_PATH $SWIFTLINT_PKG_URL
9+
10+
if [ -f $SWIFTLINT_PKG_PATH ]; then
11+
echo "SwiftLint package exists! Installing it..."
12+
sudo installer -pkg $SWIFTLINT_PKG_PATH -target /
13+
else
14+
echo "SwiftLint package doesn't exist. Compiling from source..." &&
15+
git clone https://github.com/realm/SwiftLint.git /tmp/SwiftLint &&
16+
cd /tmp/SwiftLint &&
17+
git submodule update --init --recursive &&
18+
sudo make install
19+
fi

makefile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
GREEN=\n\033[1;32;40m
2+
RED=\n\033[1;31;40m
3+
NC=\033[0m # No Color
4+
5+
# OS_VERSION 환경변수 등록 필수
6+
SWIFTLINT = $(shell command -v swiftlint)
7+
8+
lint:
9+
ifndef SWIFTLINT
10+
./install_swiftlint.sh
11+
endif
12+
swiftlint
13+
.PHONY: lint
14+
15+
XCPRETTY = $(shell command -v xcpretty)
16+
PROJECT_NAME = Sticky
17+
WORKSPACE = $(shell find . -name "*.xcworkspace")
18+
EMULATOR = iPhone 12 mini
19+
20+
OS_VERSION = $(shell xcodebuild -showsdks | egrep "iOS (\d)+.(\d)+" | head -1 | cut -f2 -d" ")
21+
build:
22+
ifndef XCPRETTY
23+
$(error xcpretty를 설치하세요)
24+
endif
25+
set -o pipefail && xcodebuild \
26+
-workspace ${WORKSPACE} \
27+
-configuration Debug \
28+
-scheme ${PROJECT_NAME} \
29+
-destination 'platform=iOS Simulator,OS=${OS_VERSION},name=${EMULATOR}' \
30+
-enableCodeCoverage YES \
31+
build test \
32+
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=YES | xcpretty
33+
.PHONY: build
34+
35+
test:
36+
ifndef XCPRETTY
37+
$(error xcpretty를 설치하세요)
38+
endif
39+
xcodebuild \
40+
-workspace ${WORKSPACE} \
41+
-configuration Debug \
42+
-scheme ${PROJECT_NAME} \
43+
-destination 'platform=iOS Simulator,OS=${OS_VERSION},name=${EMULATOR}' \
44+
-enableCodeCoverage YES \
45+
test \
46+
CODE_SIGN_IDENTITY="" \
47+
CODE_SIGNING_REQUIRED=NO \
48+
ONLY_ACTIVE_ARCH=NO | xcpretty
49+
.PHONY: test
50+
51+
release:
52+
sed -i ".bak" "s/MARKETING_VERSION = .*/MARKETING_VERSION = $(shell npx next-standard-version);/g" ${PROJECT_NAME}.xcodeproj/project.pbxproj
53+
.PHONY: release
54+
55+
# 마지막 tag로부터 현재까지의 changelog 및 버전 확인 용
56+
current_changelog:
57+
@/bin/sh -c "echo \"${GREEN}[release version] $(shell npx next-standard-version)${NC}\""
58+
@/bin/sh -c "echo \"${GREEN}[description] ${NC}\""
59+
@npx standard-version --dry-run --silent | grep -v Done | grep -v "\-\-\-" | grep -v standard-version
60+
.PHONY: current_changelog

0 commit comments

Comments
 (0)