-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (135 loc) · 4.98 KB
/
release-cli.yml
File metadata and controls
154 lines (135 loc) · 4.98 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
name: Release CLI
on:
push:
branches: [main]
paths:
- "apps/cli/**"
- ".github/workflows/release-cli.yml"
- ".github/workflows/update-homebrew-tap.yml"
workflow_dispatch:
jobs:
check-version:
name: Check CLI Version Change
runs-on: ubuntu-latest
outputs:
version-changed: ${{ steps.check.outputs.changed }}
new-version: ${{ steps.check.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check if version changed
id: check
run: |
CURRENT=$(node -p "require('./apps/cli/package.json').version")
echo "version=$CURRENT" >> $GITHUB_OUTPUT
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
exit 0
fi
git checkout HEAD~1 -- apps/cli/package.json 2>/dev/null || true
PREVIOUS=$(node -p "require('./apps/cli/package.json').version" 2>/dev/null || echo "0.0.0")
git checkout HEAD -- apps/cli/package.json
if [ "$CURRENT" != "$PREVIOUS" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
build-cli:
name: Build CLI (${{ matrix.platform }})
needs: check-version
if: needs.check-version.outputs.version-changed == 'true'
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
platform: darwin-arm64
target: bun-darwin-arm64
archive: wrapper-darwin-arm64.tar.gz
helper: wrapper-pty-helper-aarch64-macos-none
- os: macos-latest
platform: darwin-x64
target: bun-darwin-x64
archive: wrapper-darwin-x86_64.tar.gz
helper: wrapper-pty-helper-x86_64-macos-none
- os: ubuntu-latest
platform: linux-x64
target: bun-linux-x64
archive: wrapper-linux-x86_64.tar.gz
helper: wrapper-pty-helper-x86_64-linux-musl
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.2"
- name: Install dependencies
run: bun install --frozen-lockfile --ignore-scripts
- name: Build standalone binary
run: |
mkdir -p dist
bun build --compile --target="${{ matrix.target }}" apps/cli/index.ts --outfile dist/wrapper
- name: Package archive
run: |
mkdir -p staging/bin
cp dist/wrapper staging/bin/wrapper
chmod +x staging/bin/wrapper
cp "apps/cli/bin/${{ matrix.helper }}" "staging/bin/${{ matrix.helper }}"
tar -czf "dist/${{ matrix.archive }}" -C staging .
- name: Upload archive artifact
uses: actions/upload-artifact@v4
with:
name: cli-${{ matrix.platform }}
path: dist/${{ matrix.archive }}
if-no-files-found: error
release:
name: Create GitHub Release
needs: [check-version, build-cli]
if: needs.check-version.outputs.version-changed == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
sha_darwin_arm64: ${{ steps.shas.outputs.sha_darwin_arm64 }}
sha_darwin_x64: ${{ steps.shas.outputs.sha_darwin_x64 }}
sha_linux_x64: ${{ steps.shas.outputs.sha_linux_x64 }}
env:
VERSION: ${{ needs.check-version.outputs.new-version }}
steps:
- uses: actions/checkout@v4
- name: Download archives
uses: actions/download-artifact@v4
with:
pattern: cli-*
path: dist
merge-multiple: true
- name: Compute checksums
id: shas
run: |
echo "sha_darwin_arm64=$(sha256sum dist/wrapper-darwin-arm64.tar.gz | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
echo "sha_darwin_x64=$(sha256sum dist/wrapper-darwin-x86_64.tar.gz | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
echo "sha_linux_x64=$(sha256sum dist/wrapper-linux-x86_64.tar.gz | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
- name: Create or update release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION }}
name: Wrapper v${{ env.VERSION }}
generate_release_notes: true
files: |
dist/wrapper-darwin-arm64.tar.gz
dist/wrapper-darwin-x86_64.tar.gz
dist/wrapper-linux-x86_64.tar.gz
update-homebrew:
name: Update Homebrew Tap
needs: [check-version, release]
if: needs.check-version.outputs.version-changed == 'true'
uses: ./.github/workflows/update-homebrew-tap.yml
with:
version: ${{ needs.check-version.outputs.new-version }}
sha_darwin_arm64: ${{ needs.release.outputs.sha_darwin_arm64 }}
sha_darwin_x64: ${{ needs.release.outputs.sha_darwin_x64 }}
sha_linux_x64: ${{ needs.release.outputs.sha_linux_x64 }}
secrets:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}