Skip to content

Commit

Permalink
Merge pull request #359 from holisticode/cross-builds
Browse files Browse the repository at this point in the history
introduce cross-platform automatic builds
  • Loading branch information
StephenButtolph authored Sep 29, 2020
2 parents 7aedeb9 + 30d0850 commit 87ae6b3
Show file tree
Hide file tree
Showing 6 changed files with 200 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build-deb-pkg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
PKG_ROOT=/tmp/avalanchego
DEBIAN_BASE_DIR=$PKG_ROOT/debian
AVALANCHE_BUILD_BIN_DIR=$DEBIAN_BASE_DIR/usr/local/bin
AVALANCHE_LIB_DIR=$DEBIAN_BASE_DIR/usr/local/lib/avalanchego
TEMPLATE=.github/workflows/debian/template
DEBIAN_CONF=$DEBIAN_BASE_DIR/DEBIAN

mkdir -p $DEBIAN_BASE_DIR
mkdir -p $DEBIAN_CONF
mkdir -p $AVALANCHE_BUILD_BIN_DIR
mkdir -p $AVALANCHE_LIB_DIR

OK=`cp ./build/avalanchego $AVALANCHE_BUILD_BIN_DIR`
if [[ $OK -ne 0 ]]; then
exit $OK;
fi
OK=`cp ./build/plugins/evm $AVALANCHE_LIB_DIR`
if [[ $OK -ne 0 ]]; then
exit $OK;
fi
OK=`cp $TEMPLATE/control $DEBIAN_CONF`
if [[ $OK -ne 0 ]]; then
exit $OK;
fi

echo "Build debian package..."
cd $PKG_ROOT
echo "Tag: $TAG"
NEW_VERSION_STRING="Version: $TAG"
sed -i "s/Version.*/$NEW_VERSION_STRING/g" debian/DEBIAN/control
dpkg-deb --build debian avalanchego-linux_$TAG.deb
aws s3 cp avalanchego-linux_$TAG.deb s3://$BUCKET/linux/
49 changes: 49 additions & 0 deletions .github/workflows/build-linux-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Build a debian package from the avalanchego repo

name: build-linux-release

# Controls when the action will run.
on:
push:
tags:
- '*' # Push events to every tag

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-18.04

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Runs a single command using the runners shell
- name: Build the avalanchego binaries
run: ./scripts/build.sh

- name: Install aws cli
run: sudo apt-get install awscli

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
shell: bash

- name: Create debian package structure
run: ./.github/workflows/build-deb-pkg.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.UPLOAD_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.UPLOAD_KEY }}
TAG: ${{ steps.get_version.outputs.VERSION }}
BUCKET: ${{ secrets.BUCKET }}

- name: Create tgz package structure
run: ./.github/workflows/build-tgz-pkg.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.UPLOAD_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.UPLOAD_KEY }}
TAG: ${{ steps.get_version.outputs.VERSION }}
BUCKET: ${{ secrets.BUCKET }}
44 changes: 44 additions & 0 deletions .github/workflows/build-macos-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Build a macos release from the avalanchego repo

name: build-macos-release

# Controls when the action will run.
on:
push:
tags:
- '*' # Push events to every tag

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: macos-10.15

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Runs a single command using the runners shell
- name: Build the avalanchego binaries
run: ./scripts/build.sh

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
shell: bash

- name: Install aws cli
run: |
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
- name: Create zip file
run: 7z a avalanchego-macos-${{ steps.get_version.outputs.VERSION }}.zip build/avalanchego build/plugins

- name: Upload file to S3
run: aws s3 cp avalanchego-macos-${{ steps.get_version.outputs.VERSION }}.zip s3://{{ secrets.BUCKET }}/macos/
env:
AWS_ACCESS_KEY_ID: ${{ secrets.UPLOAD_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.UPLOAD_KEY }}
20 changes: 20 additions & 0 deletions .github/workflows/build-tgz-pkg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
PKG_ROOT=/tmp
VERSION=$TAG
AVALANCHE_ROOT=$PKG_ROOT/avalanchego-$VERSION

mkdir -p $AVALANCHE_ROOT

OK=`cp ./build/avalanchego $AVALANCHE_ROOT`
if [[ $OK -ne 0 ]]; then
exit $OK;
fi
OK=`cp -r ./build/plugins $AVALANCHE_ROOT`
if [[ $OK -ne 0 ]]; then
exit $OK;
fi

echo "Build tgz package..."
cd $PKG_ROOT
echo "Version: $VERSION"
tar -czvf "avalanchego-linux-$VERSION.tar.gz" avalanchego-$VERSION
aws s3 cp avalanchego-linux-$VERSION.tar.gz s3://$BUCKET/linux/
47 changes: 47 additions & 0 deletions .github/workflows/build-win-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Build a windows release from the avalanchego repo

name: build-win-release

# Controls when the action will run.
on:
push:
tags:
- '*' # Push events to every tag

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: windows-2019

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
shell: bash

# Runs a single command using the runners shell
- name: Build the avalanchego binaries
run: ./scripts/build.sh
shell: bash

- name: Create zip
run: |
mv .\build\avalanchego .\build\avalanchego.exe
mv .\build\plugins\evm .\build\plugins\evm.exe
Compress-Archive -Path .\build\avalanchego.exe,.\build\plugins -DestinationPath .\build\avalanchego-win-${{ steps.get_version.outputs.VERSION }}-experimental.zip
- name: Install aws cli
env:
AWS_ACCESS_KEY_ID: ${{ secrets.UPLOAD_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.UPLOAD_KEY }}
run: |
Install-Module -Name AWS.Tools.Installer -Force
Install-AWSToolsModule AWS.Tools.EC2,AWS.Tools.S3 -CleanUp -Force
Write-S3Object -BucketName ${{ secrets.BUCKET }} -File .\build\avalanchego-win-${{ steps.get_version.outputs.VERSION }}-experimental.zip -Key windows/avalanchego-win-${{ steps.get_version.outputs.VERSION }}-experimental.zip
8 changes: 8 additions & 0 deletions .github/workflows/debian/template/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Package: avalanchego
Version: 0.1.0
Section: misc
Priority: optional
Architecture: amd64
Depends:
Maintainer: Fabio Barone <[email protected]>
Description: The Avalanche platform binaries

0 comments on commit 87ae6b3

Please sign in to comment.