Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

cross rs

cross rs #14

Workflow file for this run

name: Build and Dockerize
on:
push:
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Extract tag name
id: extract_tag
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang gcc-aarch64-linux-gnu protobuf-compiler libssl-dev
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Install cross
run: cargo install cross
- name: Add Rust targets
run: |
rustup target add x86_64-unknown-linux-gnu
rustup target add x86_64-apple-darwin
rustup target add aarch64-unknown-linux-gnu
rustup target add aarch64-apple-darwin
- name: Build binaries
run: |
cross build --release --target x86_64-unknown-linux-gnu
cross build --release --target aarch64-unknown-linux-gnu
cross build --release --target x86_64-apple-darwin
cross build --release --target aarch64-apple-darwin
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ghcr.io/ark-network/clark:latest,ghcr.io/ark-network/clark:${{ env.TAG }}
platforms: linux/amd64,linux/arm64
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG }}
release_name: Release ${{ env.TAG }}
draft: false
prerelease: false
- name: Upload Release Assets
run: |
for binary in arkd noah; do
for target in x86_64-unknown-linux-gnu x86_64-apple-darwin aarch64-unknown-linux-gnu aarch64-apple-darwin; do
path="./target/$target/release/$binary"
echo "Uploading $path"
curl \
--header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
--header "Content-Type: $(file -b --mime-type $path)" \
--data-binary @$path \
--request POST \
"${{ steps.create_release.outputs.upload_url }}?name=$binary-$target"
done
done
- name: Update Release Description
uses: actions/github-script@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const { owner, repo } = context.repo
const releaseId = ${{ steps.create_release.outputs.id }}
const dockerImage = `ghcr.io/ark-network/clark`
const newBody = `Docker image available at \`${dockerImage}\`. You can pull it using \`docker pull ${dockerImage}\`.`
github.rest.repos.updateRelease({
owner,
repo,
release_id: releaseId,
body: newBody
})