Skip to content

Commit

Permalink
Merge pull request #5 from ambrosus/update-setup-airdao-nop
Browse files Browse the repository at this point in the history
Update setup airdao nop
  • Loading branch information
Eshanchik authored Oct 29, 2024
2 parents daadfb4 + 5c774d4 commit a334896
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 45 deletions.
65 changes: 47 additions & 18 deletions .github/workflows/build_binary_nop_x86_64.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,43 @@
name: Build and Upload AirDao Nop Binary

on:
release:
types: [published]
push:
branches:
- main
paths:
- 'Cargo.toml'

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: ${{ env.version }}
release_name: Release ${{ env.version }}
draft: false
prerelease: false

build-latest:
runs-on: ubuntu-latest
needs: create-release

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -37,27 +65,28 @@ jobs:
git submodule update --init --recursive
RUSTFLAGS='-C link-arg=-s' cargo build --release --target x86_64-unknown-linux-gnu
- name: Get release
id: get_release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Archive
run: zip -j airdao-nop-rs-x86-64.zip target/x86_64-unknown-linux-gnu/release/airdao-nop-rs
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: ${{ steps.get_release.outputs.upload_url }}
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
Expand Down Expand Up @@ -85,21 +114,21 @@ jobs:
git submodule update --init --recursive
RUSTFLAGS='-C link-arg=-s' cargo build --release --target x86_64-unknown-linux-gnu
- name: Get release
id: get_release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Archive
run: zip -j airdao-nop-rs-x86-64-old.zip target/x86_64-unknown-linux-gnu/release/airdao-nop-rs
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: ${{ steps.get_release.outputs.upload_url }}
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "airdao-nop-rs"
version = "0.1.0"
version = "0.1.1"
edition = "2021"

[dependencies]
Expand Down
4 changes: 0 additions & 4 deletions run-update.sh

This file was deleted.

28 changes: 12 additions & 16 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
sed -i 's/^#\$nrconf{restart} = '\''i'\'';/$nrconf{restart} = '\''a'\'';/' /etc/needrestart/needrestart.conf

apt-get install -y \
libssl-dev \
pkg-config \
ca-certificates \
git \
jq \
unzip
Expand Down Expand Up @@ -63,26 +60,25 @@ fi
# Revert /etc/needrestart/needrestart.conf to original state after installing required packages
sed -i 's/^\$nrconf{restart} = '\''a'\'';/$nrconf{restart} = '\''i'\'';/' /etc/needrestart/needrestart.conf

git clone https://github.com/ambrosus/airdao-nop-rs.git
cd airdao-nop-rs || return

chmod +x update.sh
./update.sh

LATEST_TAG=$(curl -s https://api.github.com/repos/ambrosus/airdao-nop-rs/releases/latest | jq -r .tag_name)
DEBIAN_VERSION=$(lsb_release -sr)
UBUNTU_VERSION=$(lsb_release -sr)
LATEST_TAG=$(curl -s https://raw.githubusercontent.com/ambrosus/airdao-nop-rs/main/Cargo.toml | grep '^version' | sed -E 's/version = "(.*)"/\1/')
UBUNTU_MAJOR_VERSION=$(lsb_release -sr | cut -d '.' -f 1)
DEBIAN_MAJOR_VERSION=$(lsb_release -sr | cut -d '.' -f 1)

if (( $(echo "$DEBIAN_VERSION > 11" | bc -l) )) || (( $(echo "$UBUNTU_VERSION >= 22" | bc -l) )); then
FILE_URL="https://github.com/ambrosus/airdao-nop-rs/releases/download/$LATEST_TAG/airdao-nop-rs-x86-64.zip"
if (( DEBIAN_MAJOR_VERSION > 11 )) || (( UBUNTU_MAJOR_VERSION >= 22 )); then
FILE_URL="https://github.com/ambrosus/airdao-nop-rs/releases/download/v$LATEST_TAG/airdao-nop-rs-x86-64.zip"
else
FILE_URL="https://github.com/ambrosus/airdao-nop-rs/releases/download/$LATEST_TAG/airdao-nop-rs-x86-64-old.zip"
FILE_URL="https://github.com/ambrosus/airdao-nop-rs/releases/download/v$LATEST_TAG/airdao-nop-rs-x86-64-old.zip"
fi

curl -L -o airdao-nop-release.zip "$FILE_URL"

unzip airdao-nop-release.zip
rm airdao-nop-release.zip

cd airdao-nop-rs || return

chmod +x update.sh
./update.sh

chmod +x ./airdao-nop-rs

./airdao-nop-rs
37 changes: 31 additions & 6 deletions update.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
set -e
cd "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )"
if [[ -d /etc/cron.daily ]]; then
rm -f /etc/cron.daily/airdao-nop-rs
Expand All @@ -11,9 +10,35 @@ net.ipv6.conf.all.disable_ipv6=1
END
sysctl -p /etc/sysctl.d/10-airdao.conf

git checkout main
git pull origin main
git submodule update --init --recursive
cd ~/airdao-nop-rs || return

chmod +x run-update.sh
source run-update.sh
CURRENT_VERSION=$(./airdao-nop-rs --version | cut -d ' ' -f2)
LATEST_VERSION=$(curl -s https://raw.githubusercontent.com/ambrosus/airdao-nop-rs/main/Cargo.toml | grep '^version' | sed -E 's/version = "(.*)"/\1/')
DIR_NAME="airdao-nop-rs"
ZIP_FILE="${DIR_NAME}.zip"

install_airdao() {
cd ~

curl -L -o "$ZIP_FILE" "$FILE_URL"
echo "Распаковка $ZIP_FILE..."
unzip -o "$ZIP_FILE"
rm "$ZIP_FILE"

cd "$DIR_NAME"
chmod +x ./airdao-nop-rs

./airdao-nop-rs update
}

if [[ "$CURRENT_VERSION" != "$LATEST_VERSION" ]]; then
DEBIAN_VERSION=$(lsb_release -sr | cut -d '.' -f 1)
UBUNTU_VERSION=$(lsb_release -sr | cut -d '.' -f 1)
if (( DEBIAN_VERSION > 11 )) || (( UBUNTU_VERSION >= 22 )); then
FILE_URL="https://github.com/ambrosus/airdao-nop-rs/releases/download/v$LATEST_VERSION/airdao-nop-rs-x86-64.zip"
else
FILE_URL="https://github.com/ambrosus/airdao-nop-rs/releases/download/v$LATEST_VERSION/airdao-nop-rs-x86-64-old.zip"
fi

install_airdao
fi

0 comments on commit a334896

Please sign in to comment.