This repository has been archived by the owner on Aug 8, 2024. It is now read-only.
docker fixes #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Dockerize | |
on: | |
push: | |
tags: | |
- '*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- 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: Extract tag name | |
id: extract_tag | |
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
- 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: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
components: rustfmt, clippy | |
- name: Install Clang | |
run: sudo apt-get install -y clang | |
- name: Install Protobuf Compiler | |
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler libclang-dev && sudo rm -rf /var/lib/apt/lists/* | |
- name: Build binaries | |
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 | |
cargo build --release --target x86_64-unknown-linux-gnu | |
cargo build --release --target x86_64-apple-darwin | |
cargo build --release --target aarch64-unknown-linux-gnu | |
cargo build --release --target aarch64-apple-darwin | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
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 | |
}) |