Skip to content

Commit

Permalink
add binaries build (#3)
Browse files Browse the repository at this point in the history
Signed-off-by: kogeler <[email protected]>
  • Loading branch information
kogeler authored Sep 27, 2023
1 parent 8836212 commit c21bb08
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 14 deletions.
92 changes: 83 additions & 9 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,34 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

RELEASE_REF: refs/heads/main
jobs:
docker-images:
build-docker-images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image-name: ${{ steps.env-vars.outputs.image-name }}
strategy:
fail-fast: false
matrix:
debian-versions: [buster, bullseye, bookworm]
debian-versions: [bullseye, bookworm]
rust-versions: [1.72.0]
clang-versions: [15, 16]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set environmental variables
id: env-vars
run: |
echo "FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:debian-${{ matrix.debian-versions }}-rust-${{ matrix.rust-versions }}-clang-${{ matrix.clang-versions }}" >> $GITHUB_ENV
echo "FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:debian-${{ matrix.debian-versions }}-rust-${{ matrix.rust-versions }}-clang-${{ matrix.clang-versions }}" >> "$GITHUB_ENV"
echo "image-name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" >> "$GITHUB_OUTPUT"
echo "NODE_GIT_REF=$(cat release-version.txt | tr -d '\n')" >> "$GITHUB_ENV"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to Container registry
uses: docker/login-action@v3
with:
Expand All @@ -50,7 +55,7 @@ jobs:
push: false
load: true
labels: ${{ steps.meta.outputs.labels }}
build-args: |
build-args: |
DEBIAN_VERSION=${{ matrix.debian-versions }}
RUST_STABLE_VERSION=${{ matrix.rust-versions }}
CLANG_VERSION=${{ matrix.clang-versions }}
Expand All @@ -66,8 +71,77 @@ jobs:
pull: false
build-args: |
IMAGE_VERSION=image-to-test:latest
GIT_REF=polkadot-v1.1.0
GIT_REF=${{ env.NODE_GIT_REF }}
tags: test-build-image
- name: Push Docker image
if: ${{ github.ref == 'refs/heads/main' }}
if: ${{ github.ref == env.RELEASE_REF }}
run: docker push ${{ env.FULL_IMAGE_NAME }}
build-binaries:
runs-on: ubuntu-latest
needs: [build-docker-images]
permissions:
contents: write
container:
image: ${{ needs.build-docker-images.outputs.image-name }}:debian-${{ matrix.debian-versions }}-rust-${{ matrix.rust-versions }}-clang-${{ matrix.clang-versions }}
env:
RUSTFLAGS: "-C target-cpu=${{ matrix.rustc-targets }}"
GH_TOKEN: ${{ github.token }}
options: --user 0:0
strategy:
fail-fast: false
matrix:
debian-versions: [bullseye, bookworm]
rust-versions: [1.72.0]
clang-versions: [16]
rustc-targets: ["x86-64-v3", "x86-64-v4"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set environmental variables
run: |
NODE_GIT_REF=$(cat release-version.txt | tr -d '\n')
echo "NODE_GIT_REF=${NODE_GIT_REF}" >> $GITHUB_ENV
echo "BINARY_FILE_NAME=${NODE_GIT_REF}-${{ matrix.debian-versions }}-${{ matrix.rustc-targets }}" >> $GITHUB_ENV
echo "EXECUTE_WORKER_BINARY_FILE_NAME=${NODE_GIT_REF}-execute-worker-${{ matrix.debian-versions }}-${{ matrix.rustc-targets }}" >> $GITHUB_ENV
echo "PREPARE_WORKER_BINARY_FILE_NAME=${NODE_GIT_REF}-prepare-worker-${{ matrix.debian-versions }}-${{ matrix.rustc-targets }}" >> $GITHUB_ENV
git config --global --add safe.directory $(pwd)
- name: Checkout polkadot-sdk repository
uses: actions/checkout@v4
with:
repository: paritytech/polkadot-sdk
path: polkadot-sdk
ref: ${{ env.NODE_GIT_REF }}
- name: Build binaries
run: |
cd polkadot-sdk/polkadot
cargo build --release --target x86_64-unknown-linux-gnu
ls /opt/cargo_target/x86_64-unknown-linux-gnu/release
- name: "Create release"
if: ${{ github.ref == env.RELEASE_REF }}
uses: "actions/github-script@v6"
with:
script: |
try {
const response = await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: process.env.NODE_GIT_REF,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.NODE_GIT_REF,
});
} catch (error) {
core.notice(error.message);
}
- name: Upload binaries
if: ${{ github.ref == env.RELEASE_REF }}
run: |
BINARIES_DIR=${CARGO_TARGET_DIR}/x86_64-unknown-linux-gnu/release
mv ${BINARIES_DIR}/polkadot ${BINARIES_DIR}/${BINARY_FILE_NAME}
mv ${BINARIES_DIR}/polkadot-execute-worker ${BINARIES_DIR}/${EXECUTE_WORKER_BINARY_FILE_NAME}
mv ${BINARIES_DIR}/polkadot-prepare-worker ${BINARIES_DIR}/${PREPARE_WORKER_BINARY_FILE_NAME}
ls ${BINARIES_DIR}
gh release upload ${{ env.NODE_GIT_REF }} ${BINARIES_DIR}/${BINARY_FILE_NAME}
gh release upload ${{ env.NODE_GIT_REF }} ${BINARIES_DIR}/${EXECUTE_WORKER_BINARY_FILE_NAME}
gh release upload ${{ env.NODE_GIT_REF }} ${BINARIES_DIR}/${PREPARE_WORKER_BINARY_FILE_NAME}
5 changes: 3 additions & 2 deletions dockerfiles/Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ RUN set -eux && \
apt-get -y update && \
apt-get install --no-install-recommends -y \
# tools
curl ca-certificates git bash sudo nano \
curl ca-certificates git bash sudo nano gh \
# compilers
build-essential libclang-dev \
# dependencies
protobuf-compiler \
# cross
# cross compiler
g++-aarch64-linux-gnu libc6-dev-arm64-cross && \
rm -rf /var/lib/apt/lists/*

Expand All @@ -43,6 +43,7 @@ USER rust
# Install rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path --default-toolchain ${RUST_STABLE_VERSION} && \
rustup target add aarch64-unknown-linux-gnu --toolchain ${RUST_STABLE_VERSION}
WORKDIR /home/rust

ENTRYPOINT ["/bin/bash"]

8 changes: 5 additions & 3 deletions dockerfiles/Dockerfile.amd64
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ ENV RUST_BACKTRACE=1
# Install dependencies
RUN set -eux && \
apt-get -y update && \
apt-get install --no-install-recommends -y curl ca-certificates && \
apt-get install --no-install-recommends -y curl ca-certificates apt-transport-https && \
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \
echo "deb http://apt.llvm.org/${DEBIAN_VERSION}/ llvm-toolchain-${DEBIAN_VERSION}-$CLANG_VERSION main" >> /etc/apt/sources.list.d/llvm-toolchain-${DEBIAN_VERSION}-$CLANG_VERSION.list && \
echo "deb https://apt.llvm.org/${DEBIAN_VERSION}/ llvm-toolchain-${DEBIAN_VERSION}-$CLANG_VERSION main" >> /etc/apt/sources.list.d/llvm-toolchain-${DEBIAN_VERSION}-$CLANG_VERSION.list && \
echo "deb https://deb.debian.org/debian ${DEBIAN_VERSION}-backports main" >> /etc/apt/sources.list.d/${DEBIAN_VERSION}-backports.list && \
apt-get -y update && \
apt-get install --no-install-recommends -y \
# tools
git bash sudo nano \
git bash sudo nano gh \
# compilers
clang-$CLANG_VERSION lldb-$CLANG_VERSION lld-$CLANG_VERSION libclang-$CLANG_VERSION-dev make \
# dependencies
Expand All @@ -46,5 +47,6 @@ run chown -R rust:rust ${RUSTUP_HOME} ${CARGO_HOME} ${CARGO_TARGET_DIR}
USER rust
# Install rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path --default-toolchain ${RUST_STABLE_VERSION}
WORKDIR /home/rust

ENTRYPOINT ["/bin/bash"]
1 change: 1 addition & 0 deletions release-version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
polkadot-v1.1.0

0 comments on commit c21bb08

Please sign in to comment.