|
| 1 | +name: build binaries |
| 2 | + |
| 3 | +# Note: this workflow should really depend on a workflow that runs on-platform tests |
| 4 | +# because as is what we're doing here is building a binary blind that we have no idea |
| 5 | +# whether it works or not beyond being able to just execute the binary. |
| 6 | +# This is more important here than in other cases because it's highly likley |
| 7 | +# there are _no_ tests being run on most of the platforms we're building here. |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - "ci-test-binaries" # Push changes to this branch to initiate a draft release to test this workflow |
| 13 | + tags: |
| 14 | + - "[0-9]+.[0-9]+.[0-9]*" # Normal trigger is a tag created of the form x.y.z (note not vx.y.z) |
| 15 | + |
| 16 | +env: |
| 17 | + test_branch_name: "ci-test-binaries" # Branch which should be named above, used for release process testing |
| 18 | + |
| 19 | +jobs: |
| 20 | + create_release: |
| 21 | + name: Create the GitHub Release |
| 22 | + permissions: |
| 23 | + contents: write # See: https://github.com/orgs/community/discussions/68252 |
| 24 | + runs-on: ubuntu-latest |
| 25 | + outputs: |
| 26 | + release-tag: ${{ steps.release-info.outputs.release-tag }} |
| 27 | + steps: |
| 28 | + - name: checkout |
| 29 | + uses: actions/checkout@v3 |
| 30 | + |
| 31 | + - name: print build info |
| 32 | + run: | |
| 33 | + echo "github.ref: ${{ github.ref }}" |
| 34 | + echo "test branch: ${{ env.test_branch_name }}" |
| 35 | + echo "test run: ${{ endsWith( github.ref, env.test_branch_name ) }}" |
| 36 | + shell: bash |
| 37 | + |
| 38 | + - name: generate release info |
| 39 | + id: release-info |
| 40 | + # For release testing we don't have a version to use from a tag |
| 41 | + # so we generate a stand in that's a time stamp |
| 42 | + run: | |
| 43 | + if [[ ${{ endsWith( github.ref, env.test_branch_name ) }} == 'true' ]]; then |
| 44 | + tag=$(date +'%Y%m%d%H%M') |
| 45 | + else |
| 46 | + # This is a bit of a hack, but we need to get the tag name from the ref |
| 47 | + tag=$(echo "${{ github.ref }}" | cut -d'/' -f3) |
| 48 | + fi |
| 49 | + echo "release-tag: ${tag}" |
| 50 | + echo "release-tag=${tag}" >> $GITHUB_OUTPUT |
| 51 | + shell: bash |
| 52 | + |
| 53 | + - name: create release |
| 54 | + id: create-release |
| 55 | + uses: softprops/action-gh-release@v2 |
| 56 | + with: |
| 57 | + draft: ${{ endsWith( github.ref, env.test_branch_name ) }} |
| 58 | + tag_name: ${{ steps.release-info.outputs.release-tag }} |
| 59 | + generate_release_notes: false # This doesn't seem to work -- it still generates release notes |
| 60 | + |
| 61 | + build: |
| 62 | + name: Build and upload binaries |
| 63 | + permissions: |
| 64 | + contents: write |
| 65 | + strategy: |
| 66 | + matrix: |
| 67 | + # windows-11-arm currently fails build due to https://github.com/0LNetworkCommunity/libra-framework/issues/405 |
| 68 | + # macos-latest is ARM, ubuntu-latest is x86, windows-latest is x86 |
| 69 | + os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-13, windows-latest] |
| 70 | + runs-on: ${{ matrix.os }} |
| 71 | + needs: create_release |
| 72 | + steps: |
| 73 | + - name: checkout |
| 74 | + uses: actions/checkout@v3 |
| 75 | + |
| 76 | + - name: get executable binary_suffix |
| 77 | + id: platform-info |
| 78 | + run: | |
| 79 | + if [[ ${{ runner.os }} == "Windows" ]]; then |
| 80 | + binary_suffix=".exe" |
| 81 | + else |
| 82 | + binary_suffix="" |
| 83 | + fi |
| 84 | + echo "binary_suffix=${binary_suffix}" >> $GITHUB_OUTPUT |
| 85 | + shell: bash |
| 86 | + |
| 87 | + - name: install rust toolchain |
| 88 | + uses: actions-rust-lang/setup-rust-toolchain@v1 # We need 1.12.0 or later for Windows ARM64 support |
| 89 | + with: |
| 90 | + # Provisionally pinning version pre 1.81 sorting changes |
| 91 | + toolchain: 1.80.1 |
| 92 | + override: true |
| 93 | + |
| 94 | + - name: install dependencies |
| 95 | + uses: awalsh128/cache-apt-pkgs-action@latest |
| 96 | + with: |
| 97 | + packages: build-essential ca-certificates clang curl git libpq-dev libssl-dev pkg-config lsof lld libgmp-dev |
| 98 | + version: 1.0 |
| 99 | + if: runner.os == 'Linux' # This action only works on Ubuntu |
| 100 | + |
| 101 | + - name: set RUSTFLAGS # Note this is necessary because the setting in .cargo/config.toml doesn't propagate to dependency builds |
| 102 | + run: echo "RUSTFLAGS=--cfg tokio_unstable" >> $GITHUB_ENV |
| 103 | + shell: bash |
| 104 | + |
| 105 | + - name: build libra binary |
| 106 | + run: | |
| 107 | + cargo b --release -p libra |
| 108 | +
|
| 109 | + - name: check binary runs on this platform |
| 110 | + run: target/release/libra version |
| 111 | + shell: bash |
| 112 | + |
| 113 | + - name: rename to platform specific name |
| 114 | + id: artifact-info |
| 115 | + run: | |
| 116 | + runner_os=${{ runner.os }} |
| 117 | + runner_os_lowercase=${runner_os,,} |
| 118 | + runner_arch=${{ runner.arch }} |
| 119 | + runner_arch_lowercase=${runner_arch,,} |
| 120 | + artifact_name=target/release/libra-${runner_os_lowercase}-${runner_arch_lowercase}${{ steps.platform-info.outputs.binary_suffix }} |
| 121 | + echo "artifact_name=${artifact_name}" >> $GITHUB_OUTPUT |
| 122 | + build_output=target/release/libra${binary_suffix} |
| 123 | + echo "Renaming: ${build_output} to: ${artifact_name}" |
| 124 | + mv ${build_output} ${artifact_name} |
| 125 | + shell: bash |
| 126 | + |
| 127 | + - name: print binary artifact name |
| 128 | + run: | |
| 129 | + echo "artifact_name: ${{ steps.artifact-info.outputs.artifact_name }}" |
| 130 | + shell: bash |
| 131 | + |
| 132 | + - name: upload binary to release # upload the binary as a release artifact |
| 133 | + uses: softprops/action-gh-release@v2 |
| 134 | + with: |
| 135 | + tag_name: ${{ needs.create_release.outputs.release-tag }} |
| 136 | + files: ${{ steps.artifact-info.outputs.artifact_name }} |
0 commit comments