Skip to content

Commit

Permalink
Merge pull request #49 from gumob:develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
gumob authored Aug 28, 2024
2 parents 2f4b948 + 1f253d6 commit b78aa55
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 13 deletions.
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

0 comments on commit b78aa55

Please sign in to comment.