1- name : Deploy Swift Package
1+ name : Release Swift Package
22
33on :
4- release :
5- types : [published]
64 workflow_dispatch :
5+ inputs :
6+ version :
7+ description : " Version to release (e.g., 1.2.3 or major/minor/patch)"
8+ required : true
9+ type : string
10+
11+ permissions :
12+ contents : write
713
814jobs :
9- deploy :
15+ release :
1016 runs-on : macos-latest
11-
17+
1218 steps :
13- - uses : actions/checkout@v3
14-
15- - name : Select Xcode
16- run : |
17- sudo xcode-select -s /Applications/Xcode.app
18-
19- - name : Build Package
20- run : swift build
21-
22- - name : Run Tests
23- run : swift test
24-
25- - name : Create git tag if not exists
26- if : github.event_name == 'workflow_dispatch'
27- run : |
28- VERSION=$(cat VERSION)
29- git config user.name hyodotdev
30- git config user.email hyo@hyo.dev
31-
32- # Check if tag exists on remote
33- if git ls-remote --tags origin | grep -q "refs/tags/$VERSION"; then
34- echo "Tag $VERSION already exists on remote, skipping..."
35- else
36- # Create tag locally if not exists
37- if ! git rev-parse "refs/tags/$VERSION" >/dev/null 2>&1; then
38- git tag $VERSION
19+ - uses : actions/checkout@v4
20+
21+ - name : Select Xcode
22+ run : sudo xcode-select -s /Applications/Xcode.app
23+
24+ - name : Determine version
25+ id : set_version
26+ shell : bash
27+ run : |
28+ VERSION="${{ github.event.inputs.version }}"
29+ # Trim possible leading 'v'
30+ VERSION="${VERSION#v}"
31+ echo "VERSION=$VERSION" >> $GITHUB_ENV
32+ echo "Release version: $VERSION"
33+
34+ - name : Configure Git
35+ run : |
36+ git config user.name "hyodotdev"
37+ git config user.email "hyo@hyo.dev"
38+
39+ - name : Bump version and tag
40+ run : |
41+ ./scripts/bump-version.sh "${{ env.VERSION }}"
42+ # Refresh VERSION to the computed value (handles major/minor/patch)
43+ NEW_VERSION=$(cat VERSION)
44+ echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV
45+ echo "Computed version: $NEW_VERSION"
46+
47+ - name : Build Package
48+ run : swift build
49+
50+ - name : Run Tests
51+ run : swift test
52+
53+ - name : Verify Package
54+ run : |
55+ swift package show-dependencies
56+ swift package describe
57+
58+ - name : Create GitHub Release
59+ uses : softprops/action-gh-release@v1
60+ with :
61+ tag_name : ${{ env.VERSION }}
62+ name : ${{ env.VERSION }}
63+ draft : false
64+ prerelease : false
65+ generate_release_notes : true
66+ env :
67+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
68+
69+ - name : Setup Ruby
70+ uses : ruby/setup-ruby@v1
71+ with :
72+ ruby-version : ' 3.0'
73+ bundler-cache : true
74+
75+ - name : Install CocoaPods
76+ run : |
77+ gem list -i cocoapods || gem install cocoapods --no-document
78+
79+ - name : Validate Podspec
80+ env :
81+ COCOAPODS_VALIDATOR_SKIP_XCODEBUILD : 1
82+ run : |
83+ pod lib lint openiap.podspec --allow-warnings
84+
85+ - name : Publish to CocoaPods Trunk
86+ env :
87+ COCOAPODS_TRUNK_TOKEN : ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
88+ COCOAPODS_VALIDATOR_SKIP_XCODEBUILD : 1
89+ run : |
90+ if [ -z "$COCOAPODS_TRUNK_TOKEN" ]; then
91+ echo "COCOAPODS_TRUNK_TOKEN is not set. Skipping CocoaPods publish.";
92+ exit 0;
3993 fi
40- # Push tag
41- git push origin $VERSION
42- fi
43-
44- - name : Verify Package
45- run : |
46- swift package show-dependencies
47- swift package describe
94+ pod trunk push openiap.podspec --allow-warnings
0 commit comments