bsc/.github/workflows/pre-release.yml
dylanhuang 282ef8952d
ci: fix release job (#1519)
* ci: remove CGO_ENABLE=0 due to blst package
* ci: fix arm binary build
* ci: remove arm5-7 version
* ci: fix arm64 build script
* ci: fix generate_change_log.sh
2023-04-24 22:30:27 +08:00

183 lines
5.5 KiB
YAML

name: Pre Release
on:
push:
# Publish `pre-v1.2.3` tags as releases.
tags:
- 'pre-*'
jobs:
build:
name: Build Release
strategy:
matrix:
go-version: [1.19.x]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/cache@v3
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
~\AppData\Local\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
# ==============================
# Linux/Macos/Windows Build
# ==============================
- name: Build Binary for ${{matrix.os}}
if: matrix.os == 'ubuntu-latest'
run: |
go mod download
wget https://musl.cc/x86_64-linux-musl-cross.tgz
tar -xvf ./x86_64-linux-musl-cross.tgz
GIT_COMMIT=$(git rev-parse HEAD)
GIT_COMMIT_DATE=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d')
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC=$(pwd)/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc go build -ldflags "-X main.gitCommit=$GIT_COMMIT -X main.gitDate=$GIT_COMMIT_DATE -extldflags=-static" -o ./build/bin/geth -a ./cmd/geth
- name: Build Binary for ${{matrix.os}}
if: matrix.os != 'ubuntu-latest'
run: |
go mod download
make geth
# ==============================
# Cross Compile for ARM
# ==============================
- name: Build Binary for ARM
if: matrix.os == 'ubuntu-latest'
run: |
go mod download
wget https://musl.cc/aarch64-linux-musl-cross.tgz
tar -xvf ./aarch64-linux-musl-cross.tgz
GIT_COMMIT=$(git rev-parse HEAD)
GIT_COMMIT_DATE=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d')
GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc go build -ldflags "-X main.gitCommit=$GIT_COMMIT -X main.gitDate=$GIT_COMMIT_DATE -extldflags=-static" -o ./build/bin/geth-linux-arm64 -a ./cmd/geth
# ==============================
# Upload artifacts
# ==============================
- name: Upload Linux Build
uses: actions/upload-artifact@v3
if: matrix.os == 'ubuntu-latest'
with:
name: linux
path: ./build/bin/geth
- name: Upload MacOS Build
uses: actions/upload-artifact@v3
if: matrix.os == 'macos-latest'
with:
name: macos
path: ./build/bin/geth
- name: Upload Windows Build
uses: actions/upload-artifact@v3
if: matrix.os == 'windows-latest'
with:
name: windows
path: ./build/bin/geth.exe
- name: Upload ARM-64 Build
uses: actions/upload-artifact@v3
if: matrix.os == 'ubuntu-latest'
with:
name: arm64
path: ./build/bin/geth-linux-arm64
release:
name: Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Set Env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Checkout Code
uses: actions/checkout@v3
# ==============================
# Download artifacts
# ==============================
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: linux
path: ./linux
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: macos
path: ./macos
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: windows
path: ./windows
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: arm64
path: ./arm64
- name: Download Config File
run: |
. ./.github/release.env
echo "mainnet.zip url: $MAINNET_FILE_URL"
echo "testnet.zip url: $TESTNET_FILE_URL"
curl -L $MAINNET_FILE_URL -o ./mainnet.zip
curl -L $TESTNET_FILE_URL -o ./testnet.zip
# ==============================
# Create release
# ==============================
# Rename assets
- run: |
mv ./linux/geth ./linux/geth_linux
mv ./macos/geth ./macos/geth_macos
mv ./windows/geth.exe ./windows/geth_windows.exe
- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.RELEASE_VERSION}}
release_name: ${{ env.RELEASE_VERSION}}
body: |
versing: ${{ env.RELEASE_VERSION}}
git commit: ${{ github.sha }}
draft: true
prerelease: true
files: |
./mainnet.zip
./testnet.zip
./linux/geth_linux
./macos/geth_macos
./windows/geth_windows.exe
./arm64/geth-linux-arm64