-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (85 loc) · 2.97 KB
/
anchor.yml
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
name: Publish a release
on:
push:
tags:
- "anchor*"
permissions:
contents: write
env:
LLVM_VERSION: 17
jobs:
release-linux:
name: Release
strategy:
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
suffix: macos-arm64
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
suffix: linux-arm64
- target: x86_64-apple-darwin
os: macos-latest
suffix: macos-amd64
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
suffix: linux-amd64
runs-on: ${{ matrix.os }}
outputs:
version: ${{ steps.extract_version.outputs.version }}
steps:
- name: Extract version from tag
id: extract_version
run: |
echo "version=$(echo ${GITHUB_REF#refs/tags/anchor-})" >> $GITHUB_OUTPUT
- name: Checkout code
uses: actions/checkout@v2
with:
repository: coral-xyz/anchor
ref: ${{ steps.extract_version.outputs.version }}
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install LLVM
if: startsWith(matrix.os, 'ubuntu')
run: |
set -euxo pipefail
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
echo -e deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-${{ env.LLVM_VERSION }} main | sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt update
sudo apt -y install llvm-${{ env.LLVM_VERSION }}-dev
echo /usr/lib/llvm-${{ env.LLVM_VERSION }}/bin >> $GITHUB_PATH
- name: Install LLVM (macOS)
if: matrix.llvm != 'source' && startsWith(matrix.target.os, 'macos')
run: |
set -euxo pipefail
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "/usr/local/bin/brew" >> $GITHUB_PATH
brew install llvm
echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v1
- name: Install target toolchain
run: |
rustup target add ${{ matrix.target }}
- name: Build
env:
CC: clang
RUSTFLAGS: -C linker=clang -C link-arg=-fuse-ld=lld -C link-arg=--target=${{ matrix.target }}
run: |
cargo build --package anchor-cli --release --target ${{ matrix.target }}
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
- name: Copy binary
run: |
cp target/${{ matrix.target }}/release/anchor anchor-${{ matrix.suffix }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
token: ${{ secrets.PAT_TOKEN }}
files: |
light-anchor-${{ matrix.suffix }}