Skip to content

Manual pre-release

Manual pre-release #93

name: Manual pre-release
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch'
required: true
default: 'main'
version:
description: 'Version (e.g. chore/upgrade, v1.13.1-alpha.1, v1.13.1-rc1)'
required: true
component:
description: 'Component'
required: true
type: choice
options:
- all
- lightclient
- fatclient
- bootnode
multiproof:
description: 'Multiproof feature'
required: false
type: boolean
default: true
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
fetch-depth: 0
- name: Set release tag
id: tag
run: |
MMP_SUFFIX=""
if [ "${{ github.event.inputs.multiproof }}" = "true" ]; then
MMP_SUFFIX="-mmp"
fi
case "${{ github.event.inputs.component }}" in
"bootnode")
echo "tag=avail-light-bootstrap${MMP_SUFFIX}-${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
;;
"lightclient")
echo "tag=avail-light-client${MMP_SUFFIX}-${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
;;
"fatclient")
echo "tag=avail-light-fat${MMP_SUFFIX}-${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
;;
"all")
echo "tag=avail-light${MMP_SUFFIX}-${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
;;
esac
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y \
librust-openssl-dev build-essential protobuf-compiler \
musl-tools clang libc6-dev libssl-dev pkg-config
- name: Setup Rust
run: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
source "$HOME/.cargo/env"
rustup target add x86_64-unknown-linux-gnu
- name: Build Bootstrap
if: ${{ github.event.inputs.component == 'bootnode' || github.event.inputs.component == 'all' }}
run: |
source "$HOME/.cargo/env"
cargo build --release -p avail-light-bootstrap
mkdir -p binaries
cp target/release/avail-light-bootstrap binaries/avail-light-bootstrap-linux-amd64
cd binaries
tar czf avail-light-bootstrap-linux-amd64.tar.gz avail-light-bootstrap-linux-amd64
- name: Build Light Client
if: ${{ github.event.inputs.component == 'lightclient' || github.event.inputs.component == 'all' }}
run: |
source "$HOME/.cargo/env"
if [ "${{ github.event.inputs.multiproof }}" = "true" ]; then
cargo build --release -p avail-light-client
else
cargo build --release --no-default-features --features rocksdb -p avail-light-client
fi
mkdir -p binaries
cp target/release/avail-light-client binaries/avail-light-linux-amd64
cd binaries
tar czf avail-light-linux-amd64.tar.gz avail-light-linux-amd64
- name: Build Fat Client
if: ${{ github.event.inputs.component == 'fatclient' || github.event.inputs.component == 'all' }}
run: |
source "$HOME/.cargo/env"
if [ "${{ github.event.inputs.multiproof }}" = "true" ]; then
cargo build --release -p avail-light-fat
else
cargo build --release --no-default-features --features rocksdb -p avail-light-fat
fi
mkdir -p binaries
ls -la target/release/
cp target/release/avail-light-fat binaries/avail-light-fat-linux-amd64
ls -la binaries/
./binaries/avail-light-fat-linux-amd64 --help
cd binaries
tar czf avail-light-fat-linux-amd64.tar.gz avail-light-fat-linux-amd64
- name: Get commit changes
id: changes
run: |
if [ "${{ github.event.inputs.branch }}" = "main" ]; then
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
echo "commits<<EOF" >> $GITHUB_OUTPUT
git log --oneline $LAST_TAG..HEAD >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "commits<<EOF" >> $GITHUB_OUTPUT
git log --oneline -10 >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
else
echo "commits<<EOF" >> $GITHUB_OUTPUT
git log --oneline origin/main..${{ github.event.inputs.branch }} >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: avail-light-binaries
path: binaries/*.tar.gz
binary_publish:
needs: [build]
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
fetch-depth: 0
- name: Set release tag
id: tag
run: |
MMP_SUFFIX=""
if [ "${{ github.event.inputs.multiproof }}" = "true" ]; then
MMP_SUFFIX="-mmp"
fi
case "${{ github.event.inputs.component }}" in
"bootnode")
echo "tag=avail-light-bootstrap${MMP_SUFFIX}-${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
;;
"lightclient")
echo "tag=avail-light-client${MMP_SUFFIX}-${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
;;
"fatclient")
echo "tag=avail-light-fat${MMP_SUFFIX}-${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
;;
"all")
echo "tag=avail-light${MMP_SUFFIX}-${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
;;
esac
- name: Get commit changes
id: changes
run: |
if [ "${{ github.event.inputs.branch }}" = "main" ]; then
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
echo "commits<<EOF" >> $GITHUB_OUTPUT
git log --oneline $LAST_TAG..HEAD >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "commits<<EOF" >> $GITHUB_OUTPUT
git log --oneline -10 >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
else
echo "commits<<EOF" >> $GITHUB_OUTPUT
git log --oneline origin/main..${{ github.event.inputs.branch }} >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: binaries
pattern: avail-light-binaries
merge-multiple: true
- name: List downloaded files
run: |
echo "Downloaded files:"
find binaries -name "*.tar.gz" | sort
- name: Publish binaries
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.PAT_TOKEN }}
file: binaries/avail-light*.tar.gz
release_name: ${{ steps.tag.outputs.tag }}
tag: ${{ steps.tag.outputs.tag }}
overwrite: true
file_glob: true
prerelease: true
- name: Summary
run: |
echo "## Release Created" >> $GITHUB_STEP_SUMMARY
echo "- **Version:** ${{ steps.tag.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "- **Component:** ${{ github.event.inputs.component }}" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** ${{ github.event.inputs.branch }}" >> $GITHUB_STEP_SUMMARY
echo "- **Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "- **Files Published:**" >> $GITHUB_STEP_SUMMARY
find binaries -name "*.tar.gz" | while read file; do
echo " - $(basename $file)" >> $GITHUB_STEP_SUMMARY
done