|
| 1 | +# TODO: until the ci works better |
| 2 | +#on: [push] |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +env: |
| 7 | + CARGO_HOME: /workspace/nehu/helix/cargo-home |
| 8 | + RUSTUP_HOME: /workspace/nehu/helix/rustup-home |
| 9 | + #CROSS_CONTAINER_IN_CONTAINER: true |
| 10 | + CROSS_CONTAINER_ENGINE: podman |
| 11 | + HELIX_DEFAULT_RUNTIME: /usr/lib/helix/runtime |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + target: |
| 18 | + - id: x86_64-unknown-linux-gnu |
| 19 | + name: amd64-linux |
| 20 | + # TODO: doesn't work well yet |
| 21 | + #- id: x86_64-apple-darwin |
| 22 | + # name: amd64-macos |
| 23 | + - id: aarch64-unknown-linux-gnu |
| 24 | + name: arm64-linux |
| 25 | + - id: aarch64-unknown-linux-musl |
| 26 | + name: arm64-linux-musl |
| 27 | + - id: arm-unknown-linux-musleabihf |
| 28 | + name: armv6-linux-musl |
| 29 | + max-parallel: 2 |
| 30 | + runs-on: linux-x86_64 |
| 31 | + container: |
| 32 | + image: rust |
| 33 | + #image: rust:alpine3.19 |
| 34 | + steps: |
| 35 | + # Required by 3rd-party actions |
| 36 | + # `musl-dev` required to avoid the crti.o error (https://github.com/rust-lang/rust/issues/40174) |
| 37 | + - run: "apt update && apt install -y podman git nodejs tree" |
| 38 | + - run: mkdir -pv ~/.rustup ~/.cargo |
| 39 | + - uses: "actions/checkout@v3" |
| 40 | + - name: "Restore rustup cache" |
| 41 | + id: "cache-rustup-restore" |
| 42 | + uses: "actions/cache/restore@v4" |
| 43 | + with: |
| 44 | + path: | |
| 45 | + rustup-home |
| 46 | + key: "helix-rustup-${{ matrix.target.id }}" |
| 47 | + - name: "Restore cargo cache" |
| 48 | + id: "cache-cargo-restore" |
| 49 | + uses: "actions/cache/restore@v4" |
| 50 | + with: |
| 51 | + path: | |
| 52 | + cargo-home |
| 53 | + key: "helix-cargo-${{ matrix.target.id }}" |
| 54 | + - name: "Restore artifacts cache" |
| 55 | + id: "cache-artifacts-restore" |
| 56 | + uses: "actions/cache/restore@v4" |
| 57 | + with: |
| 58 | + path: | |
| 59 | + target |
| 60 | + key: "helix-artifacts-${{ matrix.target.id }}" |
| 61 | + - name: "Install binstall" |
| 62 | + uses: "https://github.com/cargo-bins/[email protected]" |
| 63 | + - name: "Install cross" |
| 64 | + run: "cargo binstall -y cross" |
| 65 | + #- name: "Install target: ${{ matrix.target.id }}" |
| 66 | + # if: ${{ matrix.target.id == 'x86_64-apple-darwin' }} |
| 67 | + # run: "rustup target add ${{ matrix.target.id }}" |
| 68 | + - name: "Configure cross: ${{ matrix.target.id }}" |
| 69 | + if: ${{ matrix.target.id == 'x86_64-apple-darwin' }} |
| 70 | + run: | |
| 71 | + echo "[target.${{ matrix.target.id }}]" >> Cross.toml |
| 72 | + echo 'image = "ghcr.io/mrpixel1/x86_64-apple-darwin-cross:latest"' >> Cross.toml |
| 73 | + - name: "Build" |
| 74 | + run: $CARGO_HOME/bin/cross build --profile opt --target ${{ matrix.target.id }} |
| 75 | + - name: "Save artifacts cache" |
| 76 | + id: "cache-artifacts-save" |
| 77 | + uses: "actions/cache/save@v4" |
| 78 | + with: |
| 79 | + path: | |
| 80 | + target |
| 81 | + key: "${{ steps.cache-artifacts-restore.outputs.cache-primary-key }}" |
| 82 | + - name: "Save cargo cache" |
| 83 | + if: "always()" |
| 84 | + id: "cache-cargo-save" |
| 85 | + uses: "actions/cache/save@v4" |
| 86 | + with: |
| 87 | + path: | |
| 88 | + cargo-home |
| 89 | + key: "${{ steps.cache-cargo-restore.outputs.cache-primary-key }}" |
| 90 | + - name: "Save rustup cache" |
| 91 | + if: "always()" |
| 92 | + id: "cache-rustup-save" |
| 93 | + uses: "actions/cache/save@v4" |
| 94 | + with: |
| 95 | + path: | |
| 96 | + rustup-home |
| 97 | + key: "${{ steps.cache-rustup-restore.outputs.cache-primary-key }}" |
| 98 | + - name: "Prepare dist" |
| 99 | + run: | |
| 100 | + mkdir -pv dist/helix |
| 101 | + mv -v target/${{ matrix.target.id }}/opt/hx dist/helix/ |
| 102 | + rm -rf runtime/grammars/sources |
| 103 | + mv -v runtime dist/helix/ |
| 104 | + cd dist && tar -cvzf helix-${{ matrix.target.name }}.tar.gz helix |
| 105 | + - name: "Upload artifacts" |
| 106 | + # Temporary solution until https://code.forgejo.org/actions/upload-artifact works |
| 107 | + #uses: "https://code.forgejo.org/forgejo/upload-artifact@v4" |
| 108 | + uses: "https://code.forgejo.org/forgejo/upload-artifact@v3" |
| 109 | + with: |
| 110 | + name: helix-${{ matrix.target.name }} |
| 111 | + path: dist/helix-${{ matrix.target.name }}.tar |
0 commit comments