feat: ci releases (#36)

* add simple release ci for mac arm

* install arm target

* run mac build on macos-latest

* archive file

* fix file paths

* use tag names

* add amd darwin build

* fix typo

* add linux arm build

* add linux amd build

* fix linux arm

* install libssl for linux arm

* set linker

* install pkg-config

* fix openssl

* use cross

* fix cross

* fix cross

* .

* .

* add deps

* .

* .

* use vendored openssl

* remove cross

* deps

* push to tags

* use commit as tag name

* tag with correct name and use pre release

* fix tag names

* only maual dispatch
This commit is contained in:
Noah Citron 2022-09-15 04:55:29 -04:00 committed by GitHub
parent 17301ec409
commit 7bb9800447
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 148 additions and 160 deletions

View File

@ -1,186 +1,159 @@
# https://github.com/lightclient-rs/foundry/blob/master/.github/workflows/release.yml
name: Release version
name: release
on:
workflow_dispatch:
env:
IS_NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
CARGO_TERM_COLOR: always
jobs:
prepare:
name: Prepare release
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.release_info.outputs.tag_name }}
release_name: ${{ steps.release_info.outputs.release_name }}
changelog: ${{ steps.build_changelog.outputs.changelog }}
build-mac-arm:
runs-on: macos-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: checkout
uses: actions/checkout@v1
- name: Compute release name and tag
id: release_info
run: |
if [[ $IS_NIGHTLY ]]; then
echo "::set-output name=tag_name::nightly-${GITHUB_SHA}"
echo "::set-output name=release_name::Nightly ($(date '+%Y-%m-%d'))"
else
echo "::set-output name=tag_name::${GITHUB_REF_NAME}"
echo "::set-output name=release_name::${GITHUB_REF_NAME}"
fi
release:
name: ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}
needs: prepare
strategy:
matrix:
job:
# The OS is used for the runner
# The platform is a generic platform name
# The target is used by Cargo
# The arch is either 386, arm64 or amd64
# The svm target platform to use for the binary https://github.com/roynalnaruto/svm-rs/blob/84cbe0ac705becabdc13168bae28a45ad2299749/svm-builds/build.rs#L4-L24
- os: ubuntu-latest
platform: linux
target: x86_64-unknown-linux-gnu
arch: amd64
svm_target_platform: linux-amd64
- os: ubuntu-latest
platform: linux
target: aarch64-unknown-linux-gnu
arch: arm64
svm_target_platform: linux-aarch64
- os: macos-latest
platform: darwin
target: x86_64-apple-darwin
arch: amd64
svm_target_platform: macosx-amd64
- os: macos-latest
platform: darwin
target: aarch64-apple-darwin
arch: arm64
svm_target_platform: macosx-aarch64
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install toolchain
- name: install rust nightly
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
target: ${{ matrix.job.target }}
default: true
override: true
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true
- name: install target
run: rustup target add aarch64-apple-darwin
- name: Apple M1 setup
if: ${{ matrix.job.target == 'aarch64-apple-darwin' }}
- name: build
run: cargo build --all --release --target aarch64-apple-darwin
- name: archive
run: gtar -czvf "lightclient_darwin_arm64.tar.gz" -C ./target/aarch64-apple-darwin/release lightclient
- name: generate tag name
id: tag
run: |
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV
- name: Linux ARM setup
if: ${{ matrix.job.target == 'aarch64-unknown-linux-gnu' }}
echo "::set-output name=release_tag::nightly-${GITHUB_SHA}"
- name: release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag.outputs.release_tag }}
prerelease: true
files: |
lightclient_darwin_arm64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-mac-amd:
runs-on: macos-latest
steps:
- name: checkout
uses: actions/checkout@v1
- name: install rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
default: true
override: true
- name: install target
run: rustup target add x86_64-apple-darwin
- name: build
run: cargo build --all --release --target x86_64-apple-darwin
- name: archive
run: gtar -czvf "lightclient_darwin_amd64.tar.gz" -C ./target/x86_64-apple-darwin/release lightclient
- name: generate tag name
id: tag
run: |
echo "::set-output name=release_tag::nightly-${GITHUB_SHA}"
- name: release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag.outputs.release_tag }}
prerelease: true
files: |
lightclient_darwin_amd64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-linux-arm:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v1
- name: install rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
default: true
override: true
- name: install target
run: rustup target add aarch64-unknown-linux-gnu
- name: install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- name: Build binaries
uses: actions-rs/cargo@v1
env:
SVM_TARGET_PLATFORM: ${{ matrix.job.svm_target_platform }}
with:
command: build
args: --release --bins --target ${{ matrix.job.target }}
- name: Archive binaries
id: artifacts
env:
PLATFORM_NAME: ${{ matrix.job.platform }}
TARGET: ${{ matrix.job.target }}
ARCH: ${{ matrix.job.arch }}
VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }}
- name: build
run: cargo build --all --release --target aarch64-unknown-linux-gnu
- name: archive
run: tar -czvf "lightclient_linux_arm64.tar.gz" -C ./target/aarch64-unknown-linux-gnu/release lightclient
- name: generate tag name
id: tag
run: |
if [ "$PLATFORM_NAME" == "linux" ]; then
tar -czvf "lightclient_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release lightclient
echo "::set-output name=file_name::lightclient_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz"
elif [ "$PLATFORM_NAME" == "darwin" ]; then
# We need to use gtar here otherwise the archive is corrupt.
# See: https://github.com/actions/virtual-environments/issues/2619
gtar -czvf "lightclient_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release lightclient
echo "::set-output name=file_name::lightclient_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz"
fi
shell: bash
echo "::set-output name=release_tag::nightly-${GITHUB_SHA}"
- name: Build man page
id: man
if: ${{ matrix.job.target == 'x86_64-unknown-linux-gnu' }}
env:
PLATFORM_NAME: ${{ matrix.job.platform }}
TARGET: ${{ matrix.job.target }}
VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }}
run: |
sudo apt-get -y install help2man
help2man -N ./target/${TARGET}/release/lightclient > lightclient.1
gzip lightclient.1
tar -czvf "lightclient_man_${VERSION_NAME}.tar.gz" lightclient.1.gz
echo "::set-output name=lightclient_man::lightclient_man_${VERSION_NAME}.tar.gz"
shell: bash
# Creates the release for this specific version
- name: Create release
- name: release
uses: softprops/action-gh-release@v1
with:
name: ${{ needs.prepare.outputs.release_name }}
tag_name: ${{ needs.prepare.outputs.tag_name }}
prerelease: ${{ env.IS_NIGHTLY }}
body: ${{ needs.prepare.outputs.changelog }}
files: |
${{ steps.artifacts.outputs.file_name }}
${{ steps.man.outputs.lightclient_man }}
# If this is a nightly release, it also updates the release
# tagged `nightly` for compatability with `lightclientup`
- name: Update nightly release
if: ${{ env.IS_NIGHTLY }}
uses: softprops/action-gh-release@v1
with:
name: 'Nightly'
tag_name: 'nightly'
tag_name: ${{ steps.tag.outputs.release_tag }}
prerelease: true
body: ${{ needs.prepare.outputs.changelog }}
files: |
${{ steps.artifacts.outputs.file_name }}
${{ steps.man.outputs.lightclient_man }}
cleanup:
name: Release cleanup
lightclient_linux_arm64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-linux-amd:
runs-on: ubuntu-latest
needs: release
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: checkout
uses: actions/checkout@v1
# Moves the `nightly` tag to `HEAD`
- name: Move nightly tag
if: ${{ env.IS_NIGHTLY }}
uses: actions/github-script@v5
- name: install rust nightly
uses: actions-rs/toolchain@v1
with:
script: |
const moveTag = require('./.github/scripts/move-tag.js')
await moveTag({ github, context }, 'nightly')
- name: Delete old nightlies
uses: actions/github-script@v5
toolchain: nightly
default: true
override: true
- name: install target
run: rustup target add x86_64-unknown-linux-gnu
- name: build
run: cargo build --all --release --target x86_64-unknown-linux-gnu
- name: archive
run: tar -czvf "lightclient_linux_amd64.tar.gz" -C ./target/x86_64-unknown-linux-gnu/release lightclient
- name: generate tag name
id: tag
run: |
echo "::set-output name=release_tag::nightly-${GITHUB_SHA}"
- name: release
uses: softprops/action-gh-release@v1
with:
script: |
const prunePrereleases = require('./.github/scripts/prune-prereleases.js')
await prunePrereleases({github, context})
tag_name: ${{ steps.tag.outputs.release_tag }}
prerelease: true
files: |
lightclient_linux_amd64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,4 +1,4 @@
name: Rust
name: test
on:
push:
@ -8,7 +8,7 @@ on:
jobs:
check:
name: Check
name: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@ -22,7 +22,7 @@ jobs:
command: check
test:
name: Test Suite
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@ -36,7 +36,7 @@ jobs:
command: test
fmt:
name: Rustfmt
name: fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

11
Cargo.lock generated
View File

@ -437,6 +437,7 @@ dependencies = [
"hex",
"jsonrpsee",
"log",
"openssl",
"reqwest",
"revm",
"serde",
@ -2169,6 +2170,15 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-src"
version = "111.22.0+1.1.1q"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f31f0d509d1c1ae9cada2f9539ff8f37933831fd5098879e482aa687d659853"
dependencies = [
"cc",
]
[[package]]
name = "openssl-sys"
version = "0.9.75"
@ -2178,6 +2188,7 @@ dependencies = [
"autocfg",
"cc",
"libc",
"openssl-src",
"pkg-config",
"vcpkg",
]

View File

@ -20,6 +20,7 @@ bytes = "1.2.1"
futures = "0.3.23"
toml = "0.5.9"
log = "0.4.17"
openssl = { version = "0.10", features = ["vendored"] }
common = { path = "../common" }
consensus = { path = "../consensus" }

View File

@ -12,3 +12,4 @@ hex = "0.4.3"
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs" }
ethers = "0.17.0"
toml = "0.5.9"
openssl = { version = "0.10", features = ["vendored"] }

View File

@ -23,6 +23,7 @@ toml = "0.5.9"
async-trait = "0.1.57"
log = "0.4.17"
chrono = "0.4.22"
openssl = { version = "0.10", features = ["vendored"] }
common = { path = "../common" }
config = { path = "../config" }

View File

@ -22,6 +22,7 @@ futures = "0.3.23"
toml = "0.5.9"
triehash-ethereum = { git = "https://github.com/openethereum/parity-ethereum" }
async-trait = "0.1.57"
openssl = { version = "0.10", features = ["vendored"] }
common = { path = "../common" }
consensus = { path = "../consensus" }