|
| 1 | +name: Release binaries |
| 2 | +# This machine tests building the software on a both 32 and 64 Windows architecture. |
| 3 | + |
| 4 | +on: [push] |
| 5 | + |
| 6 | +jobs: |
| 7 | + |
| 8 | + redhat_based: |
| 9 | + strategy: |
| 10 | + fail-fast: false |
| 11 | + matrix: |
| 12 | + environment: [ |
| 13 | + "centos:7", |
| 14 | + "centos:8", |
| 15 | + ] |
| 16 | + |
| 17 | + name: build on ${{ matrix.environment }} |
| 18 | + runs-on: ubuntu-latest |
| 19 | + container: ${{ matrix.environment }} |
| 20 | + |
| 21 | + steps: |
| 22 | + |
| 23 | + - name: clone the Yubico/yubihsm-shell repository |
| 24 | + uses: actions/checkout@v3 |
| 25 | + with: |
| 26 | + path: yubihsm-shell |
| 27 | + |
| 28 | + - name: apply environment specific changes to CMakeLists.txt |
| 29 | + working-directory: yubihsm-shell |
| 30 | + if: ${{ matrix.environment == 'centos:7' }} |
| 31 | + run: | |
| 32 | + # centos 7 comes with cmake version 2.8, but the project requires 3.5 |
| 33 | + # we downgrade that requirement for the centos 7 build |
| 34 | + sed -i 's/cmake_minimum_required (VERSION 3.5)/cmake_minimum_required (VERSION 2.8)/' CMakeLists.txt |
| 35 | + # we also remove the following policies which are not supported in the older cmake version |
| 36 | + sed -i 's/cmake_policy(SET CMP0025 NEW)/#cmake_policy(SET CMP0025 NEW)/' CMakeLists.txt |
| 37 | + sed -i 's/cmake_policy(SET CMP0042 NEW)/#cmake_policy(SET CMP0042 NEW)/' CMakeLists.txt |
| 38 | + sed -i 's/cmake_policy(SET CMP0054 NEW)/#cmake_policy(SET CMP0054 NEW)/' CMakeLists.txt |
| 39 | + # append the following flags: -Wno-missing-braces -Wno-missing-field-initializers -Wno-implicit-function-declaration |
| 40 | + sed -i 's/-Wall -Wextra -Werror/-Wall -Wextra -Werror -Wno-missing-braces -Wno-missing-field-initializers/' cmake/SecurityFlags.cmake |
| 41 | +
|
| 42 | + - name: extract platform name |
| 43 | + env: |
| 44 | + DOCKER_IMAGE: ${{ matrix.environment }} |
| 45 | + run: | |
| 46 | + # Remove everything from DOCKER_IMAGE that is not a letter or a number |
| 47 | + PLATFORM=$(echo -n "$DOCKER_IMAGE" | sed -E 's/[^a-zA-Z0-9]//g') |
| 48 | + echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV |
| 49 | +
|
| 50 | + - name: install dependencies |
| 51 | + env: |
| 52 | + PLATFORM: ${{ env.PLATFORM }} |
| 53 | + run: | |
| 54 | + cd yubihsm-shell/resources/release/linux |
| 55 | + ./install_redhat_dependencies.sh $PLATFORM |
| 56 | +
|
| 57 | + if [ $PLATFORM = "centos7" ]; then |
| 58 | + # enable the epel repository for centos |
| 59 | + yum install -y epel-release |
| 60 | + fi |
| 61 | + yum install -y checksec procps-ng jq file which curl |
| 62 | +
|
| 63 | + - name: build release |
| 64 | + working-directory: yubihsm-shell |
| 65 | + env: |
| 66 | + PLATFORM: ${{ env.PLATFORM }} |
| 67 | + run: | |
| 68 | + export CMAKE="cmake" |
| 69 | + export INPUT=$GITHUB_WORKSPACE/yubihsm-shell |
| 70 | + export OUTPUT=$GITHUB_WORKSPACE/$PLATFORM/yubihsm-shell |
| 71 | + rm -rf $OUTPUT |
| 72 | + mkdir -p $OUTPUT |
| 73 | +
|
| 74 | + # These 2 lines can be replaced by the command "rpmdev-setuptree", but this command seems to add macros that force check paths that do not exist |
| 75 | + mkdir -p $GITHUB_WORKSPACE/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} |
| 76 | + echo '%_topdir %(echo $HOME)/rpmbuild' > $GITHUB_WORKSPACE/.rpmmacros |
| 77 | +
|
| 78 | + RPM_DIR=$GITHUB_WORKSPACE/rpmbuild |
| 79 | +
|
| 80 | + cp resources/release/linux/yubihsm-shell.spec $RPM_DIR/SPECS/ |
| 81 | +
|
| 82 | + QA_SKIP_BUILD_ROOT=1 QA_RPATHS=$(( 0x0001|0x0010 )) rpmbuild -bb $RPM_DIR/SPECS/yubihsm-shell.spec |
| 83 | + cp /github/home/rpmbuild/RPMS/x86_64/*.rpm $OUTPUT/ |
| 84 | +
|
| 85 | + LICENSE_DIR="$OUTPUT/share/yubihsm-shell" |
| 86 | + mkdir -p $LICENSE_DIR |
| 87 | + cp -r $INPUT/resources/release/linux/licenses $LICENSE_DIR/ |
| 88 | + for lf in $LICENSE_DIR/licenses/*; do |
| 89 | + chmod 644 $lf |
| 90 | + done |
| 91 | +
|
| 92 | + cd $OUTPUT |
| 93 | + rm -f "yubihsm-shell-$PLATFORM-amd64.tar.gz" |
| 94 | + tar -C ".." -zcvf "../yubihsm-shell-$PLATFORM-amd64.tar.gz" "yubihsm-shell" |
| 95 | + rm -f *.rpm |
| 96 | + rm -rf licenses |
| 97 | + rm -rf ../yubihsm-shell |
| 98 | +
|
| 99 | + - name: install binaries |
| 100 | + working-directory: /github/home/rpmbuild/RPMS/x86_64 |
| 101 | + run: | |
| 102 | + yum install -y ./yubihsm-shell-*.rpm |
| 103 | +
|
| 104 | + - name: check binaries for hardening |
| 105 | + run: | |
| 106 | + cs() { |
| 107 | + checksec --file=/usr/bin/yubihsm-shell --format=json | jq -r ".[] | .$1" |
| 108 | + } |
| 109 | + if [ "`cs relro`" != "full" ]; then echo "relro is `cs relro`"; exit 1; fi |
| 110 | + if [ "`cs canary`" != "yes" ]; then echo "canary is `cs canary`"; exit 1; fi |
| 111 | + if [ "`cs nx`" != "yes" ]; then echo "nx is `cs nx`"; exit 1; fi |
| 112 | + if [ "`cs pie`" != "yes" ]; then echo "pie is `cs pie`"; exit 1; fi |
| 113 | + if [ "`cs fortify_source`" != "yes" ]; then echo "fortify_source is `cs fortify_source`"; exit 1; fi |
| 114 | +
|
| 115 | +
|
| 116 | + - name: upload artifacts |
| 117 | + uses: actions/upload-artifact@v3 |
| 118 | + with: |
| 119 | + name: "yubihsm-shell-${{ env.PLATFORM }}-amd64" |
| 120 | + path: ${{ env.PLATFORM }} |
0 commit comments