-
Notifications
You must be signed in to change notification settings - Fork 1.2k
177 lines (142 loc) · 5.56 KB
/
cli-release.yml
File metadata and controls
177 lines (142 loc) · 5.56 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
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
name: CLI Release
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: write
id-token: write
jobs:
build:
strategy:
matrix:
include:
- os: macos-latest
target: bun-darwin-arm64
artifact: inbox-zero-darwin-arm64
- os: macos-latest
target: bun-darwin-x64
artifact: inbox-zero-darwin-x64
- os: ubuntu-latest
target: bun-linux-x64
artifact: inbox-zero-linux-x64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: cd packages/cli && bun install
- name: Build binary
run: |
cd packages/cli
bun build src/main.ts --compile --target=${{ matrix.target }} --outfile dist/${{ matrix.artifact }}
- name: Create tarball (Unix)
run: |
cd packages/cli/dist
tar -czvf ${{ matrix.artifact }}.tar.gz ${{ matrix.artifact }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: packages/cli/dist/${{ matrix.artifact }}.tar.gz
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- uses: actions/setup-node@v4
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Upgrade npm
run: npm install -g npm@latest
- name: Set version from tag
if: github.ref_type == 'tag'
run: |
VERSION="${GITHUB_REF_NAME#v}"
cd packages/cli
npm version "$VERSION" --no-git-tag-version
- name: Install dependencies
run: cd packages/cli && bun install
- name: Build
run: cd packages/cli && bun run build
- name: Publish to npm
run: cd packages/cli && npm publish --provenance --access public || echo "Version may already be published"
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Get version
id: version
run: |
if [ "${GITHUB_REF_TYPE}" != "tag" ]; then
echo "This workflow must be run from a tag ref (got: ${GITHUB_REF_TYPE} '${GITHUB_REF_NAME}')" >&2
exit 1
fi
VERSION="${GITHUB_REF_NAME#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$GITHUB_REF_NAME" >> $GITHUB_OUTPUT
- name: Calculate SHA256
id: sha
run: |
echo "darwin_arm64=$(sha256sum artifacts/inbox-zero-darwin-arm64/inbox-zero-darwin-arm64.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
echo "darwin_x64=$(sha256sum artifacts/inbox-zero-darwin-x64/inbox-zero-darwin-x64.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
echo "linux_x64=$(sha256sum artifacts/inbox-zero-linux-x64/inbox-zero-linux-x64.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
- name: Upload to Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
files: |
artifacts/inbox-zero-darwin-arm64/inbox-zero-darwin-arm64.tar.gz
artifacts/inbox-zero-darwin-x64/inbox-zero-darwin-x64.tar.gz
artifacts/inbox-zero-linux-x64/inbox-zero-linux-x64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update Homebrew formula
run: |
python3 << 'EOF'
import re
with open('Formula/inbox-zero.rb', 'r') as f:
content = f.read()
# Update version
content = re.sub(r'version "[^"]*"', 'version "${{ steps.version.outputs.version }}"', content)
# Update URLs to current version (handles both cli-v* and v* formats)
content = re.sub(r'releases/download/(?:cli-)?v[^/]+/', 'releases/download/${{ steps.version.outputs.tag }}/', content)
# Update SHA256 for darwin-arm64 (first sha256 after "on_arm do")
content = re.sub(
r'(on_arm do.*?sha256 ")[^"]*(")',
r'\g<1>${{ steps.sha.outputs.darwin_arm64 }}\2',
content, count=1, flags=re.DOTALL
)
# Update SHA256 for darwin-x64 (first sha256 after "on_intel do" inside on_macos)
content = re.sub(
r'(on_macos do.*?on_intel do.*?sha256 ")[^"]*(")',
r'\g<1>${{ steps.sha.outputs.darwin_x64 }}\2',
content, count=1, flags=re.DOTALL
)
# Update SHA256 for linux-x64 (sha256 after "on_linux do")
content = re.sub(
r'(on_linux do.*?sha256 ")[^"]*(")',
r'\g<1>${{ steps.sha.outputs.linux_x64 }}\2',
content, count=1, flags=re.DOTALL
)
with open('Formula/inbox-zero.rb', 'w') as f:
f.write(content)
print(content)
EOF
- name: Commit formula update
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add Formula/inbox-zero.rb
git diff --staged --quiet || git commit -m "chore: update Homebrew formula for ${{ steps.version.outputs.tag }}"
git push origin HEAD:main