Skip to content

Commit b5c1e27

Browse files
authored
ci: Automate release process with release please (#72)
1 parent 5d2912f commit b5c1e27

15 files changed

+347
-53
lines changed

.github/actions/build-docs/action.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Build Documentation
2+
description: 'Build Documentation.'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Install jazzy gem
8+
shell: bash
9+
run: gem install jazzy
10+
11+
- name: Build Documentation
12+
shell: bash
13+
run: jazzy -o docs
14+
15+
- name: Validate coverage
16+
shell: bash
17+
run: |
18+
FULLDOC=`jq '.warnings | length == 0' docs/undocumented.json`
19+
[ $FULLDOC == "true" ]

.github/actions/ci/action.yml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# This is a composite to allow sharing these steps into other workflows.
2+
# For instance it could be used by regular CI as well as the release process.
3+
4+
name: CI Workflow
5+
description: 'Shared CI workflow.'
6+
inputs:
7+
xcode-version:
8+
description: 'Which version of xcode should be installed'
9+
required: true
10+
ios-sim:
11+
description: 'iOS Simulator to use for testing'
12+
required: true
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd
18+
with:
19+
xcode-version: ${{ inputs.xcode-version }}
20+
21+
- name: Install mint
22+
shell: bash
23+
run: |
24+
brew tap mint-lang/mint-lang
25+
brew install mint-lang
26+
27+
- name: Install cocoapods
28+
shell: bash
29+
run: gem install cocoapods
30+
31+
- name: Lint the podspec
32+
shell: bash
33+
run: pod spec lint LDSwiftEventSource.podspec
34+
35+
- name: Build & Test on macOS Simulator
36+
shell: bash
37+
run: xcodebuild test -scheme 'LDSwiftEventSource' -sdk macosx -destination 'platform=macOS' | xcpretty
38+
39+
- name: Build for ARM64 macOS
40+
shell: bash
41+
run: xcodebuild build -scheme 'LDSwiftEventSource' -arch arm64e -sdk macosx | xcpretty
42+
43+
- name: Build Tests for iOS device
44+
shell: bash
45+
run: xcodebuild build-for-testing -scheme 'LDSwiftEventSource' -sdk iphoneos CODE_SIGN_IDENTITY= | xcpretty
46+
47+
- name: Build & Test on iOS Simulator
48+
shell: bash
49+
run: xcodebuild test -scheme 'LDSwiftEventSource' -sdk iphonesimulator -destination '${{ inputs.ios-sim }}' CODE_SIGN_IDENTITY= | xcpretty
50+
51+
- name: Build Tests for tvOS device
52+
shell: bash
53+
run: xcodebuild build-for-testing -scheme 'LDSwiftEventSource' -sdk appletvos CODE_SIGN_IDENTITY= | xcpretty
54+
55+
- name: Build & Test on tvOS Simulator
56+
shell: bash
57+
run: xcodebuild test -scheme 'LDSwiftEventSource' -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' | xcpretty
58+
59+
- name: Build for watchOS simulator # No XCTest testing on watchOS
60+
shell: bash
61+
run: xcodebuild build -scheme 'LDSwiftEventSource' -sdk watchsimulator | xcpretty
62+
63+
- name: Build for watchOS device # No XCTest testing on watchOS
64+
shell: bash
65+
run: xcodebuild build -scheme 'LDSwiftEventSource' -sdk watchos | xcpretty
66+
67+
- name: Build & Test with swiftpm
68+
shell: bash
69+
run: swift test -v 2>&1 | xcpretty
70+
71+
- name: Run contract tests
72+
shell: bash
73+
run: make contract-tests
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Publish Documentation
2+
description: 'Publish the documentation to GitHub pages'
3+
inputs:
4+
token:
5+
description: 'Token to use for publishing.'
6+
required: true
7+
8+
runs:
9+
using: composite
10+
steps:
11+
- uses: launchdarkly/gh-actions/actions/[email protected]
12+
name: 'Publish to GitHub pages'
13+
with:
14+
docs_path: docs
15+
github_token: ${{ inputs.token }}

.github/actions/publish/action.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Publish Package
2+
description: 'Publish the package to Cocoapods'
3+
inputs:
4+
dry_run:
5+
description: 'Is this a dry run. If so no package will be published.'
6+
required: true
7+
8+
runs:
9+
using: composite
10+
steps:
11+
- name: Push to cocoapods
12+
if: ${{ inputs.dry_run == 'false' }}
13+
shell: bash
14+
run: pod trunk push LDSwiftEventSource.podspec --allow-warnings --verbose
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Update xcode project version numbers
2+
description: 'Update xcode project version numbers'
3+
inputs:
4+
branch:
5+
description: 'The branch to checkout and push updates to'
6+
required: true
7+
8+
runs:
9+
using: composite
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
ref: ${{ inputs.branch }}
14+
15+
- name: Calculate version numbers
16+
id: version
17+
shell: bash
18+
run: |
19+
version=$(jq -r '."."' .release-please-manifest.json)
20+
major=$(echo "$version" | cut -f1 -d.)
21+
minor=$(echo "$version" | cut -f2 -d.)
22+
patch=$(echo "$version" | cut -f3 -d.)
23+
# 64 + version gives us a letter offset for the framework version.
24+
framework=$(echo $((major + 64)) | awk '{ printf("%c", $1) }')
25+
26+
echo "major=${major}" >> "$GITHUB_OUTPUT"
27+
echo "minor=${minor}" >> "$GITHUB_OUTPUT"
28+
echo "patch=${patch}" >> "$GITHUB_OUTPUT"
29+
echo "framework=${framework}" >> "$GITHUB_OUTPUT"
30+
31+
- name: Update other version numbers
32+
shell: bash
33+
run: |
34+
sed -i .bak -E \
35+
-e 's/MARKETING_VERSION = [^;]+/MARKETING_VERSION = ${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}/' \
36+
-e 's/DYLIB_CURRENT_VERSION = [^;]+/DYLIB_CURRENT_VERSION = ${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}/' \
37+
-e 's/DYLIB_COMPATIBILITY_VERSION = [^;]+/DYLIB_COMPATIBILITY_VERSION = ${{ steps.version.outputs.major }}.0.0/' \
38+
-e 's/FRAMEWORK_VERSION = .*/FRAMEWORK_VERSION = ${{ steps.version.outputs.framework }};/' \
39+
LDSwiftEventSource.xcodeproj/project.pbxproj
40+
41+
sed -i .bak -E \
42+
-e "s/pod 'LDSwiftEventSource', '~> [0-9]+.[0-9]+'/pod 'LDSwiftEventSource', '~> ${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}'/" \
43+
-e "s/github \"LaunchDarkly\/swift-eventsource\" ~> [0-9]+.[0-9]+/github \"LaunchDarkly\/swift-eventsource\" ~> ${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}/" README.md
44+
45+
rm -f LDSwiftEventSource.xcodeproj/project.pbxproj.bak README.md.bak
46+
if [ $(git status --porcelain | wc -l) -gt 0 ]; then
47+
git config --global user.name 'LaunchDarklyReleaseBot'
48+
git config --global user.email '[email protected]'
49+
50+
git add LDSwiftEventSource.xcodeproj/project.pbxproj
51+
git add README.md
52+
53+
git commit -m 'Updating generated project and readme files'
54+
git push
55+
fi

.github/workflows/ci.yml

+11-50
Original file line numberDiff line numberDiff line change
@@ -11,71 +11,32 @@ on:
1111

1212
jobs:
1313
macos-build:
14-
runs-on: macos-latest
14+
runs-on: ${{ matrix.os }}
1515

1616
strategy:
1717
matrix:
1818
include:
19-
- xcode-version: 15.0.0
20-
ios-sim: 'platform=iOS Simulator,name=iPhone 15,OS=17.0.1'
21-
- xcode-version: 14.0.1
22-
ios-sim: 'platform=iOS Simulator,name=iPhone 14,OS=16.0'
19+
- xcode-version: 15.0.1
20+
ios-sim: 'platform=iOS Simulator,name=iPhone 17,OS=17.0'
21+
os: macos-13
22+
- xcode-version: 14.3.1
23+
ios-sim: 'platform=iOS Simulator,name=iPhone 16,OS=16.4'
24+
os: macos-13
2325
- xcode-version: 13.4.1
2426
ios-sim: 'platform=iOS Simulator,name=iPhone 11,OS=15.5'
27+
os: macos-12
2528

2629
steps:
2730
- uses: actions/checkout@v4
2831
with:
2932
fetch-depth: 0 # If you only need the current version keep this.
3033

31-
- uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd
32-
if: ${{ matrix.xcode-version != '15.0.0' }}
34+
- uses: ./.github/actions/ci
3335
with:
3436
xcode-version: ${{ matrix.xcode-version }}
37+
ios-sim: ${{ matrix.ios-sim }}
3538

36-
- name: Build & Test on macOS Simulator
37-
run: xcodebuild test -scheme 'LDSwiftEventSource' -sdk macosx -destination 'platform=macOS' | xcpretty
38-
39-
- name: Build for ARM64 macOS
40-
run: xcodebuild build -scheme 'LDSwiftEventSource' -arch arm64e -sdk macosx | xcpretty
41-
42-
- name: Build Tests for iOS device
43-
run: xcodebuild build-for-testing -scheme 'LDSwiftEventSource' -sdk iphoneos CODE_SIGN_IDENTITY= | xcpretty
44-
45-
- name: Build & Test on iOS Simulator
46-
run: xcodebuild test -scheme 'LDSwiftEventSource' -sdk iphonesimulator -destination '${{ matrix.ios-sim }}' CODE_SIGN_IDENTITY= | xcpretty
47-
48-
- name: Build Tests for tvOS device
49-
run: xcodebuild build-for-testing -scheme 'LDSwiftEventSource' -sdk appletvos CODE_SIGN_IDENTITY= | xcpretty
50-
51-
- name: Build & Test on tvOS Simulator
52-
run: xcodebuild test -scheme 'LDSwiftEventSource' -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' | xcpretty
53-
54-
- name: Build for watchOS simulator # No XCTest testing on watchOS
55-
run: xcodebuild build -scheme 'LDSwiftEventSource' -sdk watchsimulator | xcpretty
56-
57-
- name: Build for watchOS device # No XCTest testing on watchOS
58-
run: xcodebuild build -scheme 'LDSwiftEventSource' -sdk watchos | xcpretty
59-
60-
- name: Build & Test with swiftpm
61-
run: swift test -v 2>&1 | xcpretty
62-
63-
- name: Run contract tests
64-
run: make contract-tests
65-
66-
- name: Install jazzy gem
67-
run: |
68-
gem install jazzy
69-
gem cleanup
70-
71-
- name: Build Documentation
72-
run: jazzy -o artifacts/docs
73-
74-
- name: Validate coverage
75-
run: |
76-
FULLDOC=`jq '.warnings | length == 0' artifacts/docs/undocumented.json`
77-
[ $FULLDOC == "true" ]
78-
39+
- uses: ./.github/actions/build-docs
7940

8041
linux-build:
8142
runs-on: ubuntu-latest

.github/workflows/lint-pr-title.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Lint PR title
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
lint-pr-title:
12+
uses: launchdarkly/gh-actions/.github/workflows/lint-pr-title.yml@main
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
on:
2+
workflow_dispatch:
3+
4+
name: Publish Documentation
5+
jobs:
6+
build-publish:
7+
runs-on: macos-13
8+
9+
permissions:
10+
id-token: write # Needed if using OIDC to get release secrets.
11+
contents: write # Needed in this case to write github pages.
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Build and Test
17+
uses: ./.github/actions/ci
18+
with:
19+
xcode-version: 14.3.1
20+
ios-sim: 'platform=iOS Simulator,name=iPhone 16,OS=16.4'
21+
22+
- uses: ./.github/actions/build-docs
23+
24+
- uses: ./.github/actions/publish-docs
25+
with:
26+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/manual-publish.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish Package
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
dry_run:
6+
description: 'Is this a dry run. If so no package will be published.'
7+
type: boolean
8+
required: true
9+
10+
jobs:
11+
build-publish:
12+
runs-on: macos-13
13+
14+
# Needed to get tokens during publishing.
15+
permissions:
16+
id-token: write
17+
contents: read
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: launchdarkly/gh-actions/actions/[email protected]
23+
name: 'Get Cocoapods token'
24+
with:
25+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
26+
ssm_parameter_pairs: '/production/common/releasing/cocoapods/token = COCOAPODS_TRUNK_TOKEN'
27+
28+
- uses: ./.github/actions/ci
29+
with:
30+
xcode-version: 14.3.1
31+
ios-sim: 'platform=iOS Simulator,name=iPhone 16,OS=16.4'
32+
33+
- uses: ./.github/actions/publish
34+
with:
35+
dry_run: ${{ inputs.dry_run }}

0 commit comments

Comments
 (0)