-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (154 loc) · 5.67 KB
/
Copy pathrelease.yml
File metadata and controls
174 lines (154 loc) · 5.67 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
name: Release
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
build:
name: Build (${{ matrix.target }})
strategy:
matrix:
include:
- os: ubuntu-22.04
target: x86_64-linux
- os: macos-latest
target: aarch64-macos
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
submodules: recursive
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: brew install cmake
- name: Set up Rust toolchain
if: runner.os == 'macOS'
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Build task binary (macOS)
if: runner.os == 'macOS'
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --target task_executable
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update -q
sudo apt-get install -y cmake clang libclang-dev
- name: Set up Rust musl target
if: runner.os == 'Linux'
run: rustup target add x86_64-unknown-linux-musl
- name: Set up Zig
if: runner.os == 'Linux'
uses: mlugg/setup-zig@v1
with:
version: "0.14.0"
- name: Create musl-cc/musl-cxx wrappers
if: runner.os == 'Linux'
run: |
sudo tee /usr/local/bin/musl-cc > /dev/null << 'WRAPPER'
#!/bin/bash
args=()
skip_next=0
for arg in "$@"; do
[ "$skip_next" = "1" ] && { skip_next=0; continue; }
[ "$arg" = "-target" ] && { skip_next=1; continue; }
[[ "$arg" == --target=* ]] && continue
args+=("$arg")
done
exec zig cc -target x86_64-linux-musl "${args[@]}"
WRAPPER
sudo tee /usr/local/bin/musl-cxx > /dev/null << 'WRAPPER'
#!/bin/bash
args=()
skip_next=0
for arg in "$@"; do
[ "$skip_next" = "1" ] && { skip_next=0; continue; }
[ "$arg" = "-target" ] && { skip_next=1; continue; }
[[ "$arg" == --target=* ]] && continue
args+=("$arg")
done
exec zig c++ -target x86_64-linux-musl "${args[@]}"
WRAPPER
sudo chmod +x /usr/local/bin/musl-cc /usr/local/bin/musl-cxx
- name: Build task binary (Linux — musl)
if: runner.os == 'Linux'
run: |
set -e
printf '%s\n' \
'set(CMAKE_SYSTEM_NAME Linux)' \
'set(CMAKE_SYSTEM_PROCESSOR x86_64)' \
'set(CMAKE_C_COMPILER /usr/local/bin/musl-cc)' \
'set(CMAKE_CXX_COMPILER /usr/local/bin/musl-cxx)' \
'set(CMAKE_C_COMPILER_WORKS TRUE)' \
'set(CMAKE_CXX_COMPILER_WORKS TRUE)' \
'set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "")' \
'set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "")' \
'set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)' \
'set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)' \
'set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)' \
> /tmp/musl-toolchain.cmake
_lib=$(dpkg -L libclang-dev 2>/dev/null | grep 'libclang.*\.so$' | head -1)
export LIBCLANG_PATH=${_lib:+$(dirname "$_lib")}
export LIBCLANG_PATH=${LIBCLANG_PATH:-/usr/lib/llvm-14/lib}
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/tmp/musl-toolchain.cmake \
-DTASK_BUILTIN_UUID=ON \
-DRust_CARGO_TARGET=x86_64-unknown-linux-musl
cmake --build build --target task_executable -j$(nproc)
- name: Package binary + completions
run: |
VERSION=$(echo "${GITHUB_REF_NAME#v}" | tr '/' '-')
mkdir -p pkg/completions
cp build/src/task pkg/
cp scripts/bash/task.sh pkg/completions/
cp scripts/zsh/_task pkg/completions/
cp scripts/fish/task.fish pkg/completions/
TARBALL="task-${VERSION}-${{ matrix.target }}.tar.gz"
tar czf "$TARBALL" -C pkg .
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.target }}
path: task-*.tar.gz
release:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/task-*.tar.gz
generate_release_notes: true
- name: Update GuionAI/homebrew-tap formula
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
REPO: ${{ github.repository }}
run: |
echo "::add-mask::${HOMEBREW_TAP_TOKEN}"
VERSION=${GITHUB_REF_NAME#v}
export VERSION REPO
export SHA_LINUX=$(sha256sum artifacts/task-${VERSION}-x86_64-linux.tar.gz | cut -d' ' -f1)
export SHA_MACOS=$(sha256sum artifacts/task-${VERSION}-aarch64-macos.tar.gz | cut -d' ' -f1)
git clone https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/GuionAI/homebrew-tap.git tap
python3 .github/scripts/update-tap-formula.py
cd tap
git config user.name "guion-bot"
git config user.email "bot@guion.io"
git add Formula/task.rb
git commit -m "task ${VERSION}"
git push