Skip to content

Commit 3b9d19b

Browse files
committed
Build arm and x86 binaries.
1 parent 3598cae commit 3b9d19b

4 files changed

Lines changed: 113 additions & 16 deletions

File tree

Cargo.lock

Lines changed: 64 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ authors = ["Nick Dower <nicholasdower@gmail.com>"]
1010
clap = { version = "4.0", features = ["derive"] }
1111
home = "0.5"
1212
git2 = "0.18"
13+
openssl = { version = "0.10", features = ["vendored"] }

script/homebrew.sh

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,44 @@ set -e
44
set -u
55
set -o pipefail
66

7-
if [ $# -ne 2 ]; then
8-
echo "usage: $0 <version> <file>" >&2
7+
if [ $# -ne 1 ]; then
8+
echo "usage: $0 <version>" >&2
99
exit 1
1010
fi
1111

1212
version="$1"
13-
file="$2"
1413

15-
url="https://github.com/nicholasdower/git-coauthor/releases/download/v$version/$file"
16-
sha=`shasum -a 256 "$file" | cut -d' ' -f1`
14+
x86_64_file="release-x86_64.tar.gz"
15+
arm_64_file="release-arm_64.tar.gz"
16+
17+
if [ ! -f "$x86_64_file" ]; then
18+
echo "error: $x86_64_file not found" >&2
19+
exit 1
20+
fi
21+
22+
if [ ! -f "$arm_64_file" ]; then
23+
echo "error: $arm_64_file not found" >&2
24+
exit 1
25+
fi
26+
27+
x86_64_url="https://github.com/nicholasdower/git-coauthor/releases/download/v$version/$x86_64_file"
28+
x86_64_sha=`shasum -a 256 "$x86_64_file" | cut -d' ' -f1`
29+
30+
arm_64_url="https://github.com/nicholasdower/git-coauthor/releases/download/v$version/$arm_64_file"
31+
arm_64_sha=`shasum -a 256 "$arm_64_file" | cut -d' ' -f1`
32+
1733
cat << EOF > Formula/git-coauthor.rb
1834
class GitCoauthor < Formula
1935
desc "List or add Git coauthors"
2036
homepage "https://github.com/nicholasdower/git-coauthor"
21-
url "$url"
22-
sha256 "$sha"
2337
license "MIT"
38+
if Hardware::CPU.arm?
39+
url "$arm_64_url"
40+
sha256 "$arm_64_sha"
41+
elsif Hardware::CPU.intel?
42+
url "$x86_64_url"
43+
sha256 "$x86_64_sha"
44+
end
2445
2546
def install
2647
bin.install "bin/git-coauthor"

script/release.sh

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,38 @@ sed -i '' "s/^version = .*/version = \"$version\"/g" Cargo.toml
1717
echo "Build"
1818
rm -rf target
1919
cargo build --release
20+
cargo build --release --target x86_64-apple-darwin
21+
cargo build --release --target aarch64-apple-darwin
2022

2123
echo "Lint"
2224
cargo clippy -- -Dwarnings
2325

2426
echo "Test"
2527
RUNNER_TEMP=/tmp ./script/test.sh
2628

29+
echo "Create man page"
30+
./script/manpage.sh "$version" "$(date '+%Y-%m-%d')"
31+
32+
x86_64_file="release-x86_64.tar.gz"
33+
arm_64_file="release-arm_64.tar.gz"
34+
35+
echo "Create $x86_64_file"
2736
rm -rf bin
2837
mkdir -p bin
29-
cp ./target/release/git-coauthor bin/
38+
cp target/x86_64-apple-darwin/release/git-coauthor bin/git-coauthor
39+
rm -f "$x86_file"
40+
tar -czf "$x86_file" ./man/ ./bin/
3041

31-
echo "Create man page"
32-
./script/manpage.sh "$version" "$(date '+%Y-%m-%d')"
3342

34-
echo "Create release.tar.gz"
35-
file="release.tar.gz"
36-
rm -f "$file"
37-
tar -czf "$file" ./man/ ./bin/
43+
echo "Create $arm_64_file"
44+
rm -rf bin
45+
mkdir -p bin
46+
cp target/aarch64-apple-darwin/release/git-coauthor bin/git-coauthor
47+
rm -f "$arm_64_file"
48+
tar -czf "$arm_64_file" ./man/ ./bin/
3849

3950
echo "Create Homebrew formula"
40-
./script/homebrew.sh "$version" "$file"
51+
./script/homebrew.sh "$version"
4152

4253
echo "Update CHANGELOG.md"
4354
./script/changelog.sh "$version"
@@ -64,7 +75,7 @@ git push origin master
6475
git push origin "v$version"
6576

6677
echo "Create release"
67-
gh release create "v$version" "$file" -R nicholasdower/git-coauthor --notes-file tmp/.release-notes
78+
gh release create "v$version" "$x86_64_file" "$arm_64_file" -R nicholasdower/git-coauthor --notes-file tmp/.release-notes
6879

6980
echo "Trigger Homebrew update"
7081
gh workflow run update.yml --ref master -R nicholasdower/homebrew-tap

0 commit comments

Comments
 (0)