-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (162 loc) · 6.08 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Release
on:
workflow_dispatch:
inputs:
bump_type:
description: "Version bump type"
required: true
type: choice
options:
- patch
- minor
- major
jobs:
update-cargo-version:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.version.outputs.new_version }}
steps:
- uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GIT_HUB_TOKEN }}
- name: Calculate new version
id: version
run: |
# Get current version from Cargo.toml
CURRENT_VERSION=$(grep -m 1 'version = ' walletkit-core/Cargo.toml | cut -d '"' -f 2)
# Split version into components
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
# Calculate new version based on bump type
case "${{ github.event.inputs.bump_type }}" in
"major")
NEW_VERSION="$((MAJOR + 1)).0.0"
;;
"minor")
NEW_VERSION="${MAJOR}.$((MINOR + 1)).0"
;;
"patch")
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
;;
esac
echo "New version will be: $NEW_VERSION"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Set up Rust
run: |
rustup update stable && rustup default stable
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache Cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-index-
- name: Cache Cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Install cargo-edit
run: cargo install cargo-edit
- name: Update version
run: cargo set-version --package walletkit-core ${{ steps.version.outputs.new_version }}
# Commit uses GIT_HUB_TOKEN which has permissions to push (set on actions/checkout)
- name: Commit and Push Changes
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add walletkit-core/Cargo.toml
git commit -m "Bump crate version to ${{ steps.version.outputs.new_version }}"
git push
build-swift:
runs-on: macos-latest
needs: update-cargo-version
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Rust
run: |
rustup update stable && rustup default stable
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache Cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-index-
- name: Cache Cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Install dependencies
run: |
cargo fetch
- name: Build the project (iOS)
run: ./build_swift.sh
- name: Checkout swift repo
uses: actions/checkout@v4
with:
repository: worldcoin/walletkit-swift
token: ${{ secrets.GIT_HUB_TOKEN }}
path: target-repo
- name: Commit swift build
env:
GITHUB_TOKEN: ${{ secrets.GIT_HUB_TOKEN }}
run: |
cp -r WalletKitCore.xcframework target-repo/
cp -r Sources/ target-repo/
# Update version number in Package.swift
sed -i '' "s/\/\/ Current version is: [0-9]\+\.[0-9]\+\.[0-9]\+/\/\/ Current version is: ${{ github.event.release.tag_name }}/" Package.swift
cp Package.swift target-repo/
cd target-repo
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add .
git commit -m "Release ${{ needs.update-cargo-version.outputs.new_version }}"
# Tag the release
git tag ${{ needs.update-cargo-version.outputs.new_version }}
git push
git push origin ${{ needs.update-cargo-version.outputs.new_version }}
create-github-release:
needs: [update-cargo-version, build-swift]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Create Release in main repo
uses: softprops/action-gh-release@v2
with:
name: ${{ needs.update-cargo-version.outputs.new_version }}
tag_name: ${{ needs.update-cargo-version.outputs.new_version }}
generate_release_notes: true
make_latest: true
- name: Create Release in swift repo
uses: softprops/action-gh-release@v2
with:
repository: worldcoin/walletkit-swift
token: ${{ secrets.GIT_HUB_TOKEN }}
name: ${{ needs.update-cargo-version.outputs.new_version }}
tag_name: ${{ needs.update-cargo-version.outputs.new_version }}
body: |
## Version ${{ needs.update-cargo-version.outputs.new_version }}
For full release notes, see the [main repo release](https://github.com/worldcoin/walletkit/releases/tag/${{ needs.update-cargo-version.outputs.new_version }}).
make_latest: true