Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mpw/bin release #8

Merged
merged 27 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Build and release binary
on:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
REPOSITORY: ${{ github.event.repository.name }}
BINARY_NAME: hub

jobs:
build:
runs-on: '${{ matrix.os }}'
strategy:
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
suffix: ''
- os: macos-latest-xlarge
target: aarch64-apple-darwin
suffix: ''
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: ''
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: .exe
steps:
- uses: actions/checkout@master
with:
lfs: true
- id: get_version
run: echo ::set-output "name=VERSION::$(IFS=\=;cat Cargo.toml | grep version | head -n1 | awk {'print $3'})"
shell: bash

- name: Install dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update -y && \
sudo apt-get install -y --no-install-recommends \
cmake \
clang \
liburing-dev \
g++ \
libsasl2-dev \
libssl-dev \
libudev-dev \
pkg-config

- name: Install dependencies
if: startsWith(matrix.os, 'macOS')
run: |
brew install cmake gcc [email protected] pkg-config protobuf

- name: Install dependencies windows
if: startsWith(matrix.os, 'windows')
run: |
choco install cmake openssl protoc


- name: Get protoc from github releases
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo ./ci/get-protoc.sh

- uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: '${{ runner.os }}-${{ matrix.target }}-cargo-registry-${{ hashFiles(''**/Cargo.lock'') }}'
- uses: actions/cache@v1
with:
path: ~/.cargo/git
key: '${{ runner.os }}-${{ matrix.target }}-cargo-index-${{ hashFiles(''**/Cargo.lock'') }}'
- uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
env:
VERSION: '${{ steps.get_version.outputs.VERSION }}'
with:
command: build
args: '--release'

- name: Rename binary
run: |
cp ./target/release/${{ env.BINARY_NAME }}${{matrix.suffix}} ./target/release/${{ env.REPOSITORY }}${{ matrix.suffix }}

- uses: actions/upload-artifact@v2
with:
name: ${{ env.REPOSITORY }}-${{ matrix.target }}
path: ./target/release/${{ env.REPOSITORY }}${{ matrix.suffix }}
if-no-files-found: error

release:
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
lfs: true
- uses: actions/download-artifact@v3

- name: Move binaries
run: |
mv ${{ env.REPOSITORY }}-x86_64-apple-darwin/${{ env.REPOSITORY }} hub-x86_64-apple-darwin
mv ${{ env.REPOSITORY }}-x86_64-unknown-linux-gnu/${{ env.REPOSITORY }} hub-x86_64-unknown-linux-gnu
mv ${{ env.REPOSITORY }}-x86_64-pc-windows-msvc/${{ env.REPOSITORY }}.exe hub-x86_64-pc-windows.exe
mv ${{ env.REPOSITORY }}-aarch64-apple-darwin/${{ env.REPOSITORY }} hub-aarch64-apple-darwin

- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
with:
generate_release_notes: true
draft: true
fail_on_unmatched_files: true
files: |
hub-x86_64-apple-darwin
hub-x86_64-unknown-linux-gnu
hub-x86_64-pc-windows.exe
hub-aarch64-apple-darwin
27 changes: 27 additions & 0 deletions ci/get-protoc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -eux
ARCHITECTURE=$(uname -m)

if [[ $ARCHITECTURE == "x86_64" ]]; then
ARCHITECTURE="x86_64"
elif [[ $ARCHITECTURE == *'aarch'* ]]; then
ARCHITECTURE="aarch_64"
elif [[ $ARCHITECTURE == *'arm'* ]]; then
ARCHITECTURE="aarch_64"
else
echo "Unsupported architecture"
exit 1
fi

OS_TYPE=$(uname | tr '[:upper:]' '[:lower:]')

PROTOC_VERSION="23.2"

URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${OS_TYPE}-${ARCHITECTURE}.zip"

wget -q "$URL" -O protoc.zip

unzip protoc.zip
cp ./bin/protoc /usr/bin/protoc
protoc --version
rm -rf bin protoc.zip