Skip to content

Commit

Permalink
build(release): use matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
evilrobot-01 committed Apr 14, 2024
1 parent e0a37e7 commit de285b5
Showing 1 changed file with 85 additions and 54 deletions.
139 changes: 85 additions & 54 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,93 +13,124 @@ on:
- 'frank/build-macos'

jobs:
build-node-for-linux:
runs-on: ubuntu-22.04
# build-node-for-linux:
# runs-on: ubuntu-22.04
# permissions:
# contents: write
# strategy:
# matrix:
# cpu: [ "", "skylake" ]
# env:
# RUSTFLAGS: "-C target-cpu=${{ matrix.cpu }}"
# name: "pop-node${{ matrix.cpu != '' && format('-{0}', matrix.cpu) || '' }}"
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# ref: ${{ github.event.inputs.ref }}
#
# - name: Install packages
# run: |
# sudo apt-get install -y protobuf-compiler
# protoc --version
#
# - name: Build node
# run: cargo build --profile=production -p pop-node
#
# - name: Save binary
# run: |
# mkdir -p build
# cp target/production/pop-node build/${{ env.name }}
# sha256sum build/${{ env.name }} > build/${{ env.name }}.sha256
#
# - name: Upload binary
# uses: actions/upload-artifact@v3
# with:
# name: binaries
# path: build
#
# - name: Add binary to release
# if: github.event_name == 'release'
# uses: softprops/action-gh-release@v1
# with:
# files: |
# build/${{ env.name }}
# build/${{ env.name }}.sha256

build-node:
runs-on: ${{ matrix.platform.os }}
permissions:
contents: write
strategy:
matrix:
cpu: [ "", "skylake" ]
platform:
# Linux
# - os: ubuntu-22.04
# target: aarch64-unknown-linux-gnu
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
cpu: skylake
# macOS
- os: macos-14
target: aarch64-apple-darwin
- os: macos-14
target: x86_64-apple-darwin
env:
RUSTFLAGS: "-C target-cpu=${{ matrix.cpu }}"
name: "pop-node${{ matrix.cpu != '' && format('-{0}', matrix.cpu) || '' }}"
RUSTFLAGS: "-C target-cpu=${{ matrix.platform.cpu }}"
path: "target/${{ matrix.platform.target }}/production"
package: "pop-node-${{ matrix.platform.target }}${{ matrix.platform.cpu != '' && format('-{0}', matrix.platform.cpu) || '' }}.tar.gz"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.ref }}

- name: Install packages
- name: Install packages (Linux)
if: contains(matrix.platform.target, 'linux')
run: |
sudo apt-get install -y protobuf-compiler
sudo apt-get install -y protobuf-compiler
protoc --version
# gcc-aarch64-linux-gnu

- name: Build node
run: cargo build --profile=production -p pop-node

- name: Save binary
run: |
mkdir -p build
cp target/production/pop-node build/${{ env.name }}
sha256sum build/${{ env.name }} > build/${{ env.name }}.sha256
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: binaries
path: build

- name: Add binary to release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: |
build/${{ env.name }}
build/${{ env.name }}.sha256
build-node-for-macos:
runs-on: macos-14
permissions:
contents: write
strategy:
matrix:
target: [ "aarch64-apple-darwin", "x86_64-apple-darwin" ]
env:
name: "pop-node-${{ matrix.target }}"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.ref }}

- name: Install packages
- name: Install packages (macOS)
if: contains(matrix.platform.target, 'apple')
run: |
brew install protobuf
protoc --version
- name: Add target
run: rustup target add ${{ matrix.target }}
run: rustup target add ${{ matrix.platform.target }}

- name: Build node
run: cargo build --profile=production -p pop-node --target ${{ matrix.target }}
run: cargo build --profile=production -p pop-node --target ${{ matrix.platform.target }}

- name: Package binary (Linux)
if: contains(matrix.platform.target, 'linux')
run: |
cd ${{ env.path }}
sha256sum pop-node > pop-node.sha256
tar -czf ${{ env.package }} pop-node pop-node.sha256
- name: Package binary
- name: Package binary (macOS)
if: contains(matrix.platform.target, 'apple')
run: |
cd target/${{ matrix.target }}/production
cd ${{ env.path }}
shasum -a 256 pop-node > pop-node.sha256
tar -czf pop-node-${{ matrix.target }}.tar.gz pop-node pop-node.sha256
tar -czf ${{ env.package }} pop-node pop-node.sha256
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: binaries
path: target/${{ matrix.target }}/production/pop-node-${{ matrix.target }}.tar.gz
path: ${{ env.path }}/${{ env.package }}

- name: Add binary to release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: |
target/${{ matrix.target }}/production/pop-node-${{ matrix.target }}.tar.gz
${{ env.path }}/${{ env.package }}

0 comments on commit de285b5

Please sign in to comment.