Skip to content

Commit 65d455e

Browse files
committed
ci(release): add workflow for automated releases
- Build universal binaries for macOS (arm64, x86_64) - Generate checksums and create GitHub releases - Update Homebrew tap with new release formula
1 parent 06d137f commit 65d455e

1 file changed

Lines changed: 106 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
release:
11+
runs-on: macos-15
12+
permissions:
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Swift
18+
uses: SwiftyLab/setup-swift@latest
19+
with:
20+
swift-version: "6.2"
21+
22+
- name: Create release directory
23+
run: mkdir -p release
24+
25+
- name: Build arm64
26+
run: |
27+
swift build -c release --arch arm64 --disable-sandbox
28+
cp .build/arm64-apple-macosx/release/asc release/asc_${GITHUB_REF_NAME}_macOS_arm64
29+
30+
- name: Build x86_64
31+
run: |
32+
swift build -c release --arch x86_64 --disable-sandbox
33+
cp .build/x86_64-apple-macosx/release/asc release/asc_${GITHUB_REF_NAME}_macOS_x86_64
34+
35+
- name: Create universal binary
36+
run: |
37+
lipo -create -output release/asc_${GITHUB_REF_NAME}_macOS_universal \
38+
release/asc_${GITHUB_REF_NAME}_macOS_arm64 \
39+
release/asc_${GITHUB_REF_NAME}_macOS_x86_64
40+
41+
- name: Create checksums
42+
run: |
43+
cd release
44+
shasum -a 256 * > asc_${GITHUB_REF_NAME}_checksums.txt
45+
46+
- name: Create GitHub Release
47+
uses: softprops/action-gh-release@v2
48+
with:
49+
files: release/**
50+
generate_release_notes: true
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Update Homebrew tap
55+
env:
56+
TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
57+
VERSION: ${{ github.ref_name }}
58+
run: |
59+
if [ -z "$TAP_GITHUB_TOKEN" ]; then
60+
echo "TAP_GITHUB_TOKEN not set, skipping"
61+
exit 0
62+
fi
63+
64+
export SHA256=$(shasum -a 256 release/asc_${VERSION}_macOS_universal | cut -d ' ' -f 1)
65+
66+
git clone https://x-access-token:${TAP_GITHUB_TOKEN}@github.com/tddworks/homebrew-tap.git homebrew-tap || {
67+
echo "Clone failed. Skipping."
68+
exit 0
69+
}
70+
cd homebrew-tap
71+
mkdir -p Formula
72+
73+
# Use Python to write the formula — avoids heredoc indentation issues in YAML
74+
python3 - << 'PYEOF'
75+
import os
76+
v = os.environ['VERSION']
77+
s = os.environ['SHA256']
78+
formula = (
79+
"# typed: false\n"
80+
"# frozen_string_literal: true\n\n"
81+
"class Asc < Formula\n"
82+
f' desc "App Store Connect CLI — manage apps, versions, and screenshots from your terminal"\n'
83+
f' homepage "https://github.com/tddworks/asc-cli"\n'
84+
f' url "https://github.com/tddworks/asc-cli/releases/download/{v}/asc_{v}_macOS_universal"\n'
85+
f' version "{v}"\n'
86+
f' sha256 "{s}"\n'
87+
' license "MIT"\n\n'
88+
' depends_on :macos\n\n'
89+
' def install\n'
90+
f' bin.install "asc_{v}_macOS_universal" => "asc"\n'
91+
' end\n\n'
92+
' test do\n'
93+
' assert_match version.to_s, shell_output("#{bin}/asc --version")\n'
94+
' end\n'
95+
'end\n'
96+
)
97+
with open('Formula/asc.rb', 'w') as f:
98+
f.write(formula)
99+
print('Formula/asc.rb written')
100+
PYEOF
101+
102+
git config user.name "itshan"
103+
git config user.email "itshan@tddworks.com"
104+
git add Formula/asc.rb
105+
git commit -m "Update asc to ${VERSION}" || echo "No changes to commit"
106+
git push || echo "Push failed. Skipping."

0 commit comments

Comments
 (0)