-
Notifications
You must be signed in to change notification settings - Fork 2
178 lines (155 loc) · 5.42 KB
/
release.yml
File metadata and controls
178 lines (155 loc) · 5.42 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
178
name: Release
on:
push:
tags:
- 'v[0-9]+.*'
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
# ── Build binaries for each platform ──────────────────────────────
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
- target: aarch64-apple-darwin
os: macos-latest
archive: tar.gz
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.94"
targets: ${{ matrix.target }}
- name: Install cross-compilation tools (Linux ARM)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build release binaries
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
run: cargo build --release --target ${{ matrix.target }} -p astrid
- name: Package binaries
run: |
VERSION="${GITHUB_REF_NAME#v}"
DIR="astrid-${VERSION}-${{ matrix.target }}"
mkdir "$DIR"
cp "target/${{ matrix.target }}/release/astrid" "$DIR/"
cp "target/${{ matrix.target }}/release/astrid-daemon" "$DIR/"
cp "target/${{ matrix.target }}/release/astrid-build" "$DIR/"
cp LICENSE* README.md "$DIR/" 2>/dev/null || true
tar czf "${DIR}.tar.gz" "$DIR"
echo "ASSET=${DIR}.tar.gz" >> "$GITHUB_ENV"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.target }}
path: ${{ env.ASSET }}
# ── Create the GitHub release with all binaries ───────────────────
github-release:
name: GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all binary artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: binary-*
merge-multiple: true
- name: Extract changelog for this version
id: changelog
run: |
VERSION="${GITHUB_REF_NAME#v}"
BODY=$(awk "/^## \\[$VERSION\\]/{found=1; next} /^## \\[/{if(found) exit} found" CHANGELOG.md)
if [ -z "$BODY" ]; then
BODY="See [CHANGELOG.md](https://github.com/unicity-astrid/astrid/blob/${GITHUB_REF_NAME}/CHANGELOG.md) for details."
fi
{
echo "body<<EOF"
echo "$BODY"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Compile Astrinauts for this release
id: contributors
env:
GH_TOKEN: ${{ github.token }}
run: |
PREV_TAG=$(git tag --sort=-v:refname | sed -n '2p')
if [ -z "$PREV_TAG" ]; then
AUTHORS=$(git log --format='%aN' | sort -u)
else
AUTHORS=$(git log --format='%aN' "$PREV_TAG"..HEAD | sort -u)
fi
ASTRINAUTS=""
while IFS= read -r name; do
[ -z "$name" ] && continue
EMAIL=$(git log --format='%aE' --author="$name" -1)
USERNAME=$(gh api "search/users?q=$EMAIL+in:email" --jq '.items[0].login // empty' 2>/dev/null || true)
if [ -n "$USERNAME" ]; then
ASTRINAUTS="${ASTRINAUTS}\n- @${USERNAME}"
else
ASTRINAUTS="${ASTRINAUTS}\n- ${name}"
fi
done <<< "$AUTHORS"
{
echo "list<<EOF"
echo -e "$ASTRINAUTS"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Generate checksums
run: |
cd artifacts
sha256sum *.tar.gz > SHA256SUMS.txt
cat SHA256SUMS.txt
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/*.tar.gz
artifacts/SHA256SUMS.txt
body: |
${{ steps.changelog.outputs.body }}
## Install
**From source (requires Rust 1.94+):**
```
cargo install astrid
```
**Pre-built binaries:**
Download the archive for your platform, extract, and add to PATH:
```
tar xzf astrid-*-$(uname -m)-*.tar.gz
sudo mv astrid-*/astrid astrid-*/astrid-daemon astrid-*/astrid-build /usr/local/bin/
```
Then run `astrid init` to set up capsules.
---
**With many thanks from the following Astrinauts** 🚀
${{ steps.contributors.outputs.list }}
- name: Notify Homebrew tap
env:
GH_TOKEN: ${{ secrets.TAP_DISPATCH_TOKEN }}
run: |
gh api repos/unicity-astrid/homebrew-tap/dispatches \
-f event_type=release \
-f "client_payload[version]=${GITHUB_REF_NAME#v}"