-
Notifications
You must be signed in to change notification settings - Fork 19
72 lines (63 loc) · 2.88 KB
/
Copy pathrelease-tag.yml
File metadata and controls
72 lines (63 loc) · 2.88 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
name: Release Tagging
on:
pull_request:
types: [closed]
branches:
- master
- development
jobs:
create-tag:
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/')
runs-on: macos-latest
outputs:
version: ${{ steps.extract-version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Git identity
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Extract version from branch name
id: extract-version
run: |
BRANCH_NAME="${{ github.head_ref }}"
VERSION=${BRANCH_NAME#release/}
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- name: Verify Version.swift contains correct version
run: |
VERSION_IN_FILE=$(grep -o 'private static let kVersion = "[^"]*"' Split/Common/Utils/Version.swift | cut -d'"' -f2)
if [ "$VERSION_IN_FILE" != "${{ steps.extract-version.outputs.version }}" ]; then
echo "❌ Error: Version in Version.swift ($VERSION_IN_FILE) does not match branch version (${{ steps.extract-version.outputs.version }})"
exit 1
fi
echo "✅ Version.swift contains correct version: $VERSION_IN_FILE"
- name: Verify Split.podspec contains correct version
run: |
PODSPEC_VERSION=$(grep -o "s.version = '[^']*'" Split.podspec | cut -d"'" -f2)
if [ "$PODSPEC_VERSION" != "${{ steps.extract-version.outputs.version }}" ]; then
echo "❌ Error: Version in Split.podspec ($PODSPEC_VERSION) does not match branch version (${{ steps.extract-version.outputs.version }})"
exit 1
fi
echo "✅ Split.podspec contains correct version: $PODSPEC_VERSION"
- name: Create tag
run: |
echo "🏷️ Creating tag ${{ steps.extract-version.outputs.version }}..."
git tag -a "${{ steps.extract-version.outputs.version }}" -m "Release ${{ steps.extract-version.outputs.version }}"
git push origin "${{ steps.extract-version.outputs.version }}"
- name: Verify tag in remote
run: |
echo "✅ Verifying tag ${{ steps.extract-version.outputs.version }} exists in remote..."
sleep 5
git fetch --tags
if git ls-remote --tags origin | grep -q "refs/tags/${{ steps.extract-version.outputs.version }}$"; then
echo "✅ Tag ${{ steps.extract-version.outputs.version }} successfully created in remote"
else
echo "❌ Failed to verify tag ${{ steps.extract-version.outputs.version }} in remote"
exit 1
fi