Skip to content

anchor: Add action for building Anchor binaries #4

anchor: Add action for building Anchor binaries

anchor: Add action for building Anchor binaries #4

Workflow file for this run

name: Publish a release
on:
push:
tags:
- "anchor*"
permissions:
contents: write
env:
CROSS_VERSION: 0.2.5
jobs:
release-linux:
name: Release (Linux)
strategy:
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
cross-rs: false
suffix: macos-arm64
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
cross-rs: true
suffix: linux-arm64
- target: x86_64-apple-darwin
os: macos-latest
cross-rs: false
suffix: macos-amd64
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
cross-rs: true
suffix: linux-amd64
runs-on: ubuntu-latest
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
- uses: Swatinem/rust-cache@v1
- name: Install cross
if: matrix.cross-rs == true
uses: supplypike/setup-bin@v3
with:
uri: "https://github.com/cross-rs/cross/releases/download/v${{ env.CROSS_VERSION }}/cross-x86_64-unknown-linux-musl.tar.gz"
name: "cross"
version: "${{ env.CROSS_VERSION }}"
- name: Install target toolchain
if: matrix.cross-rs == false
run: |
rustup target add ${{ matrix.target }}
- name: Build
if: matrix.cross-rs == true
run: |
cross build --release --target ${{ matrix.target }}
- name: Build
if: matrix.cross-rs == false
run: |
cargo build --release --target ${{ matrix.target }}
- 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 }}