-
Notifications
You must be signed in to change notification settings - Fork 706
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure GitHub Actions for Release Cycle (#485)
* Create release.yml * Remove `environment`, update cocoapods secrets name
- Loading branch information
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version to release' | ||
required: true | ||
|
||
jobs: | ||
release: | ||
runs-on: macos-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.0' | ||
|
||
- name: Install CocoaPods | ||
run: gem install cocoapods | ||
|
||
- name: Update version in podspec | ||
run: sed -i '' 's/s.version = "[^"]*"/s.version = "${{ github.event.inputs.version }}"/' KSCrash.podspec | ||
|
||
- name: Update version in source code | ||
run: | | ||
formatted_version_number=$(echo "${{ github.event.inputs.version }}" | awk -F. '{printf("%d.%02d%02d\n", $1, $2, $3)}') | ||
sed -i '' 's/const double KSCrashFrameworkVersionNumber = [^;]*/const double KSCrashFrameworkVersionNumber = '"$formatted_version_number"'/' Sources/KSCrashRecording/KSCrash.m | ||
sed -i '' 's/const unsigned char KSCrashFrameworkVersionString\[\] = "[^"]*"/const unsigned char KSCrashFrameworkVersionString[] = "${{ github.event.inputs.version }}"/' Sources/KSCrashRecording/KSCrash.m | ||
- name: Commit version update | ||
id: commit_version | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git add . | ||
git commit -m "Update version to ${{ github.event.inputs.version }}" | ||
git push | ||
- name: Create git tag | ||
id: create_tag | ||
run: | | ||
git tag ${{ github.event.inputs.version }} | ||
git push origin ${{ github.event.inputs.version }} | ||
- name: Publish to CocoaPods | ||
env: | ||
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_PASSWORD }} | ||
run: pod trunk push KSCrash.podspec --verbose | ||
|
||
rollback: | ||
runs-on: macos-latest | ||
needs: release | ||
if: failure() | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Delete git tag locally | ||
run: git tag -d ${{ github.event.inputs.version }} | ||
|
||
- name: Delete git tag remotely | ||
run: git push --delete origin ${{ github.event.inputs.version }} | ||
|
||
- name: Revert version commit | ||
run: | | ||
git revert --no-commit HEAD | ||
git commit -m "Revert version update due to failed release" | ||
git push |