-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (113 loc) · 4.24 KB
/
release.yml
File metadata and controls
132 lines (113 loc) · 4.24 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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.runner }}
defaults:
run:
working-directory: apps/tui
strategy:
matrix:
include:
- target: x86_64-apple-darwin
runner: macos-latest
archive: aipm-x86_64-apple-darwin.tar.gz
- target: aarch64-apple-darwin
runner: macos-latest
archive: aipm-aarch64-apple-darwin.tar.gz
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
archive: aipm-x86_64-unknown-linux-gnu.tar.gz
- target: aarch64-unknown-linux-gnu
runner: ubuntu-latest
archive: aipm-aarch64-unknown-linux-gnu.tar.gz
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Validate Google OAuth secrets
env:
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
run: |
test -n "$GOOGLE_CLIENT_ID" || { echo "Missing GOOGLE_CLIENT_ID secret"; exit 1; }
test -n "$GOOGLE_CLIENT_SECRET" || { echo "Missing GOOGLE_CLIENT_SECRET secret"; exit 1; }
- name: Build
env:
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
run: cargo build --release --target ${{ matrix.target }}
- name: Package
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/aipm dist/
cd dist
tar czf ../${{ matrix.archive }} aipm
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.archive }}
path: apps/tui/${{ matrix.archive }}
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: artifacts/*.tar.gz
update-tap:
name: Update Homebrew Tap
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Compute source tarball sha256
id: sha
run: |
curl -sL "https://github.com/ComputelessComputer/aipm/archive/refs/tags/${GITHUB_REF_NAME}.tar.gz" -o source.tar.gz
SHA256=$(sha256sum source.tar.gz | cut -d' ' -f1)
echo "sha256=$SHA256" >> "$GITHUB_OUTPUT"
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Update formula and push to tap
env:
TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
sed -i 's|url ".*"|url "https://github.com/ComputelessComputer/aipm/archive/refs/tags/'"${GITHUB_REF_NAME}"'.tar.gz"|' apps/tui/Formula/aipm.rb
sed -i 's|sha256 ".*"|sha256 "${{ steps.sha.outputs.sha256 }}"|' apps/tui/Formula/aipm.rb
git clone "https://x-access-token:${TAP_TOKEN}@github.com/ComputelessComputer/homebrew-aipm.git" tap || {
mkdir tap && cd tap && git init && git remote add origin "https://x-access-token:${TAP_TOKEN}@github.com/ComputelessComputer/homebrew-aipm.git"
}
mkdir -p tap/Formula
cp apps/tui/Formula/aipm.rb tap/Formula/
cd tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/aipm.rb
git diff --cached --quiet || {
git commit -m "aipm ${{ steps.sha.outputs.version }}"
git branch -M main
git push -u origin main
}