1+ name : Pre-release Build and Publish
2+
3+ on :
4+ push :
5+ tags :
6+ - ' *-pre-release'
7+
8+ jobs :
9+ build-and-release :
10+ runs-on : macos-latest
11+
12+ steps :
13+ - name : Checkout repository
14+ uses : actions/checkout@v4
15+ with :
16+ fetch-depth : 0
17+ token : ${{ secrets.GITHUB_TOKEN }}
18+
19+ - name : Extract version from tag
20+ id : get_version
21+ run : |
22+ TAG_NAME=${GITHUB_REF#refs/tags/}
23+ VERSION=${TAG_NAME%-pre-release}
24+ echo "version=$VERSION" >> $GITHUB_OUTPUT
25+
26+ - name : Build Swift FFI
27+ run : |
28+ chmod +x scripts/build_swift_ffi.sh
29+ ./scripts/build_swift_ffi.sh
30+
31+ - name : Calculate SHA256
32+ id : sha256
33+ run : |
34+ CHECKSUM=$(openssl dgst -sha256 loroFFI.xcframework.zip | awk '{print $2}')
35+ echo "checksum=$CHECKSUM" >> $GITHUB_OUTPUT
36+
37+ - name : Update Package.swift
38+ run : |
39+ VERSION=${{ steps.get_version.outputs.version }}
40+ CHECKSUM=${{ steps.sha256.outputs.checksum }}
41+ sed -i '' \
42+ -e "s|url: \"https://github.com/.*/loroFFI.xcframework.zip\"|url: \"https://github.com/${GITHUB_REPOSITORY}/releases/download/${VERSION}/loroFFI.xcframework.zip\"|" \
43+ -e "s|checksum: \"[a-f0-9]*\"|checksum: \"${CHECKSUM}\"|" \
44+ Package.swift
45+
46+ - name : Update README.md
47+ run : |
48+ VERSION=${{ steps.get_version.outputs.version }}
49+ sed -i '' \
50+ -e "s|\"https://github.com/loro-dev/loro-swift.git\", from: \"[0-9.]*\"|\"https://github.com/loro-dev/loro-swift.git\", from: \"${VERSION}\"|" \
51+ README.md
52+
53+ - name : Commit and push changes
54+ run : |
55+ VERSION=${{ steps.get_version.outputs.version }}
56+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
57+ git config --local user.name "github-actions[bot]"
58+ git add Package.swift README.md
59+ git commit -m "chore: update version to ${VERSION}"
60+ git tag -a "${VERSION}" -m "Release version ${VERSION}"
61+ git push origin HEAD:main
62+ git push origin "${VERSION}"
63+
64+ - name : Create Release
65+ uses : softprops/action-gh-release@v1
66+ with :
67+ tag_name : ${{ steps.get_version.outputs.version }}
68+ name : Release ${{ steps.get_version.outputs.version }}
69+ files : loroFFI.xcframework.zip
70+ draft : false
71+ prerelease : false
72+ env :
73+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
74+
75+ - name : Delete pre-release tag
76+ run : |
77+ VERSION=${{ steps.get_version.outputs.version }}
78+ git push origin :refs/tags/${VERSION}-pre-release
0 commit comments