Skip to content

Merge pull request #1686 from gluwa/merge-testnet-into-main #39

Merge pull request #1686 from gluwa/merge-testnet-into-main

Merge pull request #1686 from gluwa/merge-testnet-into-main #39

Workflow file for this run

---
name: Build Release Artifacts
on:
push:
tags:
- "*"
permissions: read-all
jobs:
sanity-check:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sanity check tag name
run: |
git describe --tag | grep -E "mainnet|testnet"
build-native-runtime:
needs: sanity-check
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-22.04, windows-2022, macos-11]
runs-on: ${{ matrix.operating-system }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set-up Linux
if: matrix.operating-system == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt install -y cmake pkg-config libssl-dev git build-essential clang libclang-dev curl
- name: Install protobuf
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure rustc version
shell: bash
run: |
RUSTC_VERSION=$(grep channel rust-toolchain.toml | tail -n1 | tr -d " " | cut -f2 -d'"')
echo "RUSTC_VERSION=$RUSTC_VERSION" >> "$GITHUB_ENV"
- name: Install Rust toolchain
uses: gluwa/toolchain@dev
with:
toolchain: ${{ env.RUSTC_VERSION }}
target: wasm32-unknown-unknown
profile: minimal
override: true
- name: Install MacOS aarch64 target
if: matrix.operating-system == 'macos-11'
uses: gluwa/toolchain@dev
with:
toolchain: ${{ env.RUSTC_VERSION }}
target: aarch64-apple-darwin
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
- name: Figure out platform
shell: bash
run: |
PLATFORM=$(rustup target list --installed | grep "$(uname -m)")
echo "PLATFORM=$PLATFORM" >> "$GITHUB_ENV"
- name: Figure out tag name
shell: bash
run: |
TAG_NAME=$(git describe --tag)
echo "TAG_NAME=$TAG_NAME" >> "$GITHUB_ENV"
- name: DEBUG
shell: bash
run: |
echo "Tag & Platform is '${{ env.TAG_NAME }}-${{ env.PLATFORM }}'"
- name: Build
uses: gluwa/cargo@dev
with:
command: build
args: --release
- name: Build MacOS aarch64 target
if: matrix.operating-system == 'macos-11'
uses: gluwa/cargo@dev
with:
command: build
args: --release --target aarch64-apple-darwin
- name: Compress
uses: thedoctor0/zip-release@0.7.6
with:
type: "zip"
directory: "target/release/"
path: "creditcoin-node*"
filename: "../../creditcoin-${{ env.TAG_NAME }}-${{ env.PLATFORM }}.zip"
exclusions: "creditcoin-node.d"
- name: Compress MacOS aarch64 target
if: matrix.operating-system == 'macos-11'
uses: thedoctor0/zip-release@0.7.6
with:
type: "zip"
directory: "target/aarch64-apple-darwin/release/"
path: "creditcoin-node*"
filename: "../../../creditcoin-${{ env.TAG_NAME }}-aarch64-apple-darwin.zip"
exclusions: "creditcoin-node.d"
- name: Upload binary
if: matrix.operating-system != 'windows-2022'
uses: actions/upload-artifact@v4
with:
name: binary-for-${{ matrix.operating-system }}
path: "creditcoin-${{ env.TAG_NAME }}-*.zip"
if-no-files-found: error
build-wasm-runtime:
needs: sanity-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Figure out tag name
shell: bash
run: |
TAG_NAME=$(git describe --tag)
echo "TAG_NAME=$TAG_NAME" >> "$GITHUB_ENV"
- name: Build WASM runtime
id: srtool_build
uses: chevdor/srtool-actions@v0.8.0
with:
chain: "creditcoin"
runtime_dir: runtime
package: creditcoin-node-runtime
tag: "1.66.1" # FIXME: remove this option (use the latest) once we're building w/ stable rust
workdir: ${{ github.workspace }}
- name: DEBUG
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq . > creditcoin-srtool-digest.json
cat creditcoin-srtool-digest.json
echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}"
- name: Rename file
run: |
mv ${{ steps.srtool_build.outputs.wasm }} creditcoin-${{ env.TAG_NAME }}-runtime.wasm
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: binary-for-wasm
path: "*.wasm"
if-no-files-found: error
docker-build:
needs: sanity-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Figure out tag name
shell: bash
run: |
TAG_NAME=$(git describe --tag)
echo "TAG_NAME=$TAG_NAME" >> "$GITHUB_ENV"
- name: Build docker image
run: |
docker build -t gluwa/creditcoin:${{ env.TAG_NAME }} .
echo "${{ secrets.DOCKER_PUSH_PASSWORD }}" | docker login -u="${{ secrets.DOCKER_PUSH_USERNAME }}" --password-stdin
docker push gluwa/creditcoin:${{ env.TAG_NAME }}
# only -mainnet images are tagged as :latest
# shellcheck disable=SC2046,SC2143
if [ $(echo "${{ env.TAG_NAME}}" | grep "mainnet") ]; then
docker tag gluwa/creditcoin:${{ env.TAG_NAME }} gluwa/creditcoin:latest
docker push gluwa/creditcoin:latest
fi
docker logout
build-creditcoin-js:
needs: sanity-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g yarn
- name: Figure out tag name
shell: bash
run: |
TAG_NAME=$(git describe --tag)
echo "TAG_NAME=$TAG_NAME" >> "$GITHUB_ENV"
- name: Build creditcoin-js package
run: |
pushd creditcoin-js/
# version will match the git tag
echo "DEBUG: Tag is '${{ env.TAG_NAME }}"
sed -i 's/"version": ".*",/"version": "${{ env.TAG_NAME }}",/' package.json
yarn install && yarn pack
popd
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: binary-for-creditcoin-js
path: "creditcoin-js/creditcoin-js-v${{ env.TAG_NAME }}.tgz"
if-no-files-found: error
create-release:
permissions:
contents: write
runs-on: ubuntu-latest
needs:
- build-native-runtime
- build-wasm-runtime
- build-creditcoin-js
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Figure out tag name
shell: bash
run: |
TAG_NAME=$(git describe --tag)
echo "TAG_NAME=$TAG_NAME" >> "$GITHUB_ENV"
- name: Download binaries
uses: actions/download-artifact@v4
with:
path: artifact
pattern: binary-for-*
merge-multiple: true
- name: DEBUG
shell: bash
run: |
ls -lR
- name: Make the release
uses: softprops/action-gh-release@v2
with:
files: "artifact/creditcoin-*${{ env.TAG_NAME }}*"
fail_on_unmatched_files: true
name: ${{ env.TAG_NAME }}