Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker build and push - part 1 #56

Merged
merged 160 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 144 commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
491c51c
merge test 1
magick93 Nov 25, 2024
4655e8a
update pr
magick93 Nov 25, 2024
855d735
disable jobs
magick93 Nov 25, 2024
e5f98f6
Merge pull request #1 from magick93/pr_test_1
magick93 Nov 25, 2024
bea39a1
branch check
magick93 Nov 25, 2024
4f2dc68
Merge pull request #3 from magick93/pr_test_1
magick93 Nov 25, 2024
72409c0
check when merging to stable
magick93 Nov 25, 2024
51b7443
attempt to use hcv
magick93 Nov 26, 2024
6d6a70f
Merge branch 'Allow-merge-to-stable-when-required-#52' into unstable
magick93 Nov 26, 2024
36e937b
tmp comment out
magick93 Nov 26, 2024
ca2ff87
Merge pull request #2 from magick93/unstable
magick93 Nov 26, 2024
1838ec7
tmp rm CROSS_FEATURES
magick93 Nov 26, 2024
d509ae3
Merge pull request #5 from magick93/unstable
magick93 Nov 26, 2024
229740b
upgrade
magick93 Nov 26, 2024
cde21a8
simplify
magick93 Nov 26, 2024
77342f4
Merge pull request #6 from magick93/unstable
magick93 Nov 26, 2024
03c689b
use GH_TOKEN
magick93 Nov 26, 2024
6080495
Merge pull request #7 from magick93/unstable
magick93 Nov 26, 2024
2b98998
hardcode docker repo, set dockerfile location
magick93 Nov 26, 2024
fe27047
Merge pull request #8 from magick93/unstable
magick93 Nov 26, 2024
cb96e77
use correct dir
magick93 Nov 26, 2024
55145ee
Merge pull request #9 from magick93/unstable
magick93 Nov 26, 2024
eb2d461
update rust and path
magick93 Nov 26, 2024
a97b785
Merge pull request #10 from magick93/unstable
magick93 Nov 26, 2024
33f3a57
use Cargo.toml as source of truth
magick93 Nov 26, 2024
0fc6e37
Merge pull request #11 from magick93/unstable
magick93 Nov 26, 2024
3867484
fix path for toml_reader.sh
magick93 Nov 26, 2024
5249158
Merge pull request #12 from magick93/unstable
magick93 Nov 26, 2024
e508fa1
debugging
magick93 Nov 26, 2024
27b7155
Merge pull request #13 from magick93/unstable
magick93 Nov 26, 2024
0890343
corrected path
magick93 Nov 26, 2024
145ffae
Merge pull request #14 from magick93/unstable
magick93 Nov 26, 2024
ef2e799
debugging
magick93 Nov 26, 2024
89d32f9
Merge pull request #15 from magick93/unstable
magick93 Nov 26, 2024
35b5db9
use after actions/checkout@v4
magick93 Nov 26, 2024
ee9e8ff
Merge pull request #16 from magick93/unstable
magick93 Nov 26, 2024
71351c2
re-correcting dir
magick93 Nov 26, 2024
294d38d
Merge pull request #17 from magick93/unstable
magick93 Nov 26, 2024
5471473
assign rust version to GH_ENV
magick93 Nov 26, 2024
49de973
Merge pull request #18 from magick93/unstable
magick93 Nov 26, 2024
e8a62a6
remove test docker org
magick93 Nov 26, 2024
6909c5b
Merge pull request #19 from magick93/unstable
magick93 Nov 26, 2024
195d947
re-enable check-code
magick93 Nov 26, 2024
3d83330
rm temp file
magick93 Nov 26, 2024
7a0a0c5
Merge pull request #20 from magick93/docker_build_push_part1
magick93 Nov 27, 2024
f748823
update futures
magick93 Nov 27, 2024
732ed01
tmp workaround for remaining audit error
magick93 Nov 27, 2024
cf3a494
Merge pull request #22 from magick93/docker_build_push_part1
magick93 Nov 27, 2024
e919c3f
Merge pull request #21 from magick93/unstable
magick93 Nov 27, 2024
5e0d751
update hcv path
magick93 Nov 27, 2024
c941ab0
Merge pull request #23 from magick93/docker_build_push_part1
magick93 Nov 27, 2024
cd202e6
Merge pull request #24 from magick93/unstable
magick93 Nov 27, 2024
6a57a37
try another hcv path
magick93 Nov 27, 2024
d80a030
Merge pull request #25 from magick93/docker_build_push_part1
magick93 Nov 27, 2024
52c370d
Merge pull request #26 from magick93/unstable
magick93 Nov 27, 2024
43bd52e
Merge branch 'unstable' into stable
magick93 Nov 27, 2024
e615120
Add extract-version workflow and refactor docker workflow to use it
magick93 Nov 27, 2024
09fd733
Merge pull request #27 from magick93/reusable_workflows
magick93 Nov 27, 2024
6727dc4
Merge pull request #28 from magick93/unstable
magick93 Nov 27, 2024
2d98a2d
Refactor Docker workflow to support single and multi-architecture builds
magick93 Nov 27, 2024
9533df2
Enhance extract-version workflow to default to 'latest' and add debug…
magick93 Dec 1, 2024
ae91231
Refactor Docker workflow to improve architecture support and add debu…
magick93 Dec 3, 2024
83fa758
Merge pull request #29 from magick93/releases-from-docker
magick93 Dec 3, 2024
135890f
Merge pull request #30 from magick93/unstable
magick93 Dec 3, 2024
fee33f8
Refactor Docker workflow to enable multi-architecture builds and stre…
magick93 Dec 3, 2024
66ebb3b
Merge pull request #31 from magick93/releases-from-docker
magick93 Dec 3, 2024
75be9e3
Merge pull request #32 from magick93/unstable
magick93 Dec 3, 2024
bd2240d
rm jemalloc
magick93 Dec 3, 2024
11ee356
Merge pull request #33 from magick93/releases-from-docker
magick93 Dec 3, 2024
9d0a233
Merge pull request #34 from magick93/unstable
magick93 Dec 3, 2024
4c4c454
try with TARGETPLATFORM arg
magick93 Dec 3, 2024
8e71ed7
Merge pull request #35 from magick93/releases-from-docker
magick93 Dec 3, 2024
1f98a14
Merge pull request #36 from magick93/unstable
magick93 Dec 3, 2024
80fe1cd
Update Docker workflow to include architecture-specific tags and enab…
magick93 Dec 3, 2024
e773475
Merge pull request #37 from magick93/releases-from-docker
magick93 Dec 3, 2024
1cfb88b
Merge pull request #38 from magick93/unstable
magick93 Dec 3, 2024
ed1b6f6
disable buildx imagetools, add labels
magick93 Dec 3, 2024
0848426
Merge pull request #39 from magick93/releases-from-docker
magick93 Dec 3, 2024
61981ff
Merge pull request #40 from magick93/unstable
magick93 Dec 3, 2024
d9fec9e
enable md book, only run on sipg org
magick93 Dec 3, 2024
c69cbc2
Merge pull request #41 from magick93/releases-from-docker
magick93 Dec 3, 2024
b49cda3
Merge pull request #42 from magick93/unstable
magick93 Dec 3, 2024
eb7d032
fix yml formatting
magick93 Dec 3, 2024
f893bf0
Merge pull request #43 from magick93/releases-from-docker
magick93 Dec 3, 2024
d3fe7df
re-Implement linkcheck workflow for mdbook with conditional execution…
magick93 Dec 3, 2024
c9c3c56
Merge pull request #44 from magick93/releases-from-docker
magick93 Dec 3, 2024
11ba2fd
Add release, debug, and code quality test jobs to Docker workflow
magick93 Dec 3, 2024
ec342e5
Merge pull request #45 from magick93/releases-from-docker
magick93 Dec 3, 2024
78b9210
Merge pull request #46 from magick93/unstable
magick93 Dec 3, 2024
cb2bbcf
remove debugging
magick93 Dec 3, 2024
ebc6d86
remove debugging
magick93 Dec 3, 2024
5036e06
remove unneeded job
magick93 Dec 3, 2024
43685bb
Merge pull request #47 from magick93/releases-from-docker
magick93 Dec 3, 2024
bff054b
Merge pull request #48 from magick93/unstable
magick93 Dec 3, 2024
584f9f2
remove features
magick93 Dec 4, 2024
33abe8f
Merge pull request #49 from magick93/releases-from-docker
magick93 Dec 4, 2024
7aebdb9
Merge pull request #50 from magick93/unstable
magick93 Dec 4, 2024
6d6c38f
remove x86_64-windows architecture from release workflow due to issue…
magick93 Dec 4, 2024
d9b857a
Merge pull request #52 from magick93/releases-from-docker
magick93 Dec 4, 2024
9c6c8b2
Merge pull request #53 from magick93/unstable
magick93 Dec 4, 2024
69f1ef7
rename build job to support multi-architecture Docker builds
magick93 Dec 4, 2024
84525af
disable x86_64-windows architecture in release workflow due to issue #51
magick93 Dec 4, 2024
5538e18
Merge pull request #54 from magick93/releases-from-docker
magick93 Dec 4, 2024
6b02704
Merge pull request #55 from magick93/unstable
magick93 Dec 4, 2024
ef28593
Add mermaid support for our mdbook (#55)
AgeManning Dec 1, 2024
6013c0a
Add conditional check for repository owner in build workflow
magick93 Dec 4, 2024
21cb56b
Merge pull request #56 from magick93/book-condition
magick93 Dec 4, 2024
067778f
Add job to fail if pull request is a draft
magick93 Dec 4, 2024
de905f1
Update pull request trigger types in test suite workflow
magick93 Dec 4, 2024
897f4ee
Merge pull request #59 from magick93/test-pr-types
magick93 Dec 4, 2024
cc05929
Remove draft pull request failure job from test suite workflow
magick93 Dec 4, 2024
00859aa
Merge pull request #60 from magick93/test-pr-types
magick93 Dec 4, 2024
b0d67ae
Update Docker workflow to trigger on test suite completion
magick93 Dec 5, 2024
ba05463
Merge pull request #61 from magick93/on-tests-pass
magick93 Dec 5, 2024
6233bb7
Merge pull request #62 from magick93/unstable
magick93 Dec 5, 2024
6682f98
Temporarily disable check-code job in test suite workflow due to depe…
magick93 Dec 5, 2024
de4f13c
Remove release, debug, and code quality test jobs from Docker workflow
magick93 Dec 5, 2024
f1ad769
Merge pull request #63 from magick93/on-tests-pass
magick93 Dec 5, 2024
74461c9
Merge pull request #64 from magick93/unstable
magick93 Dec 5, 2024
7252933
rm on workflow_run
magick93 Dec 5, 2024
d4aab52
Merge pull request #65 from magick93/on-tests-pass
magick93 Dec 5, 2024
dc5ee60
Merge pull request #66 from magick93/unstable
magick93 Dec 5, 2024
9a3c481
Fix Docker workflow secret syntax for vault - hopefully
magick93 Dec 5, 2024
4994520
Merge pull request #67 from magick93/on-tests-pass
magick93 Dec 5, 2024
4731a9c
Merge pull request #68 from magick93/unstable
magick93 Dec 5, 2024
07490f1
Re-enable check-code job in test suite workflow
magick93 Dec 5, 2024
686ce90
Merge pull request #69 from magick93/on-tests-pass
magick93 Dec 5, 2024
39106a9
Merge branch 'unstable' into stable
magick93 Dec 5, 2024
b389092
disable jobs
magick93 Nov 25, 2024
81ea948
Merge pull request #70 from magick93/unstable
magick93 Dec 5, 2024
9b6e5cd
Merge pull request #71 from sigp/unstable
magick93 Dec 5, 2024
6b90833
update workflows to use ubuntu-22.04 as the runner environment
magick93 Dec 5, 2024
d8497dc
Merge pull request #73 from magick93/ubuntu-latest
magick93 Dec 6, 2024
b343219
add cargo update step to test suite workflow
magick93 Dec 6, 2024
5801ecf
Merge pull request #74 from magick93/unstable
magick93 Dec 6, 2024
0bc18ff
Merge pull request #76 from magick93/update-audit
magick93 Dec 6, 2024
25550d2
Merge pull request #77 from magick93/unstable
magick93 Dec 6, 2024
8ccf798
enable Windows runner in release workflow
magick93 Dec 6, 2024
27387cf
add x86_64-windows architecture back to release workflow
magick93 Dec 6, 2024
f8307a6
Merge pull request #78 from magick93/windows-rel
magick93 Dec 6, 2024
c892892
Merge pull request #79 from magick93/unstable
magick93 Dec 6, 2024
17acbd0
add conditional imports for Unix target family in environment module
magick93 Dec 6, 2024
25f2192
Merge pull request #80 from magick93/windows-rel
magick93 Dec 6, 2024
5d99284
Merge pull request #81 from magick93/unstable
magick93 Dec 6, 2024
dcd6f0c
Add Windows-specific shutdown signal handling
magick93 Dec 8, 2024
e55fedd
revert
magick93 Dec 8, 2024
7b32477
Add zcross to .gitignore
magick93 Dec 9, 2024
e335191
fmt
magick93 Dec 9, 2024
8dbb208
Merge branch 'unstable' into windows-shutdown
magick93 Dec 9, 2024
7afc4db
Merge branch 'windows-shutdown' into pr-56-review
magick93 Dec 11, 2024
303e3db
Merge branch 'stable' into pr-56-review
magick93 Dec 11, 2024
dd31f75
Remove RUSTSEC-2024-0399 ignore from cargo audit in Makefile
magick93 Dec 11, 2024
9874dd2
Downgrade futures dependency from 0.3.31 to 0.3.30 in Cargo.toml
magick93 Dec 11, 2024
84f7de4
Remove cargo update step from test suite workflow
magick93 Dec 11, 2024
323915b
Merge pull request #82 from magick93/pr-56-review
magick93 Dec 11, 2024
76780ae
Merge pull request #83 from magick93/unstable
magick93 Dec 11, 2024
0fcb735
Merge branch 'unstable' into stable
magick93 Dec 11, 2024
502e5d5
revert
magick93 Dec 11, 2024
f35765e
Merge branch 'unstable' into stable
magick93 Dec 16, 2024
a2ee16a
Merge remote-tracking branch 'upstream/unstable' into stable
magick93 Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/scripts/toml_reader.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# TOML Reader - A script to read values from simple TOML files
# Usage: ./toml_reader.sh <file_path> <section> <key>

get_section() {
# Function to get the section from a TOML file
# Parameters:
# $1 - TOML file path
# $2 - section name
local file="$1"
local section="$2"

sed -n "/^\[$section\]/,/^\[/p" "$file" | sed '$d'
}

get_toml_value() {
# Function to get a value from a TOML file
# Parameters:
# $1 - TOML file path
# $2 - section
# $3 - key
local file="$1"
local section="$2"
local key="$3"

get_section "$file" "$section" | grep "^$key " | cut -d "=" -f2- | tr -d ' "'
}

# Show usage if script is called directly
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
if [ "$#" -ne 3 ]; then
echo "Error: Incorrect number of arguments"
echo "Usage: $0 <file_path> <section> <key>"
echo "Example: $0 ./config.toml server_b domain"
exit 1
fi

# Check if file exists
if [ ! -f "$1" ]; then
echo "Error: File '$1' does not exist"
exit 1
fi

# Get the value
result=$(get_toml_value "$1" "$2" "$3")

# Check if value was found
if [ -z "$result" ]; then
echo "Error: No value found for section '[$2]' and key '$3'"
exit 1
fi

echo "$result"
fi
3 changes: 2 additions & 1 deletion .github/workflows/book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ concurrency:

jobs:
build-and-upload-to-s3:
if: github.repository_owner == 'sigp'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
Expand All @@ -33,4 +34,4 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'ap-southeast-2'
SOURCE_DIR: 'book/book'
SOURCE_DIR: 'book/book'
297 changes: 134 additions & 163 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,163 +1,134 @@
# TODO: Setup docker
# name: docker
#
# on:
# push:
# branches:
# - stable
# tags:
# - v*
#
# concurrency:
# group: ${{ github.workflow }}-${{ github.ref }}
# cancel-in-progress: true
#
# env:
# DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
# # Enable self-hosted runners for the sigp repo only.
# SELF_HOSTED_RUNNERS: ${{ github.repository == 'sigp/anchor' }}
#
# jobs:
# # Extract the VERSION which is either `latest` or `vX.Y.Z`, and the VERSION_SUFFIX
# # which is either empty or `-unstable`.
# #
# # It would be nice if the arch didn't get spliced into the version between `latest` and
# # `unstable`, but for now we keep the two parts of the version separate for backwards
# # compatibility.
# extract-version:
# runs-on: ubuntu-22.04
# steps:
# - name: Extract version (if stable)
# if: github.event.ref == 'refs/heads/stable'
# run: |
# echo "VERSION=latest" >> $GITHUB_ENV
# echo "VERSION_SUFFIX=" >> $GITHUB_ENV
# - name: Extract version (if unstable)
# if: github.event.ref == 'refs/heads/unstable'
# run: |
# echo "VERSION=latest" >> $GITHUB_ENV
# echo "VERSION_SUFFIX=-unstable" >> $GITHUB_ENV
# - name: Extract version (if tagged release)
# if: startsWith(github.event.ref, 'refs/tags')
# run: |
# echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV
# echo "VERSION_SUFFIX=" >> $GITHUB_ENV
# outputs:
# VERSION: ${{ env.VERSION }}
# VERSION_SUFFIX: ${{ env.VERSION_SUFFIX }}
# build-docker-single-arch:
# name: build-docker-${{ matrix.binary }}-${{ matrix.cpu_arch }}${{ matrix.features.version_suffix }}
# # Use self-hosted runners only on the sigp repo.
# runs-on: ${{ github.repository == 'sigp/anchor' && fromJson('["self-hosted", "linux", "release"]') || 'ubuntu-22.04' }}
# strategy:
# matrix:
# binary: [anchor]
# cpu_arch: [aarch64, x86_64]
# include:
# - profile: maxperf
#
# needs: [extract-version]
# env:
# VERSION: ${{ needs.extract-version.outputs.VERSION }}
# VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
# steps:
# - uses: actions/checkout@v4
# - name: Update Rust
# if: env.SELF_HOSTED_RUNNERS == 'false'
# run: rustup update stable
# - name: Dockerhub login
# run: |
# echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
#
# - name: Sets env vars for Anchor
# if: startsWith(matrix.binary, 'anchor')
# run: |
# echo "CROSS_FEATURES=gnosis,spec-minimal,slasher-lmdb,jemalloc" >> $GITHUB_ENV
#
# - name: Set `make` command for anchor
# if: startsWith(matrix.binary, 'anchor')
# run: |
# echo "MAKE_CMD=build-${{ matrix.cpu_arch }}" >> $GITHUB_ENV
#
# - name: Set `make` command for lcli
# if: startsWith(matrix.binary, 'lcli')
# run: |
# echo "MAKE_CMD=build-lcli-${{ matrix.cpu_arch }}" >> $GITHUB_ENV
#
# - name: Cross build binaries
# run: |
# cargo install cross
# env CROSS_PROFILE=${{ matrix.profile }} CROSS_FEATURES=${{ env.CROSS_FEATURES }} make ${{ env.MAKE_CMD }}
#
# - name: Make bin dir
# run: mkdir ./bin
#
# - name: Move cross-built binary into Docker scope
# run: mv ./target/${{ matrix.cpu_arch }}-unknown-linux-gnu/${{ matrix.profile }}/${{ matrix.binary }} ./bin
#
# - name: Map aarch64 to arm64 short arch
# if: startsWith(matrix.cpu_arch, 'aarch64')
# run: echo "SHORT_ARCH=arm64" >> $GITHUB_ENV
#
# - name: Map x86_64 to amd64 short arch
# if: startsWith(matrix.cpu_arch, 'x86_64')
# run: echo "SHORT_ARCH=amd64" >> $GITHUB_ENV;
#
# - name: Install QEMU
# if: env.SELF_HOSTED_RUNNERS == 'false'
# run: sudo apt-get update && sudo apt-get install -y qemu-user-static
#
# - name: Set up Docker Buildx
# if: env.SELF_HOSTED_RUNNERS == 'false'
# uses: docker/setup-buildx-action@v3
#
# - name: Build and push (Anchor)
# if: startsWith(matrix.binary, 'anchor')
# uses: docker/build-push-action@v5
# with:
# file: ./Dockerfile.cross
# context: .
# platforms: linux/${{ env.SHORT_ARCH }}
# push: true
# tags: |
# ${{ github.repository_owner}}/${{ matrix.binary }}:${{ env.VERSION }}-${{ env.SHORT_ARCH }}${{ env.VERSION_SUFFIX }}
#
# - name: Build and push (lcli)
# if: startsWith(matrix.binary, 'lcli')
# uses: docker/build-push-action@v5
# with:
# file: ./lcli/Dockerfile.cross
# context: .
# platforms: linux/${{ env.SHORT_ARCH }}
# push: true
#
# tags: |
# ${{ github.repository_owner}}/${{ matrix.binary }}:${{ env.VERSION }}-${{ env.SHORT_ARCH }}${{ env.VERSION_SUFFIX }}
#
#
# build-docker-multiarch:
# name: build-docker-${{ matrix.binary }}-multiarch
# runs-on: ubuntu-22.04
# strategy:
# matrix:
# binary: [anchor,
# lcli]
# needs: [build-docker-single-arch, extract-version]
# env:
# VERSION: ${{ needs.extract-version.outputs.VERSION }}
# VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
# steps:
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
#
# - name: Dockerhub login
# run: |
# echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
#
# - name: Create and push multiarch manifests
# run: |
# docker buildx imagetools create -t ${{ github.repository_owner}}/${{ matrix.binary }}:${VERSION}${VERSION_SUFFIX} \
# ${{ github.repository_owner}}/${{ matrix.binary }}:${VERSION}-arm64${VERSION_SUFFIX} \
# ${{ github.repository_owner}}/${{ matrix.binary }}:${VERSION}-amd64${VERSION_SUFFIX};
#
name: Docker build and push

on:
push:
branches:
- stable
tags:
- v*

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# Enable self-hosted runners for the sigp repo only.
SELF_HOSTED_RUNNERS: ${{ github.repository == 'sigp/anchor' }}
RUST_VERSION: '1.80.0'
SHORT_ARCH: 'amd64'
# Deny warnings in CI
RUSTFLAGS: "-D warnings -C debuginfo=0"
# Prevent Github API rate limiting
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
extract-version:
uses: ./.github/workflows/extract-version.yml


build-docker-multi-arch:
name: build-docker-anchor-${{ matrix.cpu_arch }}
runs-on: ${{ github.repository == 'sigp/anchor' && fromJson('["self-hosted", "linux", "release"]') || 'ubuntu-22.04' }}
strategy:
matrix:
cpu_arch: [aarch64, x86_64]
include:
- profile: maxperf

needs: [extract-version]
env:
VERSION: ${{ needs.extract-version.outputs.VERSION }}
VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
steps:

- name: Map aarch64 to arm64 short arch
if: startsWith(matrix.cpu_arch, 'aarch64')
run: echo "SHORT_ARCH=arm64" >> $GITHUB_ENV

- name: Map x86_64 to amd64 short arch
if: startsWith(matrix.cpu_arch, 'x86_64')
run: echo "SHORT_ARCH=amd64" >> $GITHUB_ENV


- name: Install Rust and Cargo
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
echo "PATH=$HOME/.cargo/bin:$PATH" >> $GITHUB_ENV


- name: cargo install cross
run: |
cargo install cross

# - uses: actions/checkout@v4
# - name: Update Rust
# if: env.SELF_HOSTED_RUNNERS == 'false'
# run: rustup update stable
- name: Checkout sources
uses: actions/checkout@v4

- name: Get rust-version
id: get-rust-version
run: |
echo "RUST_VERSION=$(./.github/scripts/toml_reader.sh ./anchor/Cargo.toml package rust-version)" >> $GITHUB_ENV

- name: Get latest version of stable Rust
run: echo "rust version is ${{ env.RUST_VERSION }}"

- name: Retrieve Docker credentials from Vault
uses: hashicorp/vault-action@v2
with:
url: https://vault.sigp.io
method: github
githubToken: ${{ secrets.GH_TOKEN }}
secrets: |
spesi_kv/data/dev/docker/anchor DOCKER_USERNAME ;
spesi_kv/data/dev/docker/anchor DOCKER_PASSWORD

- name: Dockerhub login
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these have changed. They are now DH_ORG and DH_KEY I think

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In these workflows we are not trusting github to responsibility protect the dockerhub token in perpetuity. Instead we give it on demand, and approval, via vault.
While it does use DOCKER_USERNAME and DOCKER_PASSWORD vars internally, the only variable that needs to be set in Github is to add your org token. See https://www.notion.so/sigp/HashiCorp-Vault-12a56eefb55e8023bb58de9d57cfe2b8


- name: Build binary
run: |
cargo install cross
env CROSS_PROFILE=${{ matrix.profile }} make build-${{ matrix.cpu_arch }}


- name: Set `make` command for anchor
run: |
echo "MAKE_CMD=build-${{ matrix.cpu_arch }}" >> $GITHUB_ENV

- name: Make bin dir
run: mkdir ./bin

- name: Move built binary into Docker scope
run: mv ./target/${{ matrix.cpu_arch }}-unknown-linux-gnu/${{ matrix.profile }}/anchor ./bin

- name: Install QEMU
if: env.SELF_HOSTED_RUNNERS == 'false'
run: sudo apt-get update && sudo apt-get install -y qemu-user-static

- name: Set up Docker Buildx
if: env.SELF_HOSTED_RUNNERS == 'false'
uses: docker/setup-buildx-action@v3

- name: Build and push
uses: docker/build-push-action@v5
with:
file: ./anchor/Dockerfile.cross
context: .
platforms: linux/${{ env.SHORT_ARCH }}
labels: |
git.revision=${{ github.sha }}
git.branch=${{ github.ref }}
git.tag=${{ github.ref }}
git.repository=${{ github.repository }}
push: true
tags: |
${{ github.repository_owner}}/anchor:${{ env.VERSION }}-${{ env.SHORT_ARCH }}${{ env.VERSION_SUFFIX }}
build-args: |
RUST_VERSION=${{ env.RUST_VERSION }}
TARGETPLATFORM=linux/${{ env.SHORT_ARCH }}

Loading