diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 461cdde..92114a7 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -45,6 +45,13 @@ jobs: name: build-packages runs-on: ubuntu-24.04 needs: build-meta + outputs: + usign-private-key: + ${{ steps.build-keypair.outputs.usign-private-key }} + usign-public-key: + ${{ steps.build-keypair.outputs.usign-public-key }} + usign-fingerprint: + ${{ steps.build-keypair.outputs.usign-singerprint }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -94,17 +101,26 @@ jobs: with: path: /tmp/openwrt-sdk key: ${{ steps.cache-key-sdk.outputs.cache-key }} + - name: Get build keypair + id: build-keypair + env: + GHA_PRIVATE_KEY: ${{ secrets.USIGN_PRIVATE_KEY }} + GHA_PUBLIC_KEY: ${{ vars.USIGN_PUBLIC_KEY }} + run: | + bash $GITHUB_WORKSPACE/contrib/build-key.sh /tmp/openwrt-sdk/staging_dir/host/bin/usign + - name: Save secret build-key + run: | + echo "${{ steps.build-keypair.outputs.usign-private-key }}" > /tmp/openwrt-sdk/build-key - name: Create SDK configuration run: | cd /tmp/openwrt-sdk - echo "# CONFIG_SIGNED_PACKAGES is not set" > /tmp/openwrt-sdk/.config echo CONFIG_FFDA_OOB_FIRMWARE_VERSION=\"${{ needs.build-meta.outputs.firmware-version }}\" >> /tmp/openwrt-sdk/.config make defconfig - name: Build packages run: | cd /tmp/openwrt-sdk make package/ffda-oob-firmware/compile V=s -j4 - make package/index + make package/index V=s - name: Show binary output directory structure run: | tree /tmp/openwrt-sdk/bin @@ -161,9 +177,11 @@ jobs: with: path: /tmp/openwrt-imagebuilder key: ${{ steps.cache-key-ib.outputs.cache-key }} + - name: Save pulic build-key + run: | + echo ${{ needs.build-packages.outputs.usign-public-key }} > /tmp/openwrt-imagebuilder/keys/${{ needs.build-packages.outputs.usign-fingerprint }} - name: Link repositories run: | - sed -i '/^option check_signature/d' /tmp/openwrt-imagebuilder/repositories.conf echo "src oobfw file:///tmp/packages/packages-oobfw" >> /tmp/openwrt-imagebuilder/repositories.conf echo "src oobpkgs file:///tmp/packages/packages-oobpkgs" >> /tmp/openwrt-imagebuilder/repositories.conf - name: Set Version information diff --git a/contrib/build-key.sh b/contrib/build-key.sh new file mode 100644 index 0000000..6e52261 --- /dev/null +++ b/contrib/build-key.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +USIGN_PATH="$1" +KEY_PATH="$(mktemp -d)" + +if [ -z "$USIGN_PATH" ] || [ -z "$KEY_PATH" ]; then + echo "Usage: $0 " + exit 1 +fi + +$USIGN_PATH -G -p "$KEY_PATH/public.key" -s "$KEY_PATH/private.key" + +if [ -n "$GHA_PRIVATE_KEY" ] && [ -n "$GHA_PUBLIC_KEY" ]; then + echo "GHA_PRIVATE_KEY and GHA_PUBLIC_KEY is set" + + echo "$GHA_PRIVATE_KEY" > "$KEY_PATH/private.key" + echo "$GHA_PUBLIC_KEY" > "$KEY_PATH/public.key" +fi + +USIGN_PRIVATE_KEY="$(cat $KEY_PATH/private.key)" +USIGN_PUBLIC_KEY="$(cat $KEY_PATH/public.key)" +USIGN_FINGERPRINT="$($USIGN_PATH -F -p $KEY_PATH/public.key)" + +echo "usign-private-key<> "$GITHUB_OUTPUT" +echo "$USIGN_PRIVATE_KEY" >> "$GITHUB_OUTPUT" +echo "EOF" >> "$GITHUB_OUTPUT" + +echo "usign-public-key<> "$GITHUB_OUTPUT" +echo "$USIGN_PUBLIC_KEY" >> "$GITHUB_OUTPUT" +echo "EOF" >> "$GITHUB_OUTPUT" + +echo "usign-fingerprint<> "$GITHUB_OUTPUT" +echo "$USIGN_FINGERPRINT" >> "$GITHUB_OUTPUT" +echo "EOF" >> "$GITHUB_OUTPUT" + +rm -rf "$KEY_PATH" \ No newline at end of file