-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (123 loc) · 4.63 KB
/
release.yml
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: Build and Release Yttrium
on:
push:
branches:
- 'xcframework'
env:
CARGO_TERM_COLOR: always
VERSION: ${{ github.event.inputs.version || '0.0.3' }}
TARGET_BRANCH: ${{ github.ref_name }}
permissions:
contents: write # Grant write access to repository contents for this workflow
jobs:
release-swift-package:
runs-on: macos-14
strategy:
matrix:
config:
- debug
steps:
# 1. Checkout the Repository with full history
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history so that we can create and push tags
# 2. Setup ccache (Optional: Improve build speeds)
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
# 3. Setup pnpm (JavaScript Package Manager)
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
# 4. Setup Rust Environment and Dependencies
- name: Setup Rust Environment and Dependencies
env:
VERSION: ${{ env.VERSION }}
run: |
rustup update stable && rustup default stable
git submodule update --init --recursive
make setup-thirdparty
# 5. Select Specific Xcode Version
- name: Select Xcode 15.4
run: |
sudo xcode-select -s /Applications/Xcode_15.4.app
# 6. Build and Package Rust XCFramework
- name: Build and Package Rust XCFramework
run: |
make build-ios-bindings-release
make zip-rust-xcframework
make compute-rust-checksum
make generate-package-swift
# 7. (Optional) Debug Environment Variables
- name: Debug Environment Variables
run: |
echo "VERSION: $VERSION"
echo "TARGET_BRANCH: $TARGET_BRANCH"
# 8. (Optional) Check Git Status
- name: Check Git Status
run: git status
# 9. (Optional) List Changes in Package.swift
- name: List Changes in Package.swift
run: git diff Package.swift
# 10. Compute Checksum and Update Package.swift
- name: Compute Checksum and Update Package.swift
id: compute_checksum
run: |
# Compute checksum
CHECKSUM=$(swift package compute-checksum ./Output/RustXcframework.xcframework.zip)
echo "Computed checksum: $CHECKSUM"
# Update Package.swift with the new checksum
# Assuming the binary target is named "RustXcframework"
sed -i '' "s/checksum: \".*\"/checksum: \"$CHECKSUM\"/" Package.swift
echo "Updated Package.swift with new checksum."
# 11. Commit and Push Package.swift
- name: Commit and Push Package.swift
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use default token
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Package.swift
if git diff --cached --quiet; then
echo "No changes to commit."
else
git commit -m "chore: update Package.swift for version $VERSION"
git push origin HEAD:$TARGET_BRANCH
fi
# 12. Create Git Tag
- name: Create Git Tag
env:
VERSION: ${{ env.VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Ensure we're on the latest commit
git fetch origin $TARGET_BRANCH
# Get the latest commit hash
COMMIT_HASH=$(git rev-parse HEAD)
echo "Tagging commit ${COMMIT_HASH} with version ${VERSION}"
# Create an annotated tag on the latest commit
git tag -a "${VERSION}" -m "Release version ${VERSION}" "${COMMIT_HASH}"
# Push the tag to the repository
git push origin "${VERSION}"
# 13. Create a GitHub Release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: Yttrium ${{ env.VERSION }}
draft: false
prerelease: true
# 14. Upload Rust XCFramework to the Release
- name: Upload Rust XCFramework to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Output/RustXcframework.xcframework.zip
asset_name: RustXcframework.xcframework.zip
asset_content_type: application/zip