-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from gumob:develop
Develop
- Loading branch information
Showing
2 changed files
with
109 additions
and
13 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
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,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 |