|
| 1 | +name: Build Rust Binary (extended) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + rust-toolchain: |
| 7 | + description: 'Rust toolchain to use' |
| 8 | + required: false |
| 9 | + type: string |
| 10 | + default: 'stable' |
| 11 | + packages: |
| 12 | + description: 'Comma-separated list of package names' |
| 13 | + required: true |
| 14 | + type: string |
| 15 | + target-config-file: |
| 16 | + description: 'Path to the TOML file containing target configurations' |
| 17 | + required: false |
| 18 | + type: string |
| 19 | + default: '.github/target.toml' |
| 20 | + run-tests: |
| 21 | + description: 'Whether to run tests (can be overridden by matrix config)' |
| 22 | + required: false |
| 23 | + type: boolean |
| 24 | + default: true |
| 25 | + cache-key-prefix: |
| 26 | + description: 'Prefix for cache key to avoid collisions' |
| 27 | + required: false |
| 28 | + type: string |
| 29 | + default: 'rust-build' |
| 30 | + rustflags: |
| 31 | + description: 'Additional RUSTFLAGS to pass to the compiler' |
| 32 | + required: false |
| 33 | + type: string |
| 34 | + default: '' |
| 35 | + package-name: |
| 36 | + description: 'Package name for artifacts (env PACKAGE)' |
| 37 | + required: false |
| 38 | + type: string |
| 39 | + default: '' |
| 40 | + image-name: |
| 41 | + description: 'Docker image name for docker-image job' |
| 42 | + required: false |
| 43 | + type: string |
| 44 | + default: '' |
| 45 | + registry: |
| 46 | + description: 'Container registry' |
| 47 | + required: false |
| 48 | + type: string |
| 49 | + default: 'ghcr.io' |
| 50 | + enable-nasm: |
| 51 | + description: 'Whether to run NASM setup' |
| 52 | + required: false |
| 53 | + type: boolean |
| 54 | + default: false |
| 55 | + retention-days: |
| 56 | + description: 'Artifact retention days' |
| 57 | + required: false |
| 58 | + type: number |
| 59 | + default: 3 |
| 60 | + postfix: |
| 61 | + description: 'Binary postfix (.exe etc)' |
| 62 | + required: false |
| 63 | + type: string |
| 64 | + default: '' |
| 65 | + |
| 66 | +defaults: |
| 67 | + run: |
| 68 | + shell: bash |
| 69 | + |
| 70 | +env: |
| 71 | + RUSTC_BOOTSTRAP: "1" |
| 72 | + |
| 73 | +jobs: |
| 74 | + # Reuse most of the original rust-build implementation but expose extra inputs |
| 75 | + call-rust-build: |
| 76 | + uses: ./.github/workflows/rust-build.yml |
| 77 | + with: |
| 78 | + rust-toolchain: ${{ inputs.rust-toolchain }} |
| 79 | + packages: ${{ inputs.packages }} |
| 80 | + target-config-file: ${{ inputs.target-config-file }} |
| 81 | + run-tests: ${{ inputs.run-tests }} |
| 82 | + cache-key-prefix: ${{ inputs.cache-key-prefix }} |
| 83 | + rustflags: ${{ inputs.rustflags }} |
| 84 | + |
| 85 | + docker-image: |
| 86 | + needs: [call-rust-build] |
| 87 | + if: ${{ inputs.image-name != '' }} |
| 88 | + runs-on: ubuntu-latest |
| 89 | + steps: |
| 90 | + - name: Checkout code |
| 91 | + uses: actions/checkout@v6 |
| 92 | + - name: Download binaries |
| 93 | + uses: actions/download-artifact@v8 |
| 94 | + with: |
| 95 | + name: ${{ matrix.release-name || matrix.target }}-binaries |
| 96 | + path: ./binaries |
| 97 | + - name: Build and push docker |
| 98 | + if: ${{ inputs.image-name != '' }} |
| 99 | + uses: docker/build-push-action@v6 |
| 100 | + with: |
| 101 | + context: . |
| 102 | + file: .github/Dockerfile |
| 103 | + push: true |
| 104 | + tags: ${{ inputs.registry }}/${{ github.repository_owner }}/${{ inputs.image-name }}:latest |
| 105 | + |
| 106 | + publish-release: |
| 107 | + needs: [call-rust-build] |
| 108 | + if: ${{ always() }} |
| 109 | + runs-on: ubuntu-latest |
| 110 | + steps: |
| 111 | + - name: Merge artifacts (noop placeholder) |
| 112 | + run: echo "release step placeholder" |
0 commit comments