-
Notifications
You must be signed in to change notification settings - Fork 1
148 lines (146 loc) · 5.86 KB
/
docker-images.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Build and push Docker image
on:
push:
branches:
pull_request:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
RELEASE_REF: refs/heads/main
jobs:
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: [bullseye, bookworm]
rust-versions: [1.77.2]
clang-versions: [17, 18]
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 "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: Log in to Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: dockerfiles
file: dockerfiles/Dockerfile.amd64
push: false
load: true
labels: ${{ steps.meta.outputs.labels }}
build-args: |
DEBIAN_VERSION=${{ matrix.debian-versions }}
RUST_STABLE_VERSION=${{ matrix.rust-versions }}
CLANG_VERSION=${{ matrix.clang-versions }}
tags: ${{ env.FULL_IMAGE_NAME }},image-to-test:latest
- name: Switch to default Docker builder
run: docker buildx use default
- name: Build node to test Docker image
uses: docker/build-push-action@v5
with:
context: dockerfiles
file: dockerfiles/Dockerfile.test
push: false
pull: false
build-args: |
IMAGE_VERSION=image-to-test:latest
GIT_REF=${{ env.NODE_GIT_REF }}
tags: test-build-image
- name: Push Docker image
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.77.2]
clang-versions: [17, 18]
rustc-targets: ["x86-64-v2", "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
ENV_VERSION="debian-${{ matrix.debian-versions }}-rust-${{ matrix.rust-versions }}-clang-${{ matrix.clang-versions }}-${{ matrix.rustc-targets }}"
echo "BINARY_FILE_NAME=${NODE_GIT_REF}-${ENV_VERSION}" >> $GITHUB_ENV
echo "EXECUTE_WORKER_BINARY_FILE_NAME=${NODE_GIT_REF}-execute-worker-${ENV_VERSION}" >> $GITHUB_ENV
echo "PREPARE_WORKER_BINARY_FILE_NAME=${NODE_GIT_REF}-prepare-worker-${ENV_VERSION}" >> $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}