Skip to content

Commit

Permalink
Merge pull request #2 from OS-ricardomoreirasilva/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
OS-ricardomoreirasilva committed Aug 6, 2024
2 parents 3d43fc2 + 845cfaa commit 97388c1
Show file tree
Hide file tree
Showing 53 changed files with 4,274 additions and 8 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Continuous Integration

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

jobs:
sonarcloud:
name: Unit-Tests
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Java 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'

- name: Link SwiftLint or install it
run: brew link --overwrite swiftlint || brew install swiftlint

- name: Set up XCode
run: sudo xcode-select --switch /Applications/Xcode_15.1.app

- name: Bundle Install
run: bundle install

- name: Unit tests
run: bundle exec fastlane unit_tests
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

- name: Code Coverage
run: bundle exec fastlane coverage

- name: Lint
run: bundle exec fastlane lint

- name: Setup sonarqube
uses: warchant/setup-sonar-scanner@v8

- name: Send to Sonarcloud
run: bundle exec fastlane sonarqube
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_KEY }}
81 changes: 81 additions & 0 deletions .github/workflows/prepare_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Prepare Release

on:
workflow_dispatch:
inputs:
versionBumpLevel:
description: 'Version bump level (patch, minor, major)'
required: true
type: choice
default: 'patch'
options:
- patch
- minor
- major

jobs:
build-and-release:
if: github.ref == 'refs/heads/main'
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Link SwiftLint or install it
run: brew link --overwrite swiftlint || brew install swiftlint

- name: Set up XCode
run: sudo xcode-select --switch /Applications/Xcode_15.1.app

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'

- name: Bump version
run: ruby ./scripts/bump_versions.rb ${{ github.event.inputs.versionBumpLevel }}

- name: Build XCFramework
run: ./scripts/build_framework.sh

- name: Get new version
id: version
run: echo "VERSION=$(ruby -e 'puts File.read("./OSInAppBrowserLib.podspec").match(/spec.version.*=.*''(\d+\.\d+\.\d+)''/)[1]')" >> $GITHUB_ENV

- name: Create new branch
run: |
git switch --create "prepare-new-release-${{ env.VERSION }}"
- name: Move zip file to root and push changes
run: |
if [ -f OSInAppBrowserLib.zip ]; then
rm OSInAppBrowserLib.zip
else
echo "File does not exist."
fi
mv build/OSInAppBrowserLib.zip .
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 "chore: Bump version to ${{ env.VERSION }}"
git push origin HEAD:prepare-new-release-${{ env.VERSION }}
- name: Create pull request
id: create_pr
run: |
gh pr create -B main -H prepare-new-release-${{ env.VERSION }} --title 'Prepare `main` to Release `${{ env.VERSION }}`' --body 'Bumps version to `${{ env.VERSION }}`.<br/>Creates an updated and ready-to-be-released `OSInAppBrowserLib.zip`.'
PR_NUMBER=$(gh pr view --json number --jq '.number')
echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Add label to the pull request
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/issues/${{ env.PR_NUMBER }}/labels \
-f "labels[]=release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67 changes: 67 additions & 0 deletions .github/workflows/release_and_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Release and Publish

on:
pull_request:
types: [closed]
branches:
- 'main'

jobs:
post-merge:
if: contains(github.event.pull_request.labels.*.name, 'release')
runs-on: macos-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Cocoapods
run: gem install cocoapods

- name: Get new version
id: version
run: echo "VERSION=$(ruby -e 'puts File.read("./OSInAppBrowserLib.podspec").match(/spec.version.*=.*''(\d+\.\d+\.\d+)''/)[1]')" >> $GITHUB_ENV

- name: Extract release notes
run: sh scripts/extract_release_notes.sh "${{ env.VERSION }}" >> release_notes.md

- name: Create Tag
id: create_tag
run: |
# Define the tag name and message
TAG_NAME="${{ env.VERSION }}"
TAG_MESSAGE="Tag for version ${{ env.VERSION }}"
# Create the tag
git tag -a "$TAG_NAME" -m "$TAG_MESSAGE"
git push origin "$TAG_NAME"
echo "Tag created: $TAG_NAME"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
run: |
# Extract the tag name
TAG_NAME="${{ env.VERSION }}"
RELEASE_NOTES="$(cat release_notes.md)"
# Create the release using GitHub CLI
gh release create "$TAG_NAME" \
--title "$TAG_NAME" \
--notes "$RELEASE_NOTES" \
"OSInAppBrowserLib.zip"
echo "Release created for tag: $TAG_NAME"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy to Cocoapods
run: pod trunk push ./OSInAppBrowserLib.podspec --allow-warnings
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}

- name: Delete Release Branch
run: git push origin --delete prepare-new-release-${{ env.VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
disabled_rules:
- trailing_whitespace
opt_in_rules:
- empty_count
- empty_string
excluded:
- Carthage
- Pods
- vendor
- SwiftLint/Common/3rdPartyLib
line_length:
warning: 150
error: 200
ignores_function_declarations: true
ignores_comments: true
ignores_urls: true
function_body_length:
warning: 300
error: 500
function_parameter_count:
warning: 6
error: 8
type_body_length:
warning: 300
error: 500
file_length:
warning: 1000
error: 1500
ignore_comment_only_lines: true
cyclomatic_complexity:
warning: 15
error: 25
reporter: "xcode"
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Add content to `README` (https://outsystemsrd.atlassian.net/browse/RMET-3473).
### Features
- Add custom error page for `OpenInWebView` feature (https://outsystemsrd.atlassian.net/browse/RMET-3491).
- Add `Close` feature (https://outsystemsrd.atlassian.net/browse/RMET-3427).
- Add `OpenInWebView`'s interface customisations (https://outsystemsrd.atlassian.net/browse/RMET-3489).
- Add `OpenInWebView`'s event listeners (https://outsystemsrd.atlassian.net/browse/RMET-3430).
- Add `OpenInWebView`'s features (https://outsystemsrd.atlassian.net/browse/RMET-3425).
- Add `OpenInSystemBrowser`'s event listeners (https://outsystemsrd.atlassian.net/browse/RMET-3429).
- Add `OpenInSystemBrowser`'s features (https://outsystemsrd.atlassian.net/browse/RMET-3423).
- Add `OpenInExternalBrowser` (https://outsystemsrd.atlassian.net/browse/RMET-3421).

### Chores
- Create `podspec` to enable CocoaPods publish (https://outsystemsrd.atlassian.net/browse/RMET-3578).
- Add content to `README` (https://outsystemsrd.atlassian.net/browse/RMET-3473).
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "https://rubygems.org"

gem "fastlane"
gem "slather"
Loading

0 comments on commit 97388c1

Please sign in to comment.