Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Whole Project Structure #1

Merged
merged 12 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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: Link SwiftLint or install it
run: brew link --overwrite swiftlint || brew install swiftlint
OS-pedrogustavobilro marked this conversation as resolved.
Show resolved Hide resolved

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

- name: Bundle Install
run: bundle install

- name: Unit tests
run: bundle exec fastlane unit_tests

- name: Code Coverage
run: bundle exec fastlane coverage

- name: Lint
run: bundle exec fastlane lint
81 changes: 81 additions & 0 deletions .github/workflows/prepare_release.yml
OS-ricardomoreirasilva marked this conversation as resolved.
Show resolved Hide resolved
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
OS-pedrogustavobilro marked this conversation as resolved.
Show resolved Hide resolved

- name: Set up XCode
run: sudo xcode-select --switch /Applications/Xcode_15.0.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("./OSGeolocationLib.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 OSGeolocationLib.zip ]; then
rm OSGeolocationLib.zip
else
echo "File does not exist."
fi
mv build/OSGeolocationLib.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 `OSGeolocationLib.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') && github.event.pull_request.merged == true
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("./OSGeolocationLib.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" \
"OSGeolocationLib.zip"

echo "Release created for tag: $TAG_NAME"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy to Cocoapods
run: pod trunk push ./OSGeolocationLib.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 }}
34 changes: 34 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
disabled_rules:
- trailing_whitespace
- switch_case_alignment
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"
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog
OS-ricardomoreirasilva marked this conversation as resolved.
Show resolved Hide resolved
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Features
- Add complete implementation, including `getCurrentPosition`, `watchPosition`, and `clearWatch`.
- Create repository.
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
Loading