-
Notifications
You must be signed in to change notification settings - Fork 1
138 lines (126 loc) · 4.7 KB
/
Copy pathrelease.yml
File metadata and controls
138 lines (126 loc) · 4.7 KB
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
name: Release
on:
push:
tags:
- 'v*'
jobs:
# 1. Build prebuilt binaries for each target and attach to the GitHub release.
build:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- run: cargo build --release --target ${{ matrix.target }}
- name: Package
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/cc-session dist/cc-session-${{ matrix.target }}
tar -czf dist/cc-session-${{ matrix.target }}.tar.gz -C dist cc-session-${{ matrix.target }}
(cd dist && shasum -a 256 cc-session-${{ matrix.target }}.tar.gz > cc-session-${{ matrix.target }}.tar.gz.sha256)
- uses: softprops/action-gh-release@v2
with:
files: |
dist/cc-session-${{ matrix.target }}.tar.gz
dist/cc-session-${{ matrix.target }}.tar.gz.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 2. Publish the crate to crates.io.
cargo-publish:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --no-verify --allow-dirty
# 3. Update Homebrew formula in this repo (it doubles as the tap).
homebrew:
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Resolve tag
id: tag
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Fetch SHA256s from release
id: sha
env:
VERSION: ${{ steps.tag.outputs.version }}
run: |
base="https://github.com/dudegladiator/claude-code-session-editor/releases/download/v${VERSION}"
for t in aarch64-apple-darwin x86_64-apple-darwin x86_64-unknown-linux-gnu; do
sha=$(curl -fsSL "$base/cc-session-${t}.tar.gz.sha256" | awk '{print $1}')
echo "${t}=${sha}" >> "$GITHUB_OUTPUT"
done
- name: Write formula
env:
VERSION: ${{ steps.tag.outputs.version }}
SHA_ARM: ${{ steps.sha.outputs.aarch64-apple-darwin }}
SHA_INTEL: ${{ steps.sha.outputs.x86_64-apple-darwin }}
SHA_LINUX: ${{ steps.sha.outputs.x86_64-unknown-linux-gnu }}
run: |
mkdir -p Formula
cat > Formula/cc-session.rb <<EOF
class CcSession < Formula
desc "Interactive TUI editor for Claude Code session JSONL files"
homepage "https://github.com/dudegladiator/claude-code-session-editor"
version "${VERSION}"
license "MIT"
on_macos do
on_arm do
url "https://github.com/dudegladiator/claude-code-session-editor/releases/download/v#{version}/cc-session-aarch64-apple-darwin.tar.gz"
sha256 "${SHA_ARM}"
end
on_intel do
url "https://github.com/dudegladiator/claude-code-session-editor/releases/download/v#{version}/cc-session-x86_64-apple-darwin.tar.gz"
sha256 "${SHA_INTEL}"
end
end
on_linux do
url "https://github.com/dudegladiator/claude-code-session-editor/releases/download/v#{version}/cc-session-x86_64-unknown-linux-gnu.tar.gz"
sha256 "${SHA_LINUX}"
end
def install
bin.install Dir["cc-session-*"].first => "cc-session"
end
test do
assert_match version.to_s, shell_output("#{bin}/cc-session --version")
end
end
EOF
- name: Commit + push formula
env:
VERSION: ${{ steps.tag.outputs.version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Formula/cc-session.rb
if git diff --cached --quiet; then
echo "no formula changes"
exit 0
fi
git commit -m "chore: update Homebrew formula for v${VERSION}"
git push origin HEAD:main