Attach IOTA binaries to a release #21
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Attach IOTA binaries to a release | |
run-name: Attach IOTA binaries to a ${{ inputs.iota_tag }} release | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: | |
inputs: | |
iota_tag: | |
description: "IOTA repo tag to build from" | |
type: string | |
required: true | |
concurrency: ${{ github.workflow }}-${{ inputs.iota_tag || github.ref }} | |
env: | |
TAG_NAME: "${{ github.event.inputs.iota_tag || github.ref }}" | |
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 & Publish Binaries | |
timeout-minutes: 120 | |
strategy: | |
matrix: | |
os: [ | |
self-hosted, # ubuntu-x86_64 | |
macos-latest, # macos-arm64 | |
# windows-latest (windows-x86_64) is disabled because we need to add custom logic for authenticating | |
# git for private repositories during the build (needed for iota-msim) | |
# MrSquaare/ssh-setup-action@v3 does not support windows | |
] | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Clean up and validate ${{ env.TAG_NAME }} tag name | |
shell: bash | |
run: | | |
export iota_tag=$(echo ${{ env.TAG_NAME }} | sed s/'refs\/tags\/'// ) | |
[[ "${iota_tag}" == "develop" ]] && echo "tag cannot be equal to 'develop'" && exit 1 | |
echo "iota_tag=${iota_tag}" >> $GITHUB_ENV | |
export iota_version=$(echo ${iota_tag} | sed -e 's/mainnet-v//' -e 's/testnet-v//') | |
echo "iota_version=${iota_version}" >> $GITHUB_ENV | |
- name: Check out ${{ env.iota_tag }} | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # pin@v4 | |
with: | |
ref: ${{ env.iota_tag }} | |
- name: Set os/arch variables (Windows) | |
if: ${{ matrix.os == 'windows-latest' }} | |
shell: bash | |
run: | | |
export arch=$(uname -m) | |
export os_type="windows-${arch}" | |
echo "os_type=${os_type}" >> $GITHUB_ENV | |
echo "extention=$(echo ".exe")" >> $GITHUB_ENV | |
- name: Set os/arch variables (self hosted ubuntu) | |
if: ${{ matrix.os == 'self-hosted' }} | |
shell: bash | |
run: | | |
export arch=$(uname -m) | |
export os_type="linux-${arch}" | |
echo "os_type=${os_type}" >> $GITHUB_ENV | |
- name: Set os/arch variables | |
if: ${{ matrix.os == 'macos-latest' }} | |
shell: bash | |
run: | | |
export arch=$(uname -m) | |
export system_os=$(echo ${{ matrix.os }} | cut -d- -f1) | |
export os_type="${system_os}-${arch}" | |
echo "os_type=${system_os}-${arch}" >> $GITHUB_ENV | |
- name: Setup caching | |
# Fork of 'Swatinem/rust-cache' which allows caching additional paths | |
uses: bmwill/rust-cache@fb63fcd7a959767755b88b5af2f5cbf65fb8a127 # pin@v1 | |
- name: Install nexttest (Windows) | |
if: ${{ matrix.os == 'windows-latest' }} | |
uses: taiki-e/install-action@375e0c7f08a66b8c2ba7e7eef31a6f91043a81b0 # pin@v2 | |
with: | |
tool: nextest | |
- name: Install postgres (Windows) | |
if: ${{ matrix.os == 'windows-latest' }} | |
shell: bash | |
run: | | |
choco install postgresql12 --force --params '/Password:root' | |
echo "C:\Program Files\PostgreSQL\12\bin" >> $GITHUB_PATH | |
echo "C:\Program Files\PostgreSQL\12\lib" >> $GITHUB_PATH | |
echo "PQ_LIB_DIR=C:\Program Files\PostgreSQL\12\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 == 'macos-latest' }} | |
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 | |
# NOTE: Self-hosted runners should already have postgres installed | |
# - name: Install postgres (Ubuntu arm64) | |
# if: ${{ matrix.os == 'ubuntu-arm64' }} | |
# shell: bash | |
# run: | | |
# sudo apt install libpq-dev | |
- name: Remove unused apps (MacOS arm64) | |
if: ${{ matrix.os == 'macos-latest' }} | |
continue-on-error: true | |
shell: bash | |
run: | | |
# MacOS arm64 runner only has 14GB avaialble, which is too small for our builds, so removing unused softwared. | |
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 }} 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 | |
- name: Rename binaries for ${{ matrix.os }} | |
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.extention }} ${{ env.TMP_BUILD_DIR }}/${binary}${{ env.extention }} | |
done | |
tar -cvzf ./tmp/iota-${{ env.iota_tag }}-${{ env.os_type }}.tgz -C ${{ env.TMP_BUILD_DIR }} . | |
# - name: Publish Windows iota binary to Chocolatey | |
# if: ${{ matrix.os == 'windows-latest' && contains(env.iota_tag, 'testnet') }} | |
# 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_tag }}/iota-${{ env.iota_tag }}-windows-x86_64.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_version }} configuration=release | |
# choco apikey --api-key ${{ secrets.CHOCO_API_KEY }} --source https://push.chocolatey.org/ | |
# choco push iota.${{ env.iota_version }}.nupkg --source https://push.chocolatey.org/ | |
- name: Upload release artifacts for ${{ matrix.os }} platform | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # pin@v4 | |
with: | |
name: iota-binaries-${{ matrix.os }} | |
if-no-files-found: error | |
path: | | |
./tmp/iota-${{ env.iota_tag }}-${{ env.os_type }}.tgz | |
- name: Attach artifacts to ${{ env.iota_tag }} release in GH | |
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # pin@v2 | |
with: | |
tag_name: ${{ env.iota_tag }} | |
files: | | |
./tmp/iota-${{ env.iota_tag }}-${{ env.os_type }}.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_tag, 'testnet') || contains( github.ref, 'testnet') }} | |
# steps: | |
# - name: Clean up tag name ${{ env.TAG_NAME }} | |
# shell: bash | |
# run: | | |
# echo "iota_tag=$(echo ${{ env.TAG_NAME }} | sed s/'refs\/tags\/'//)" >> $GITHUB_ENV | |
# echo "versionless_tag=$(echo ${{ env.TAG_NAME }} | sed s/'refs\/tags\/'// | sed s/'testnet\-v'//)" >> $GITHUB_ENV | |
# - uses: mislav/bump-homebrew-formula-action@b3327118b2153c82da63fd9cbf58942146ee99f0 # pin@v3 | |
# with: | |
# 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: | |
# # https://github.com/settings/tokens/new?scopes=public_repo,workflow | |
# COMMITTER_TOKEN: ${{ secrets.HOMEBREW_GH_FORMULA_BUMP }} | |
# | |
# # Tag all iota images with release tag, so that they can be easily found | |
# tag-docker-hub-images: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Dispatch Tagging of images in DockerHub, in MystenLabs/sui-operations | |
# uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # pin@v3.0.0 | |
# with: | |
# repository: iotaledger/iota | |
# token: ${{ secrets.DOCKER_BINARY_BUILDS_DISPATCH }} | |
# event-type: tag-docker-images | |
# client-payload: '{"iota_commit": "${{ github.sha }}", "repo_name": "all", "tag": "${{ env.TAG_NAME }}"}' |