-
Notifications
You must be signed in to change notification settings - Fork 7
155 lines (135 loc) · 5.12 KB
/
Copy pathrelease.yaml
File metadata and controls
155 lines (135 loc) · 5.12 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
build-macos:
strategy:
matrix:
include:
- arch: arm64
runner: macos-latest
- arch: x86_64
runner: macos-15-intel
runs-on: ${{ matrix.runner }}
# Backstop against a hung build (e.g. a stalled Zig compile on the Intel
# runner) so the job fails fast and frees the runner instead of sitting
# until the 6-hour Actions limit. A normal job finishes in well under 10m.
timeout-minutes: 30
env:
ZIG_GLOBAL_CACHE_DIR: ${{ github.workspace }}/architect/.zig-cache
ZIG_LOCAL_CACHE_DIR: ${{ github.workspace }}/architect/.zig-cache/local
# Prevent ghostty (dependency) from reading the repository git tag of Architect
# and thinking it is its own release tag.
GIT_CEILING_DIRECTORIES: ${{ github.workspace }}/architect/.zig-cache
steps:
- uses: actions/checkout@v7
with:
path: architect
- name: Install Nix
uses: cachix/install-nix-action@v31.11.1
with:
extra_nix_config: |
experimental-features = nix-command flakes
- name: Cache Zig package cache
uses: actions/cache@v6
with:
path: architect/.zig-cache
key: zig-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('architect/build.zig.zon') }}
restore-keys: |
zig-${{ runner.os }}-${{ matrix.arch }}-
- name: Cache Nix store
uses: cachix/cachix-action@v17
with:
name: forketyfork
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Prefetch Zig dependencies
timeout-minutes: 10
run: |
for i in 1 2 3; do
nix develop --command just setup && break
if [ $i -eq 3 ]; then exit 1; fi
sleep 5
done
working-directory: architect
- name: Build release
timeout-minutes: 20
run: |
for i in 1 2 3; do
nix develop --command zig build -Doptimize=ReleaseFast && break
if [ $i -eq 3 ]; then exit 1; fi
sleep 5
done
working-directory: architect
- name: Bundle libraries and package
run: |
chmod +x scripts/bundle-macos.sh
./scripts/bundle-macos.sh zig-out/bin/architect release zig-out/bin/architect-mcp
cd release
tar -czf architect-macos-${{ matrix.arch }}.tar.gz Architect.app
working-directory: architect
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: architect-macos-${{ matrix.arch }}
path: architect/release/architect-macos-${{ matrix.arch }}.tar.gz
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v3
with:
files: architect/release/architect-macos-${{ matrix.arch }}.tar.gz
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-formula:
needs: build-macos
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
ref: main
token: ${{ secrets.PAT_TOKEN }}
- name: Update Homebrew formula
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "Updating formula for version $VERSION"
# Download and compute SHA256 for the source tarball
TARBALL_URL="https://github.com/${{ github.repository }}/archive/refs/tags/${VERSION}.tar.gz"
SHA256=$(curl -sL "$TARBALL_URL" | sha256sum | awk '{print $1}')
echo "Computed SHA256: $SHA256"
# Update the formula file
sed -i "s|url \"https://github.com/${{ github.repository }}/archive/refs/tags/v[^\"]*\.tar\.gz\"|url \"$TARBALL_URL\"|" Formula/architect.rb
sed -i "0,/sha256 \"[^\"]*\"/s//sha256 \"$SHA256\"/" Formula/architect.rb
# Check if there were changes
if git diff --quiet Formula/architect.rb; then
echo "No changes to formula"
exit 0
fi
# Create a PR with the changes
BRANCH_NAME="update-formula-${VERSION}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "$BRANCH_NAME"
git add Formula/architect.rb
git commit -m "Update Homebrew formula to ${VERSION}"
git push origin "$BRANCH_NAME"
# Create PR
gh pr create \
--title "Update Homebrew formula to ${VERSION}" \
--body "Automatically updates the Homebrew formula to version ${VERSION} with the correct SHA256 checksum.
**Changes:**
- Update version to ${VERSION}
- Update SHA256 to \`${SHA256}\`
This PR was automatically generated by the release workflow." \
--base main \
--head "$BRANCH_NAME"