-
Notifications
You must be signed in to change notification settings - Fork 6
145 lines (130 loc) · 4.67 KB
/
release.yml
File metadata and controls
145 lines (130 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Release
on:
pull_request:
types: [closed]
branches:
- 'main'
env:
PROJECT_NAME: OSInAppBrowserLib
XCODE_VERSION: 16.4
CHANGELOG_PATH: CHANGELOG.md
LICENSE_PATH: LICENSE
PODSPEC_FILE: OSInAppBrowserLib.podspec
jobs:
tag_and_release:
name: Release and Publish
runs-on: macos-15
if: >-
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'release')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
with:
tools: gh
gems: cocoapods
- name: Get current project version
id: get_version
uses: ./.github/actions/get-project-version
with:
project_name: ${{ env.PROJECT_NAME }}
- name: Get release notes for this version
id: release_notes
env:
VERSION: ${{ steps.get_version.outputs.version }}
CHANGELOG_PATH: ${{ env.CHANGELOG_PATH }}
run: |
set -euo pipefail
if [ ! -f "$CHANGELOG_PATH" ]; then
echo "❌ Changelog file not found: $CHANGELOG_PATH"
exit 1
fi
echo "📜 Extracting release notes for version $VERSION..."
release_notes_section=$(awk "/^## \[${VERSION}\]/ {flag=1; next} flag && /^## \\[/ {exit} flag {print}" "$CHANGELOG_PATH" | sed '/^\s*$/d')
if [ -n "$release_notes_section" ]; then
echo "$release_notes_section"
echo 'release_notes<<EOF' >> $GITHUB_OUTPUT
echo "$release_notes_section" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
else
echo "⚠️ No release notes found for version $VERSION."
exit 0
fi
- name: Set Xcode version
uses: ./.github/actions/set-xcode-version
with:
xcode-version: ${{ env.XCODE_VERSION }}
- name: Build XCFramework
id: build_xcframework
uses: ./.github/actions/build-xcframework
with:
project_name: ${{ env.PROJECT_NAME }}
- name: Package XCFramework
uses: ./.github/actions/package-xcframework
id: package
with:
package_name: ${{ env.PROJECT_NAME }}
xcframework_path: ${{ steps.build_xcframework.outputs.xcframework_path }}
license_path: ${{ env.LICENSE_PATH }}
- name: Create tag
id: create_tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.get_version.outputs.version }}
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag v$VERSION -m "Release version $VERSION"
git push origin v$VERSION
echo "Tag v$VERSION created."
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TITLE: ${{ steps.create_tag.outputs.tag }}
RELEASE_NOTES: ${{ steps.release_notes.outputs.release_notes }}
ASSET_PATH: ${{ steps.package.outputs.zip_name }}
run: |
set -euo pipefail
gh release create $TITLE \
--title "$TITLE" \
--notes "$RELEASE_NOTES" \
"$ASSET_PATH"
- name: Publish Pod
if: hashFiles('${{ env.PODSPEC_FILE }}') != ''
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
set -euo pipefail
if [ -z "${COCOAPODS_TRUNK_TOKEN:-}" ]; then
echo "❌ COCOAPODS_TRUNK_TOKEN secret is not set. Please set it in your repository secrets."
exit 1
fi
echo "🚀 Deploying podspec to CocoaPods..."
pod trunk push "$PODSPEC_FILE" --allow-warnings
- name: Delete source branch
if: github.event.pull_request.head.ref != 'main'
run: |
set +e
git push origin --delete ${{ github.event.pull_request.head.ref }}
set -e
delete_branch_if_pr_closed_without_merge:
name: Delete Source Branch If PR Closed Without Merge
runs-on: macos-15
if: >-
github.event.pull_request.merged == false &&
github.event.pull_request.head.ref != 'main' &&
contains(github.event.pull_request.labels.*.name, 'release')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Delete source branch
run: |
set +e
git push origin --delete ${{ github.event.pull_request.head.ref }}
set -e