Files
nomos-node/.github/workflows/prepare-release.yml

213 lines
8.3 KiB
YAML

name: Prepare release draft with built binaries
on:
workflow_dispatch:
inputs:
release-type:
description: Type of release to prepare
required: true
type: choice
options:
- release
- release-candidate
concurrency:
group: ${{ github.workflow }}@${{ github.ref_name }}
cancel-in-progress: true
env:
TEST_TAG_NAME: release-ci-test
jobs:
configure-version:
name: Configure release version
if: ${{ github.ref_type == 'tag' }}
runs-on: ubuntu-latest
outputs:
version: ${{ steps.define-version.outputs.version }}
is_prerelease: ${{ steps.define-version.outputs.is_prerelease }}
steps:
# Take the version of the tag from which the workflow is dispatched, or use `0.0.0` for test runs with the `release-ci-test` tag.
- name: Define version
id: define-version
env:
TAG_NAME: ${{ github.ref_name }}
RELEASE_TYPE: ${{ inputs.release-type }}
run: |
if [[ "$TAG_NAME" == "${{ env.TEST_TAG_NAME }}" ]]; then
echo "Test workflow run. Setting version to 0.0.0 for testing."
VERSION=0.0.0
elif [[ "$RELEASE_TYPE" == "release" && "$TAG_NAME" =~ ^([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
echo "Release workflow run for tag '$TAG_NAME'. Setting version to '$TAG_NAME'."
VERSION="$TAG_NAME"
elif [[ "$RELEASE_TYPE" == "release-candidate" && "$TAG_NAME" =~ ^([0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+)$ ]]; then
echo "Release workflow run for tag '$TAG_NAME'. Setting version to '$TAG_NAME'."
VERSION="$TAG_NAME"
else
echo "Tag name '$TAG_NAME' is not valid for release type '$RELEASE_TYPE'. It must either be '${{ env.TEST_TAG_NAME }}', 'X.Y.Z' for 'release', or 'X.Y.Z-rc.N' for 'release-candidate'."
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "is_prerelease=$([[ "$RELEASE_TYPE" == "release-candidate" ]] && echo true || echo false)" >> $GITHUB_OUTPUT
build:
name: "Build and tar binaries for ${{ matrix.platform.os-display }} (${{ matrix.platform.arch }})"
needs: configure-version
runs-on: ${{ matrix.platform.builder }}
env:
VERSION: ${{ needs.configure-version.outputs.version }}
strategy:
matrix:
platform:
- os: linux
os-display: Linux
arch: x86_64
builder: ubuntu-24.04
target_triple: x86_64-unknown-linux-gnu
- os: linux
os-display: Linux
arch: aarch64
builder: ubuntu-24.04-arm
target_triple: aarch64-unknown-linux-gnu
- os: macos
os-display: MacOS
arch: aarch64
builder: macos-14
target_triple: aarch64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # Version 4.2.2
- name: Add the target triple
run: rustup target add ${{ matrix.platform.target_triple }}
- name: Build node binary
run: cargo build -p logos-blockchain-node --release --locked --target ${{ matrix.platform.target_triple }}
- name: Tar node binary
run: tar -czf logos-blockchain-node-${{ matrix.platform.os }}-${{ matrix.platform.arch }}-${{ needs.configure-version.outputs.version }}.tar.gz -C target/${{ matrix.platform.target_triple }}/release logos-blockchain-node
- name: Upload binary tar (${{ matrix.platform.arch }})
uses: actions/upload-artifact@6027e3dd177782cd8ab9af838c04fd81a07f1d47 # Version 4.6.2
with:
name: logos-blockchain-node-${{ matrix.platform.os }}-${{ matrix.platform.arch }}-${{ needs.configure-version.outputs.version }}
path: logos-blockchain-node-${{ matrix.platform.os }}-${{ matrix.platform.arch }}-${{ needs.configure-version.outputs.version }}.tar.gz
if-no-files-found: error
create-draft-release:
name: Create draft release
needs:
- configure-version
- build
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.configure-version.outputs.version }}
IS_PRERELEASE: ${{ needs.configure-version.outputs.is_prerelease }}
outputs:
upload_url: ${{ steps.create-draft-release.outputs.upload_url }}
steps:
- name: Checkout
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # Version 4.2.2
- name: Prepare release body with the module version, bootstrap peers, and release candidate-specific disclaimers
run: |
set -euo pipefail
TEMPLATE=.github/release/release-content.md
DISCLAIMER_FILE=.github/release/rc-disclaimer.md
OUTPUT=.github/release/release-content.generated.md
MODULE_VERSION_PLACEHOLDER='{{BLOCKCHAIN_MODULE_VERSION}}'
INITIAL_PEERS_PLACEHOLDER='{{INITIAL_PEERS}}'
for PLACEHOLDER in "$MODULE_VERSION_PLACEHOLDER" "$INITIAL_PEERS_PLACEHOLDER"; do
if ! grep -qF "$PLACEHOLDER" "$TEMPLATE"; then
echo "'$TEMPLATE' does not contain the '$PLACEHOLDER' placeholder. It must be present so the release notes match the release being prepared."
exit 1
fi
done
# The `blockchain_module` package is published under the same version as the node, for both
# releases and release candidates. Only the network they bootstrap against differs.
if [[ "$IS_PRERELEASE" == "true" ]]; then
PEERS_FILE=.github/release/devnet-peers.txt
else
PEERS_FILE=.github/release/testnet-peers.txt
fi
# `sed`'s `r` command ignores a missing file, which would silently produce an empty peer list.
if [[ ! -s "$PEERS_FILE" ]]; then
echo "'$PEERS_FILE' is missing or empty. It must list the bootstrap peers to inject into the release notes."
exit 1
fi
echo "Setting '$MODULE_VERSION_PLACEHOLDER' to '$VERSION' and '$INITIAL_PEERS_PLACEHOLDER' to the contents of '$PEERS_FILE'."
sed -e "s|$MODULE_VERSION_PLACEHOLDER|$VERSION|g" \
-e "/$INITIAL_PEERS_PLACEHOLDER/r $PEERS_FILE" \
-e "/$INITIAL_PEERS_PLACEHOLDER/d" \
"$TEMPLATE" > "$OUTPUT"
if grep -n '{{' "$OUTPUT"; then
echo "'$OUTPUT' still contains unsubstituted placeholders (listed above)."
exit 1
fi
if [[ "$IS_PRERELEASE" == "true" ]]; then
{ cat "$DISCLAIMER_FILE"; echo; cat "$OUTPUT"; } > "${OUTPUT}.tmp"
mv "${OUTPUT}.tmp" "$OUTPUT"
fi
- name: Create Draft Release
uses: actions/create-release@4c11c9fe1dcd9636620a16455165783b20fc7ea0 # Version 1.1.4
id: create-draft-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: Logos Blockchain Node ${{ env.VERSION }}
body_path: .github/release/release-content.generated.md
draft: true
prerelease: ${{ env.IS_PRERELEASE }}
upload-binaries:
name: Upload binaries to release
needs:
- configure-version
- create-draft-release
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- os: linux
arch: x86_64
- os: linux
arch: aarch64
- os: macos
arch: aarch64
env:
UPLOAD_URL: ${{ needs.create-draft-release.outputs.upload_url }}
BINARY_NAME: logos-blockchain-node-${{ matrix.platform.os }}-${{ matrix.platform.arch }}-${{ needs.configure-version.outputs.version }}
DOWNLOAD_DIRECTORY: binaries
steps:
- name: Download artifact
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # Version 4.2.1
with:
name: ${{ env.BINARY_NAME }}
path: ${{ env.DOWNLOAD_DIRECTORY }}
merge-multiple: true
- name: Upload ${{ matrix.platform.os }} (${{ matrix.platform.arch }}) to release
uses: actions/upload-release-asset@ef2adfe8cb8ebfa540930c452c576b3819990faa # Version 1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: ${{ env.DOWNLOAD_DIRECTORY }}/${{ env.BINARY_NAME }}.tar.gz
asset_name: ${{ env.BINARY_NAME }}.tar.gz
asset_content_type: application/gzip