Skip to content
This repository has been archived by the owner on Dec 14, 2024. It is now read-only.

Commit

Permalink
ci: Automate release process with release please (launchdarkly#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
keelerm84 authored Dec 29, 2023
1 parent 5d2912f commit b5c1e27
Show file tree
Hide file tree
Showing 15 changed files with 347 additions and 53 deletions.
19 changes: 19 additions & 0 deletions .github/actions/build-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build Documentation
description: 'Build Documentation.'

runs:
using: composite
steps:
- name: Install jazzy gem
shell: bash
run: gem install jazzy

- name: Build Documentation
shell: bash
run: jazzy -o docs

- name: Validate coverage
shell: bash
run: |
FULLDOC=`jq '.warnings | length == 0' docs/undocumented.json`
[ $FULLDOC == "true" ]
73 changes: 73 additions & 0 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This is a composite to allow sharing these steps into other workflows.
# For instance it could be used by regular CI as well as the release process.

name: CI Workflow
description: 'Shared CI workflow.'
inputs:
xcode-version:
description: 'Which version of xcode should be installed'
required: true
ios-sim:
description: 'iOS Simulator to use for testing'
required: true

runs:
using: composite
steps:
- uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd
with:
xcode-version: ${{ inputs.xcode-version }}

- name: Install mint
shell: bash
run: |
brew tap mint-lang/mint-lang
brew install mint-lang
- name: Install cocoapods
shell: bash
run: gem install cocoapods

- name: Lint the podspec
shell: bash
run: pod spec lint LDSwiftEventSource.podspec

- name: Build & Test on macOS Simulator
shell: bash
run: xcodebuild test -scheme 'LDSwiftEventSource' -sdk macosx -destination 'platform=macOS' | xcpretty

- name: Build for ARM64 macOS
shell: bash
run: xcodebuild build -scheme 'LDSwiftEventSource' -arch arm64e -sdk macosx | xcpretty

- name: Build Tests for iOS device
shell: bash
run: xcodebuild build-for-testing -scheme 'LDSwiftEventSource' -sdk iphoneos CODE_SIGN_IDENTITY= | xcpretty

- name: Build & Test on iOS Simulator
shell: bash
run: xcodebuild test -scheme 'LDSwiftEventSource' -sdk iphonesimulator -destination '${{ inputs.ios-sim }}' CODE_SIGN_IDENTITY= | xcpretty

- name: Build Tests for tvOS device
shell: bash
run: xcodebuild build-for-testing -scheme 'LDSwiftEventSource' -sdk appletvos CODE_SIGN_IDENTITY= | xcpretty

- name: Build & Test on tvOS Simulator
shell: bash
run: xcodebuild test -scheme 'LDSwiftEventSource' -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' | xcpretty

- name: Build for watchOS simulator # No XCTest testing on watchOS
shell: bash
run: xcodebuild build -scheme 'LDSwiftEventSource' -sdk watchsimulator | xcpretty

- name: Build for watchOS device # No XCTest testing on watchOS
shell: bash
run: xcodebuild build -scheme 'LDSwiftEventSource' -sdk watchos | xcpretty

- name: Build & Test with swiftpm
shell: bash
run: swift test -v 2>&1 | xcpretty

- name: Run contract tests
shell: bash
run: make contract-tests
15 changes: 15 additions & 0 deletions .github/actions/publish-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Publish Documentation
description: 'Publish the documentation to GitHub pages'
inputs:
token:
description: 'Token to use for publishing.'
required: true

runs:
using: composite
steps:
- uses: launchdarkly/gh-actions/actions/[email protected]
name: 'Publish to GitHub pages'
with:
docs_path: docs
github_token: ${{ inputs.token }}
14 changes: 14 additions & 0 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Publish Package
description: 'Publish the package to Cocoapods'
inputs:
dry_run:
description: 'Is this a dry run. If so no package will be published.'
required: true

runs:
using: composite
steps:
- name: Push to cocoapods
if: ${{ inputs.dry_run == 'false' }}
shell: bash
run: pod trunk push LDSwiftEventSource.podspec --allow-warnings --verbose
55 changes: 55 additions & 0 deletions .github/actions/update-versions/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Update xcode project version numbers
description: 'Update xcode project version numbers'
inputs:
branch:
description: 'The branch to checkout and push updates to'
required: true

runs:
using: composite
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: Calculate version numbers
id: version
shell: bash
run: |
version=$(jq -r '."."' .release-please-manifest.json)
major=$(echo "$version" | cut -f1 -d.)
minor=$(echo "$version" | cut -f2 -d.)
patch=$(echo "$version" | cut -f3 -d.)
# 64 + version gives us a letter offset for the framework version.
framework=$(echo $((major + 64)) | awk '{ printf("%c", $1) }')
echo "major=${major}" >> "$GITHUB_OUTPUT"
echo "minor=${minor}" >> "$GITHUB_OUTPUT"
echo "patch=${patch}" >> "$GITHUB_OUTPUT"
echo "framework=${framework}" >> "$GITHUB_OUTPUT"
- name: Update other version numbers
shell: bash
run: |
sed -i .bak -E \
-e 's/MARKETING_VERSION = [^;]+/MARKETING_VERSION = ${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}/' \
-e 's/DYLIB_CURRENT_VERSION = [^;]+/DYLIB_CURRENT_VERSION = ${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}/' \
-e 's/DYLIB_COMPATIBILITY_VERSION = [^;]+/DYLIB_COMPATIBILITY_VERSION = ${{ steps.version.outputs.major }}.0.0/' \
-e 's/FRAMEWORK_VERSION = .*/FRAMEWORK_VERSION = ${{ steps.version.outputs.framework }};/' \
LDSwiftEventSource.xcodeproj/project.pbxproj
sed -i .bak -E \
-e "s/pod 'LDSwiftEventSource', '~> [0-9]+.[0-9]+'/pod 'LDSwiftEventSource', '~> ${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}'/" \
-e "s/github \"LaunchDarkly\/swift-eventsource\" ~> [0-9]+.[0-9]+/github \"LaunchDarkly\/swift-eventsource\" ~> ${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}/" README.md
rm -f LDSwiftEventSource.xcodeproj/project.pbxproj.bak README.md.bak
if [ $(git status --porcelain | wc -l) -gt 0 ]; then
git config --global user.name 'LaunchDarklyReleaseBot'
git config --global user.email '[email protected]'
git add LDSwiftEventSource.xcodeproj/project.pbxproj
git add README.md
git commit -m 'Updating generated project and readme files'
git push
fi
61 changes: 11 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,71 +11,32 @@ on:

jobs:
macos-build:
runs-on: macos-latest
runs-on: ${{ matrix.os }}

strategy:
matrix:
include:
- xcode-version: 15.0.0
ios-sim: 'platform=iOS Simulator,name=iPhone 15,OS=17.0.1'
- xcode-version: 14.0.1
ios-sim: 'platform=iOS Simulator,name=iPhone 14,OS=16.0'
- xcode-version: 15.0.1
ios-sim: 'platform=iOS Simulator,name=iPhone 17,OS=17.0'
os: macos-13
- xcode-version: 14.3.1
ios-sim: 'platform=iOS Simulator,name=iPhone 16,OS=16.4'
os: macos-13
- xcode-version: 13.4.1
ios-sim: 'platform=iOS Simulator,name=iPhone 11,OS=15.5'
os: macos-12

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

- uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd
if: ${{ matrix.xcode-version != '15.0.0' }}
- uses: ./.github/actions/ci
with:
xcode-version: ${{ matrix.xcode-version }}
ios-sim: ${{ matrix.ios-sim }}

- name: Build & Test on macOS Simulator
run: xcodebuild test -scheme 'LDSwiftEventSource' -sdk macosx -destination 'platform=macOS' | xcpretty

- name: Build for ARM64 macOS
run: xcodebuild build -scheme 'LDSwiftEventSource' -arch arm64e -sdk macosx | xcpretty

- name: Build Tests for iOS device
run: xcodebuild build-for-testing -scheme 'LDSwiftEventSource' -sdk iphoneos CODE_SIGN_IDENTITY= | xcpretty

- name: Build & Test on iOS Simulator
run: xcodebuild test -scheme 'LDSwiftEventSource' -sdk iphonesimulator -destination '${{ matrix.ios-sim }}' CODE_SIGN_IDENTITY= | xcpretty

- name: Build Tests for tvOS device
run: xcodebuild build-for-testing -scheme 'LDSwiftEventSource' -sdk appletvos CODE_SIGN_IDENTITY= | xcpretty

- name: Build & Test on tvOS Simulator
run: xcodebuild test -scheme 'LDSwiftEventSource' -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' | xcpretty

- name: Build for watchOS simulator # No XCTest testing on watchOS
run: xcodebuild build -scheme 'LDSwiftEventSource' -sdk watchsimulator | xcpretty

- name: Build for watchOS device # No XCTest testing on watchOS
run: xcodebuild build -scheme 'LDSwiftEventSource' -sdk watchos | xcpretty

- name: Build & Test with swiftpm
run: swift test -v 2>&1 | xcpretty

- name: Run contract tests
run: make contract-tests

- name: Install jazzy gem
run: |
gem install jazzy
gem cleanup
- name: Build Documentation
run: jazzy -o artifacts/docs

- name: Validate coverage
run: |
FULLDOC=`jq '.warnings | length == 0' artifacts/docs/undocumented.json`
[ $FULLDOC == "true" ]
- uses: ./.github/actions/build-docs

linux-build:
runs-on: ubuntu-latest
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Lint PR title

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
lint-pr-title:
uses: launchdarkly/gh-actions/.github/workflows/lint-pr-title.yml@main
26 changes: 26 additions & 0 deletions .github/workflows/manual-publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on:
workflow_dispatch:

name: Publish Documentation
jobs:
build-publish:
runs-on: macos-13

permissions:
id-token: write # Needed if using OIDC to get release secrets.
contents: write # Needed in this case to write github pages.

steps:
- uses: actions/checkout@v4

- name: Build and Test
uses: ./.github/actions/ci
with:
xcode-version: 14.3.1
ios-sim: 'platform=iOS Simulator,name=iPhone 16,OS=16.4'

- uses: ./.github/actions/build-docs

- uses: ./.github/actions/publish-docs
with:
token: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish Package
on:
workflow_dispatch:
inputs:
dry_run:
description: 'Is this a dry run. If so no package will be published.'
type: boolean
required: true

jobs:
build-publish:
runs-on: macos-13

# Needed to get tokens during publishing.
permissions:
id-token: write
contents: read

steps:
- uses: actions/checkout@v4

- uses: launchdarkly/gh-actions/actions/[email protected]
name: 'Get Cocoapods token'
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
ssm_parameter_pairs: '/production/common/releasing/cocoapods/token = COCOAPODS_TRUNK_TOKEN'

- uses: ./.github/actions/ci
with:
xcode-version: 14.3.1
ios-sim: 'platform=iOS Simulator,name=iPhone 16,OS=16.4'

- uses: ./.github/actions/publish
with:
dry_run: ${{ inputs.dry_run }}
Loading

0 comments on commit b5c1e27

Please sign in to comment.