Build and Upload AirDao Nop Binary #10
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 Upload AirDao Nop Binary | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'Cargo.toml' | |
workflow_dispatch: | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
create-release: | |
runs-on: ubuntu-latest | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- name: Get version from Cargo.toml | |
id: create_release_tag_name | |
run: | | |
version=$(curl -s https://raw.githubusercontent.com/ambrosus/airdao-nop-rs/main/Cargo.toml | grep '^version' | sed -E 's/version = "(.*)"/\1/') | |
echo "version=$version" >> $GITHUB_ENV | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.version }} | |
release_name: Release v${{ env.version }} | |
draft: false | |
prerelease: false | |
build-latest: | |
runs-on: ubuntu-latest | |
needs: create-release | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.81 | |
override: true | |
components: rustfmt, clippy | |
target: x86_64-unknown-linux-gnu | |
- name: Cache cargo registry and git dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
- name: Build binary | |
run: | | |
git submodule update --init --recursive | |
RUSTFLAGS='-C link-arg=-s' cargo build --release --target x86_64-unknown-linux-gnu | |
- name: Archive | |
run: | | |
mkdir airdao-nop-rs | |
cp target/x86_64-unknown-linux-gnu/release/airdao-nop-rs airdao-nop-rs/ | |
cp -r setup_templates/ config/ airdao-nop-rs/ | |
cp -r config/ airdao-nop-rs/ | |
cp update.sh airdao-nop-rs/ | |
zip -r airdao-nop-rs-x86-64.zip airdao-nop-rs/ | |
- name: Upload to Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload_url }} | |
asset_path: ./airdao-nop-rs-x86-64.zip | |
asset_name: airdao-nop-rs-x86-64.zip | |
asset_content_type: application/zip | |
build_20_04: | |
runs-on: ubuntu-20.04 | |
needs: create-release | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.81 | |
override: true | |
components: rustfmt, clippy | |
target: x86_64-unknown-linux-gnu | |
- name: Cache cargo registry and git dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
- name: Build binary | |
run: | | |
git submodule update --init --recursive | |
RUSTFLAGS='-C link-arg=-s' cargo build --release --target x86_64-unknown-linux-gnu | |
- name: Archive | |
run: | | |
mkdir airdao-nop-rs | |
cp target/x86_64-unknown-linux-gnu/release/airdao-nop-rs airdao-nop-rs/ | |
cp -r setup_templates/ config/ airdao-nop-rs/ | |
cp -r config/ airdao-nop-rs/ | |
cp update.sh airdao-nop-rs/ | |
zip -r airdao-nop-rs-x86-64-old.zip airdao-nop-rs/ | |
- name: Upload to Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload_url }} | |
asset_path: ./airdao-nop-rs-x86-64-old.zip | |
asset_name: airdao-nop-rs-x86-64-old.zip | |
asset_content_type: application/zip |