main
yml 155 lines 4.16 KB
Raw
1 name: Release
2
3 on:
4 push:
5 tags:
6 - "v*"
7 workflow_dispatch:
8 inputs:
9 tag:
10 description: "Release tag, for example v1.0.0"
11 required: true
12 type: string
13
14 permissions:
15 contents: write
16
17 concurrency:
18 group: release-${{ github.ref }}
19 cancel-in-progress: false
20
21 jobs:
22 validate:
23 name: Validate release
24 runs-on: macos-15
25
26 outputs:
27 tag: ${{ steps.version.outputs.tag }}
28 version: ${{ steps.version.outputs.version }}
29
30 steps:
31 - name: Checkout
32 uses: actions/checkout@v4
33 with:
34 fetch-depth: 0
35 ref: ${{ github.event.inputs.tag || github.ref }}
36
37 - name: Select Xcode
38 uses: maxim-lobanov/setup-xcode@v1
39 with:
40 xcode-version: latest-stable
41
42 - name: Resolve version
43 id: version
44 run: |
45 if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
46 TAG="${{ github.event.inputs.tag }}"
47 else
48 TAG="${GITHUB_REF_NAME}"
49 fi
50
51 VERSION="${TAG#v}"
52 PODSPEC_VERSION="$(ruby -e "content = File.read('JomloCollectionView.podspec'); puts content[/s\\.version\\s*=\\s*['\\\"]([^'\\\"]+)['\\\"]/, 1]")"
53
54 if [ -z "$VERSION" ] || [ "$VERSION" = "$TAG" ]; then
55 echo "Release tags must use the vMAJOR.MINOR.PATCH format, for example v1.0.0." >&2
56 exit 1
57 fi
58
59 if [ "$VERSION" != "$PODSPEC_VERSION" ]; then
60 echo "Tag version $VERSION does not match podspec version $PODSPEC_VERSION." >&2
61 exit 1
62 fi
63
64 echo "tag=$TAG" >> "$GITHUB_OUTPUT"
65 echo "version=$VERSION" >> "$GITHUB_OUTPUT"
66
67 - name: Show toolchain
68 run: |
69 xcodebuild -version
70 swift --version
71
72 - name: Build package
73 run: |
74 xcodebuild \
75 -scheme JomloCollectionView \
76 -destination "platform=iOS Simulator,name=iPhone 16 Pro" \
77 CODE_SIGNING_ALLOWED=NO \
78 build
79
80 - name: Test package
81 run: |
82 xcodebuild \
83 -scheme JomloCollectionView \
84 -destination "platform=iOS Simulator,name=iPhone 16 Pro" \
85 CODE_SIGNING_ALLOWED=NO \
86 test
87
88 - name: Build iOS example
89 run: |
90 xcodebuild \
91 -project Example/JomloCollectionViewExample.xcodeproj \
92 -scheme "JomloCV Example iOS" \
93 -destination "generic/platform=iOS Simulator" \
94 CODE_SIGNING_ALLOWED=NO \
95 build
96
97 - name: Build tvOS example
98 run: |
99 xcodebuild \
100 -project Example/JomloCollectionViewExample.xcodeproj \
101 -scheme "JomloCV Example tvOS" \
102 -destination "generic/platform=tvOS Simulator" \
103 CODE_SIGNING_ALLOWED=NO \
104 build
105
106 - name: Lint podspec
107 run: |
108 pod lib lint JomloCollectionView.podspec \
109 --allow-warnings \
110 --platforms=ios,tvos \
111 --skip-import-validation
112
113 github-release:
114 name: GitHub release
115 runs-on: ubuntu-latest
116 needs: validate
117
118 steps:
119 - name: Checkout
120 uses: actions/checkout@v4
121 with:
122 ref: ${{ needs.validate.outputs.tag }}
123
124 - name: Create release
125 uses: softprops/action-gh-release@v2
126 with:
127 tag_name: ${{ needs.validate.outputs.tag }}
128 name: JomloCollectionView ${{ needs.validate.outputs.version }}
129 generate_release_notes: true
130
131 cocoapods:
132 name: CocoaPods publish
133 runs-on: macos-15
134 needs:
135 - validate
136 - github-release
137 env:
138 COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
139
140 steps:
141 - name: Checkout
142 uses: actions/checkout@v4
143 with:
144 ref: ${{ needs.validate.outputs.tag }}
145
146 - name: Skip without trunk token
147 if: ${{ env.COCOAPODS_TRUNK_TOKEN == '' }}
148 run: echo "COCOAPODS_TRUNK_TOKEN is not configured; skipping CocoaPods publish."
149
150 - name: Publish pod
151 if: ${{ env.COCOAPODS_TRUNK_TOKEN != '' }}
152 run: |
153 pod trunk push JomloCollectionView.podspec \
154 --allow-warnings \
155 --skip-import-validation