Skip to content

Merge pull request #20 from gevulotnetwork/mia/update-deps #18

Merge pull request #20 from gevulotnetwork/mia/update-deps

Merge pull request #20 from gevulotnetwork/mia/update-deps #18

Workflow file for this run

name: Create MIA binary release
# MIA releases are created for tags like `mia-0.1.0`
on:
workflow_dispatch:
push:
tags:
- "mia-[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: write
# Since we only support x86_64-unknown-linux-gnu for MIA,
# it's fine to hard-code it here now.
env:
TARGET_PLATFORM: x86_64-unknown-linux-gnu
jobs:
x86_64-release:
name: x86_64 release
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout source code
uses: actions/checkout@v4
# Get release version
- name: Get MIA release version from tag name
run: |
VERSION=$(echo "${{ github.ref_name }}" \
| grep -E "^mia-[0-9]+.[0-9]+.[0-9]+$" \
| grep --color=never -Eo "[0-9]+.[0-9]+.[0-9]+$")
if [[ -z $VERSION ]]; then
echo "Ref is not a MIA release tag."
echo "To create MIA release, use tag names like 'mia-0.1.0'."
exit 1;
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Install jq
run: sudo apt-get install -y jq
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ env.TARGET_PLATFORM }}
- name: Get MIA crate version
run: |
cd mia
CARGO_VERSION=$(cargo metadata \
--format-version=1 \
--no-deps \
| jq \
--raw-output \
'.packages[] | select(.name == "mia") | .version')
echo "CARGO_VERSION=$CARGO_VERSION" >> $GITHUB_ENV
- name: Check tag name is aligned with Cargo.toml version
run: |
if [[ "$CARGO_VERSION" != "$VERSION" ]]; then
echo "Tag name is not aligned with MIA crate version."
echo "Please ensure that Cargo.toml version is updated."
exit 1;
fi
- name: Print release version
run: echo $VERSION
# Install binary dependencies
- name: Install buf
uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Protoc
uses: arduino/setup-protoc@v3
# Build sources
- name: Build MIA
run: |
cd mia
cargo build --release --target $TARGET_PLATFORM
# Package MIA
- name: Archive artifacts
id: artifacts
run: |
ARCHIVE_NAME="mia-$VERSION-$TARGET_PLATFORM.tar.gz"
mkdir release
cp ./mia/target/$TARGET_PLATFORM/release/mia ./release/
tar -C ./release -cz -f $ARCHIVE_NAME .
echo "mia=$ARCHIVE_NAME" >> $GITHUB_OUTPUT
- name: Calculate SHA256 checksum
id: checksums
run: |
CHECKSUM_NAME=${{ steps.artifacts.outputs.mia }}.sha256
sha256sum ${{ steps.artifacts.outputs.mia }} | cut -d " " -f 1 > $CHECKSUM_NAME
echo "mia_checksum=$CHECKSUM_NAME" >> $GITHUB_OUTPUT
# Create GitHub release
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: gh release create ${{ github.ref_name }} --title "mia-$VERSION"
- name: Upload release assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
gh release upload ${{ github.ref_name }} \
${{ steps.artifacts.outputs.mia }} \
${{ steps.checksums.outputs.mia_checksum }}