Skip to content

Build IOTA binaries for develop #54

Build IOTA binaries for develop

Build IOTA binaries for develop #54

Workflow file for this run

name: Build IOTA binaries
run-name: Build IOTA binaries for ${{ inputs.iota_branch || github.ref }}
on:
release:
types: [created]
schedule:
- cron: "0 4 * * *" # Runs every day at 4 AM
workflow_dispatch:
inputs:
iota_branch:
description: "Branch to build from"
type: string
required: true
concurrency: ${{ github.workflow }}-${{ inputs.iota_branch || github.ref }}
env:
BINARY_LIST_FILE: "./binary-build-list.json"
CARGO_TERM_COLOR: always
# Disable incremental compilation.
#
# Incremental compilation is useful as part of an edit-build-test-edit cycle,
# as it lets the compiler avoid recompiling code that hasn't changed. However,
# on CI, we're not making small edits; we're almost always building the entire
# project from scratch. Thus, incremental compilation on CI actually
# introduces *additional* overhead to support making future builds
# faster...but no future builds will ever occur in any given CI environment.
#
# See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
# for details.
CARGO_INCREMENTAL: 0
# Allow more retries for network requests in cargo (downloading crates) and
# rustup (installing toolchains). This should help to reduce flaky CI failures
# from transient network timeouts or other issues.
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
# Don't emit giant backtraces in the CI logs.
RUST_BACKTRACE: short
TMP_BUILD_DIR: "./tmp/release"
jobs:
release-build:
name: Build Binaries
timeout-minutes: 240
strategy:
matrix:
include:
- os: self-hosted-x64
os_type: linux-x86_64
- os: self-hosted-arm64
os_type: linux-arm64
- os: macos-latest
os_type: macos-arm64
- os: windows-latest
os_type: windows-x86_64
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Clean up and validate ref to build and create artifact name
shell: bash
run: |
# Manual dispatch on a branch ref
if [ "${{ github.event_name == 'workflow_dispatch' }}" == "true" ]; then
echo "iota_ref=${{ inputs.iota_branch }}" >> $GITHUB_ENV
echo "artifact_name=iota-$(echo ${{ inputs.iota_branch }} | tr "/" "-")-${{ matrix.os_type }}" >> $GITHUB_ENV
fi
# Release builds on a tag ref
if [ "${{ github.event_name == 'release' }}" == "true" ]; then
export iota_ref=$(echo ${{ github.ref }} | sed s/'refs\/tags\/'// )
echo "iota_ref=${iota_ref}" >> $GITHUB_ENV
echo "artifact_name=iota-${iota_ref}-${{ matrix.os_type }}" >> $GITHUB_ENV
fi
# Scheduled nightly builds are always cut from develop
if [ "${{ github.event_name == 'schedule' }}" == "true" ]; then
echo "iota_ref=develop" >> $GITHUB_ENV
echo "artifact_name=iota-nightly-$(date -Idate)-${{ matrix.os_type }}" >> $GITHUB_ENV
fi
- name: Check out ${{ env.iota_ref }}
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
ref: ${{ env.iota_ref }}
# - name: Set os/arch variables (Windows)
# if: ${{ matrix.os_type == 'windows-x86_64' }}
# shell: bash
# run: |
# echo "extension=$(echo ".exe")" >> $GITHUB_ENV
# - name: Setup caching
# # Fork of 'Swatinem/rust-cache' which allows caching additional paths
# uses: bmwill/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # v1.4.0
# - name: Install nexttest (Windows)
# if: ${{ matrix.os_type == 'windows-x86_64' }}
# uses: taiki-e/install-action@375e0c7f08a66b8c2ba7e7eef31a6f91043a81b0 # v2.44.38
# with:
# tool: nextest
# - name: Install postgres (Windows)
# if: ${{ matrix.os_type == 'windows-x86_64' }}
# shell: bash
# run: |
# choco install postgresql16 --force --params '/Password:root'
# echo "C:\Program Files\PostgreSQL\16\bin" >> $GITHUB_PATH
# echo "C:\Program Files\PostgreSQL\16\lib" >> $GITHUB_PATH
# echo "PQ_LIB_DIR=C:\Program Files\PostgreSQL\16\lib" >> $GITHUB_ENV
# echo "PG_DATABASE_URL=postgres://postgres:root@localhost/" >> $GITHUB_ENV
# echo "PG_EXAMPLE_DATABASE_URL=postgres://postgres:root@localhost/diesel_example" >> $GITHUB_ENV
# - name: Install postgres (MacOS arm64)
# if: ${{ matrix.os_type == 'macos-arm64' }}
# shell: bash
# env:
# PQ_LIB_DIR: "$(brew --prefix libpq)/lib"
# LIBRARY_PATH: "/opt/homebrew/lib:$LIBRARY_PATH"
# PKG_CONFIG_PATH: "/opt/homebrew/lib/pkgconfig:$PKG_CONFIG_PATH"
# PATH: "/opt/homebrew/bin:$PATH"
# run: |
# brew install postgresql
# - name: Remove unused apps (MacOS arm64)
# if: ${{ matrix.os_type == 'macos-arm64' }}
# continue-on-error: true
# shell: bash
# run: |
# # MacOS arm64 runner only has 14GB available, which is too small for our builds, so removing unused software.
# df -h /
# sudo rm -rf /Applications/Xcode*.app
# sudo rm -rf ~/Library/Developer/Xcode/DerivedData
# sudo rm -rf ~/Library/Developer/CoreSimulator/Caches/*
# sudo rm -rf ~/Library/Developer/Xcode/iOS\ DeviceSupport/*
# df -h /
# - name: Cargo build for ${{ matrix.os_type }} platform
# shell: bash
# # Currently building in release mode, but we could also have debug builds for testing
# run: |
# [ -f ~/.cargo/env ] && source ~/.cargo/env ; cargo build --release --features indexer
# - name: Rename binaries for ${{ matrix.os_type }}
# shell: bash
# run: |
# mkdir -p ${{ env.TMP_BUILD_DIR }}
# [ ! -f ${{ env.BINARY_LIST_FILE }} ] && echo "${{ env.BINARY_LIST_FILE }} cannot be found" && exit 1
# for binary in $(cat ${{ env.BINARY_LIST_FILE }} | jq -r '.release_binaries[]'); do
# export binary=$(echo ${binary} | tr -d $'\r')
# mv ./target/release/${binary}${{ env.extension }} ${{ env.TMP_BUILD_DIR }}/${binary}${{ env.extension }}
# done
# tar -cvzf ./tmp/${{ env.artifact_name }}.tgz -C ${{ env.TMP_BUILD_DIR }} .
# # - name: Publish Windows iota binary to Chocolatey
# # if: ${{ matrix.os == 'windows-latest' && github.event_name == 'release' && && contains(env.iota_ref, '-rc') }}
# # shell: bash
# # run: |
# # choco install checksum
# # export iota_sha=$(checksum -t sha256 ${{ env.TMP_BUILD_DIR }}/iota.exe)
# # cd chocolatey
# #
# # cat <<EOF >>VERIFICATION.txt
# # IOTA Binary verification steps
# # 1. Download https://github.com/iotaledger/iota/releases/download/${{ env.iota_ref }}/${{ env.artifact_name }}.tgz
# # 2. Extract iota.exe
# # 3. Verify binary: checksum.exe -t sha256 iota.exe: ${iota_sha}
# #
# # File 'LICENSE.txt' is obtained from: https://github.com/iotaledger/iota/blob/develop/LICENSE
# # EOF
# #
# # choco pack --version ${{ env.iota_ref }} configuration=release
# # choco apikey --api-key ${{ secrets.CHOCO_API_KEY }} --source https://push.chocolatey.org/
# # choco push iota.${{ env.iota_ref }}.nupkg --source https://push.chocolatey.org/
# - name: Upload artifacts for ${{ matrix.os_type }} platform
# uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
# with:
# name: ${{ env.artifact_name }}
# if-no-files-found: error
# path: |
# ./tmp/${{ env.artifact_name }}.tgz
# - name: Attach artifacts to ${{ env.iota_ref }} release in GH
# if: ${{ github.event_name == 'release' }}
# uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
# with:
# tag_name: ${{ env.iota_ref }}
# files: |
# ./tmp/${{ env.artifact_name }}.tgz
update-homebrew-formula:
name: Run brew bump-formula-pr for iota on testnet releases
# needs: release-build
runs-on: ubuntu-latest
# releasing iota cli on testnet releases because it lags `main` less than mainnet, but is more likely to be stable than devnet
if: ${{ contains( inputs.iota_branch, 'testnet') || contains( github.ref, 'testnet') }}
steps:
- name: Clean up tag name ${{ env.iota_ref }}
shell: bash
run: |
echo "iota_tag=$(echo ${{ env.iota_ref }} | sed s/'refs\/tags\/'//)" >> $GITHUB_ENV
echo "versionless_tag=$(echo ${{ env.iota_ref }} | sed s/'refs\/tags\/'// | sed s/'testnet\-v'//)" >> $GITHUB_ENV
- uses: mislav/bump-homebrew-formula-action@b3327118b2153c82da63fd9cbf58942146ee99f0 # pin@v3
with:
homebrew-tap: iotaledger/homebrew-tap
formula-name: iota
create-pullrequest: true
tag-name: "${{ env.iota_tag }}"
commit-message: |
{{formulaName}} ${{ env.versionless_tag }}
Created by https://github.com/mislav/bump-homebrew-formula-action
From release: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
env:
# COMMITTER_TOKEN needs write access to the repository specified by the homebrew-tap input,
# or enough privileges to fork the tap repo (usually homebrew-core) and submit a PR to it.
# Recommended "classic" token scopes: repo & workflow.
# https://github.com/settings/tokens/new?scopes=public_repo,workflow
COMMITTER_TOKEN: ${{ secrets.HOMEBREW_GH_FORMULA_BUMP }}