Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into jeremy-bump-rust-ve…
Browse files Browse the repository at this point in the history
…rsion
  • Loading branch information
nanocryk committed Sep 27, 2024
2 parents 21f2a89 + c6eb23b commit 8bf0d04
Show file tree
Hide file tree
Showing 95 changed files with 6,471 additions and 458 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/prepare-tanssi-relay-binary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Prepare Optimized Dancelight Binary Draft (internal only)

# The code (like generate-release-body) will be taken from the tag version, not master
on:
workflow_dispatch:
inputs:
sha:
description: full sha to build the binary from
required: true

jobs:
####### Building binaries #######

build-binary:
runs-on: bare-metal
strategy:
matrix:
cpu: ["", "skylake"]
env:
RUSTFLAGS: "-C target-cpu=${{ matrix.cpu }}"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.sha }}
- name: Setup Rust toolchain
run: rustup show
- name: Build Node
run: cargo build --profile=production -p tanssi-relay
- name: Save dancelight binary
if: ${{ matrix.cpu == '' }}
run: |
mkdir -p binaries
cp target/production/tanssi-relay binaries/tanssi-relay
- name: Save dancelight custom binary
if: ${{ matrix.cpu != '' }}
run: |
mkdir -p binaries
cp target/production/tanssi-relay binaries/tanssi-relay-${{matrix.cpu}}
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: binaries
path: binaries

####### Prepare the release draft #######
docker-tanssi:
runs-on: ubuntu-latest
needs: ["build-binary"]
strategy:
matrix:
image: ["tanssi-relay"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.sha }}
- uses: actions/download-artifact@v3
with:
name: binaries
path: build
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=moondancelabs/${{matrix.image}}
SHA8="$(git log -1 --format="%H" | cut -c1-8)"
TAGS="${DOCKER_IMAGE}:sha-${SHA8}-opt"
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
driver-opts: |
image=moby/buildkit:master
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/${{matrix.image}}.Dockerfile
platforms: linux/amd64
push: true
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Tag it with moondance-labs for 6 month
run: |
MOONDANCELABS_TAG=`echo "${{ steps.prep.outputs.tags }}"`
docker pull ${{ steps.prep.outputs.tags }}
docker tag ${{ steps.prep.outputs.tags }} $MOONDANCELABS_TAG
docker push $MOONDANCELABS_TAG
133 changes: 133 additions & 0 deletions .github/workflows/publish-binary-tannsi-relay.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Publish Dancelight Binary Draft

# The code (like generate-release-body) will be taken from the tag version, not master
on:
workflow_dispatch:
inputs:
from:
description: tag (ex. v0.8.3) to retrieve commit diff from
required: true
to:
description: tag (ex. v0.9.0) to generate release note and srtool runtimes from
required: true

jobs:
####### Building binaries #######
setup-scripts:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Upload tools
uses: actions/upload-artifact@v4
with:
name: original-tools
path: tools

build-binary:
needs: ["setup-scripts"]
runs-on: self-hosted
strategy:
matrix:
cpu: ["", "skylake", "znver3"]
env:
RUSTFLAGS: "-C target-cpu=${{ matrix.cpu }}"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.to }}
- name: Setup Rust toolchain
run: rustup show
- name: Build Node
run: cargo build --profile=production -p tanssi-relay
- name: Save dancelight binary
if: ${{ matrix.cpu == '' }}
run: |
mkdir -p binaries
cp target/production/tanssi-relay binaries/tanssi-relay
- name: Save dancelight custom binary
if: ${{ matrix.cpu != '' }}
run: |
mkdir -p binaries
cp target/production/tanssi-relay binaries/tanssi-relay-${{matrix.cpu}}
- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: binaries
path: binaries

####### Prepare the release draft #######
publish-draft-release:
runs-on: ubuntu-latest
needs: ["build-binary"]
outputs:
release_url: ${{ steps.create-release.outputs.html_url }}
asset_upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.to }}
fetch-depth: 0
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Download Original Tools
uses: actions/download-artifact@v4
with:
name: original-tools
path: original-tools
- name: Generate release body
id: generate-release-body
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: original-tools
run: |
yarn
yarn -s run ts-node github/generate-release-body.ts --owner "${{ github.repository_owner }}" --repo "$(basename ${{ github.repository }})" --from ${{ github.event.inputs.from }} --to ${{ github.event.inputs.to }} --srtool-report-folder '../build/' > ../body.md
- name: Create draft release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.to }}
release_name: Tanssi ${{ github.event.inputs.to }}
body_path: body.md
draft: true

####### Upload Binaries #######

upload-binaries:
runs-on: ubuntu-latest
needs: ["build-binary", "publish-draft-release"]
strategy:
matrix:
cpu: ["", "skylake", "znver3"]
node: ["tanssi-relay"]
steps:
- uses: actions/download-artifact@v3
with:
name: binaries
path: build
- name: Upload dancelight
uses: actions/upload-release-asset@v1
if: ${{ matrix.cpu == '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-draft-release.outputs.asset_upload_url }}
asset_path: build/${{matrix.node}}
asset_name: ${{matrix.node}}
asset_content_type: application/octet-stream
- name: Upload dancelight
uses: actions/upload-release-asset@v1
if: ${{ matrix.cpu != '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-draft-release.outputs.asset_upload_url }}
asset_path: build/${{matrix.node}}-${{matrix.cpu}}
asset_name: ${{matrix.node}}-${{matrix.cpu}}
asset_content_type: application/octet-stream
75 changes: 75 additions & 0 deletions .github/workflows/publish-docker-tannsi-relay.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Publish Dancelight Docker

on:
workflow_dispatch:
inputs:
tag:
description: tag (ex. v0.8.3) to publish on docker
required: true

env:
BASE_URL: https://github.com/moondance-labs/tanssi/releases/download
jobs:
tag-docker:
runs-on: ubuntu-latest
strategy:
matrix:
image: [
{ name: "starlight", file_name: "tanssi-relay" },
]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Download files
run: |
mkdir -p build
VERSION="${{ github.event.inputs.tag }}"
wget "${{ env.BASE_URL }}/$VERSION/${{ matrix.image.file_name }}" -O build/${{ matrix.image.file_name }}
wget "${{ env.BASE_URL }}/$VERSION/${{ matrix.image.file_name }}-skylake" -O build/${{ matrix.image.file_name }}-skylake
wget "${{ env.BASE_URL }}/$VERSION/${{ matrix.image.file_name }}-znver3" -O build/${{ matrix.image.file_name }}-znver3
- name: push to docker
run: |
DOCKER_IMAGE=moondancelabs/${{matrix.image.name}}
VERSION="${{ github.event.inputs.tag }}"
COMMIT=`git rev-list -n 1 '${{ github.event.inputs.tag }}'`
SHA=sha-${COMMIT::8}
echo using "${DOCKER_IMAGE}:${SHA} as base image"
echo building "${DOCKER_IMAGE}:${VERSION}"
docker build \
--build-arg DOCKER_IMAGE="$DOCKER_IMAGE" \
--build-arg SHA="$SHA" \
-f docker/${{matrix.image.name}}.Dockerfile \
-t "${DOCKER_IMAGE}:${VERSION}" \
.
echo tagging "${DOCKER_IMAGE}:${VERSION}"
docker push "${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MINOR=${VERSION%.*}
echo tagging "${DOCKER_IMAGE}:${MINOR}"
docker tag "${DOCKER_IMAGE}:${VERSION}" "${DOCKER_IMAGE}:${MINOR}"
docker push "${DOCKER_IMAGE}:${MINOR}"
MAJOR=${MINOR%.*}
echo tagging "${DOCKER_IMAGE}:${MAJOR}"
docker tag "${DOCKER_IMAGE}:${VERSION}" "${DOCKER_IMAGE}:${MAJOR}"
docker push "${DOCKER_IMAGE}:${MAJOR}"
echo tagging "${DOCKER_IMAGE}:${SHA}"
docker tag "${DOCKER_IMAGE}:${VERSION}" "${DOCKER_IMAGE}:${SHA}"
docker push "${DOCKER_IMAGE}:${SHA}"
echo tagging "${DOCKER_IMAGE}:latest"
docker tag "${DOCKER_IMAGE}:${VERSION}" "${DOCKER_IMAGE}:latest"
docker push "${DOCKER_IMAGE}:latest"
fi
6 changes: 5 additions & 1 deletion .github/workflows/publish-runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ on:
- templates-only
- simple-template-only
- frontier-template-only
- dancelight-only
- run-all

jobs:
Expand Down Expand Up @@ -58,6 +59,7 @@ jobs:
flashbox='{"runtime_name": "flashbox","runtime_path" : "./runtime/flashbox/src/lib.rs"}'
frontier_template='{"runtime_name": "frontier-template","runtime_path" : "./container-chains/runtime-templates/frontier/src/lib.rs"}'
simple_template='{"runtime_name": "simple-template","runtime_path" : "./container-chains/runtime-templates/simple/src/lib.rs"}'
dancelight='{"runtime_name": "dancelight","runtime_path" : "./solo-chains/runtime/dancelight/src/lib.rs"}'
if [[ ${{ github.event.inputs.chains }} = "tanssi-only" ]]; then
echo "matrix_tests=[$dancebox, $flashbox]" >> $GITHUB_OUTPUT
Expand All @@ -71,8 +73,10 @@ jobs:
echo "matrix_tests=[$simple_template]" >> $GITHUB_OUTPUT
elif [[ ${{ github.event.inputs.chains }} = "frontier-template-only" ]]; then
echo "matrix_tests=[$frontier_template]" >> $GITHUB_OUTPUT
elif [[ ${{ github.event.inputs.chains }} = "dancelight-only" ]]; then
echo "matrix_tests=[$dancelight]" >> $GITHUB_OUTPUT
else
echo "matrix_tests=[$dancebox, $flashbox, $simple_template, $frontier_template]" >> $GITHUB_OUTPUT
echo "matrix_tests=[$dancebox, $flashbox, $simple_template, $frontier_template, $dancelight]" >> $GITHUB_OUTPUT
fi
build-srtool-runtimes:
needs: ["setup-scripts", "matrix_prep"]
Expand Down
Loading

0 comments on commit 8bf0d04

Please sign in to comment.