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

Develop #49

Merged
merged 17 commits into from
Aug 28, 2024
Merged
26 changes: 13 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -426,24 +426,24 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Enable error handling and exit the script on pipe failures
### Enable error handling and exit the script on pipe failures
set -eo pipefail
# Retrieve build settings and execute a command to filter MARKETING_VERSION
### Retrieve build settings and execute a command to filter MARKETING_VERSION
current_version=$(grep -m1 'MARKETING_VERSION' "${{ env.project_name }}.xcodeproj/project.pbxproj" | sed 's/.*= //;s/;//')
echo "Current version: $current_version"
# If the current version is found
### If the current version is found
if [[ $current_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# Check if a tag for the current version already exists
### If the tag exists, delete it from both local and remote
if git tag -l | grep -q "$current_version"; then
# If the tag exists, delete it from both local and remote
git fetch --tags
git tag -d "$current_version"
git push origin ":refs/tags/$current_version"
fi
# Create a new tag for the current version and push it to the remote repository
### Create a new tag for the current version and push it to the remote repository
git tag "$current_version"
git push origin "$current_version"
else
# If the version could not be retrieved, display an error message
### If the version could not be retrieved, display an error message
echo "Error: Could not retrieve the version."
fi
needs: lint_cocoapods
Expand All @@ -458,23 +458,23 @@ jobs:
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
# Enable error handling and exit the script on pipe failures
### Enable error handling and exit the script on pipe failures
set -eo pipefail
# Retrieve the current version from the project file
### Retrieve the current version from the project file
current_version=$(grep -m1 'MARKETING_VERSION' "${{ env.project_name }}.xcodeproj/project.pbxproj" | sed 's/.*= //;s/;//')
echo "Current version: $current_version"
# Check if the current version is a valid semantic version
### Check if the current version is a valid semantic version
if [[ ! "$current_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Invalid version number"
exit 1
fi
# Check if the current version already exists in the CocoaPods trunk
### Check if the current version already exists in the CocoaPods trunk
if pod trunk info ${podspec_name} | grep -q "$current_version"; then
echo "Start deleting $current_version"
# Delete the existing version from the CocoaPods trunk
### Delete the existing version from the CocoaPods trunk
echo "y" | pod trunk delete ${podspec_name} $current_version || true
fi
echo "Start pushing $current_version"
# Push the new version to the CocoaPods trunk
### Push the new version to the CocoaPods trunk
pod trunk push ${podspec_name}.podspec --allow-warnings
needs: update_tag
96 changes: 96 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift

name: test

on:
push:
branches:
- release/**
paths:
- .github/workflows/**
- .swiftlint.yml
- Cartfile
- Package.swift
- TLDExtractSwift.podspec
- TLDExtractSwift.xcodeproj/**
- Sources/**
- Tests/**

env:
project_name: TLDExtractSwift
podspec_name: TLDExtractSwift

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
update_tag:
runs-on: macOS-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Extract version and add tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
### Enable error handling and exit the script on pipe failures
set -eo pipefail
### Retrieve build settings and execute a command to filter MARKETING_VERSION
current_version=$(grep -m1 'MARKETING_VERSION' "${{ env.project_name }}.xcodeproj/project.pbxproj" | sed 's/.*= //;s/;//')
echo "Current version: $current_version"
### If the current version is found
if [[ $current_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
git fetch --tags
### Check if a tag for the current version already exists
tag_exists1=$(git tag -l "${current_version}")
echo "tag_exists1: ${tag_exists1}"
tag_exists2=$(git tag -l | grep "${current_version}")
echo "tag_exists2: ${tag_exists2}"
if git tag -l | grep -q "$current_version"; then
### If the tag exists, delete it from both local and remote
echo "delete tag $current_version"
# git tag -d "$current_version"
# git push origin ":refs/tags/$current_version"
fi
### Create a new tag for the current version and push it to the remote repository
echo "create tag $current_version"
# git tag "$current_version"
# git push origin "$current_version"
else
### If the version could not be retrieved, display an error message
echo "Error: Could not retrieve the version."
fi

push_cocoapods:
runs-on: macOS-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Publish to cocoapods
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
### Enable error handling and exit the script on pipe failures
set -eo pipefail
### Retrieve the current version from the project file
current_version=$(grep -m1 'MARKETING_VERSION' "${{ env.project_name }}.xcodeproj/project.pbxproj" | sed 's/.*= //;s/;//')
echo "Current version: $current_version"
### Check if the current version is a valid semantic version
if [[ ! "$current_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Invalid version number"
exit 1
fi
### Check if the current version already exists in the CocoaPods trunk
if pod trunk info ${podspec_name} | grep -q "$current_version"; then
echo "Start deleting $current_version"
### Delete the existing version from the CocoaPods trunk
# echo "y" | pod trunk delete ${podspec_name} $current_version || true
fi
echo "Start pushing $current_version"
### Push the new version to the CocoaPods trunk
# pod trunk push ${podspec_name}.podspec --allow-warnings
needs: update_tag