-
Notifications
You must be signed in to change notification settings - Fork 9
162 lines (135 loc) · 4.89 KB
/
release.yml
File metadata and controls
162 lines (135 loc) · 4.89 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
name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
RUSTC_WRAPPER: sccache
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-14
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Linux linker
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y clang lld
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.5
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Install Zig
run: ./scripts/bootstrap-zig.sh
- name: Build
env:
ZIG: ${{ github.workspace }}/.context/zig/zig
run: cargo build -p cas --release --target ${{ matrix.target }}
- name: Package (Unix)
run: |
mkdir -p package
cp target/${{ matrix.target }}/release/cas package/
cp LICENSE package/
cd package
tar -czvf cas-${{ matrix.target }}.tar.gz cas LICENSE
mv cas-${{ matrix.target }}.tar.gz ../
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: cas-${{ matrix.target }}
path: cas-${{ matrix.target }}.tar.gz
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release
find artifacts -name "*.tar.gz" -exec mv {} release/ \;
ls -la release/
- name: Generate release notes
id: notes
run: |
# Get the previous tag
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -n "$PREV_TAG" ]; then
NOTES=$(git log --pretty=format:"- %s" $PREV_TAG..HEAD)
else
NOTES=$(git log --pretty=format:"- %s" -10)
fi
echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION="${GITHUB_REF#refs/tags/}"
# Delete existing release if it exists (handles retags)
gh release delete "$VERSION" --repo ${{ github.repository }} --yes 2>/dev/null || true
# Create the release
gh release create "$VERSION" \
--repo ${{ github.repository }} \
--title "CAS $VERSION" \
--notes "${{ steps.notes.outputs.notes }}" \
release/*
update-homebrew:
name: Update Homebrew Formula
needs: release
runs-on: ubuntu-latest
# Requires HOMEBREW_TAP_TOKEN secret: a PAT with push access to codingagentsystem/homebrew-cas
steps:
- uses: actions/checkout@v4
- name: Update Homebrew formula
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
if [ -z "${GH_TOKEN}" ]; then
echo "HOMEBREW_TAP_TOKEN not set, skipping homebrew update"
exit 0
fi
VERSION="${GITHUB_REF#refs/tags/v}"
# Download and compute SHA256 for each platform
MACOS_SHA=$(curl -fsSL "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/cas-aarch64-apple-darwin.tar.gz" | shasum -a 256 | cut -d' ' -f1)
LINUX_SHA=$(curl -fsSL "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/cas-x86_64-unknown-linux-gnu.tar.gz" | shasum -a 256 | cut -d' ' -f1)
# Clone homebrew-cas tap
git clone https://x-access-token:${GH_TOKEN}@github.com/codingagentsystem/homebrew-cas.git /tmp/homebrew-cas
cd /tmp/homebrew-cas
# Update version and SHA256 hashes in formula
sed -i "s/version \"[^\"]*\"/version \"${VERSION}\"/" Formula/cas.rb
sed -i "0,/sha256 \"[a-f0-9]\{64\}\"/s/sha256 \"[a-f0-9]\{64\}\"/sha256 \"${MACOS_SHA}\"/" Formula/cas.rb
sed -i "/sha256 \"${MACOS_SHA}\"/!s/sha256 \"[a-f0-9]\{64\}\"/sha256 \"${LINUX_SHA}\"/" Formula/cas.rb
# Commit and push
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/cas.rb
git commit -m "Update CAS to ${VERSION}"
git push