From 9859b14bec12bca373b093b8cbeb5963a4e1e3ec Mon Sep 17 00:00:00 2001 From: iff Date: Fri, 22 Nov 2024 11:30:30 +0100 Subject: [PATCH] ci: cross compiling --- .github/workflows/build.yaml | 93 +++++++++++++++++++++++++++--------- Cargo.lock | 4 +- Cargo.toml | 2 +- 3 files changed, 74 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ed6855c..937332b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -4,37 +4,86 @@ on: push: tags: - v* - +permissions: + contents: write jobs: build: + name: ${{ matrix.target }} runs-on: ${{ matrix.os }} - permissions: - contents: write strategy: fail-fast: true matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + deb: true + - os: macos-latest + target: x86_64-apple-darwin + - os: macos-latest + target: aarch64-apple-darwin + - os: windows-latest + target: x86_64-pc-windows-msvc + - os: windows-latest + target: aarch64-pc-windows-msvc steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: build - run: | - cargo build --release --all-features + - name: get version + id: version + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT - - name: Zipping files (exe) - if: matrix.os == 'windows-latest' - run: | - 7z a pay-respects-${{ matrix.os }}.zip ./target/release/pay-respects.exe + - name: setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + target: ${{ matrix.target }} - - name: Zipping files (unix) - if: matrix.os != 'windows-latest' - run: | - 7z a pay-respects-${{ matrix.os }}.zip ./target/release/pay-respects + # will need to static link openssl + # - name: install cross + # if: ${{ runner.os == 'Linux' }} + # uses: actions-rs/cargo@v1 + # with: + # command: install + # args: cross --locked - - name: Uploading to release - uses: ncipollo/release-action@v1 - with: - artifacts: pay-respects-${{ matrix.os }}.zip - allowUpdates: true - makeLatest: true + - name: build + run: + cargo build --release --all-features --locked --target ${{ matrix.target }} + + - name: install cargo-deb + if: ${{ matrix.deb == true }} + uses: actions-rs/install@v0.1 + with: + crate: cargo-deb + + - name: build deb + if: ${{ matrix.deb == true }} + uses: actions-rs/cargo@v1 + with: + command: deb + args: --no-build --no-strip --output=. --target=${{ matrix.target }} + + - name: zipping files (exe) + if: runner.os == 'Windows' + # for some reason Windows doesn't support environment variables? + run: > + 7z a pay-respects-${{ matrix.target }}.zip + ./target/${{ matrix.target }}/release/pay-respects.exe + + - name: zipping files (unix) + if: runner.os != 'Windows' + run: > + tar -czf pay-respects-${{ steps.version.outputs.VERSION }}-${{ matrix.target }}.tar.gz + -C target/${{ matrix.target }}/release pay-respects + + - name: uploading to release + uses: ncipollo/release-action@v1 + with: + artifacts: | + *.tar.gz + *.zip + *.deb + allowUpdates: true + makeLatest: true diff --git a/Cargo.lock b/Cargo.lock index cff2c19..5525138 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -371,9 +371,9 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "proc-macro2" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307e3004becf10f5a6e0d59d20f3cd28231b0e0827a96cd3e0ce6d14bc1e4bb3" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] diff --git a/Cargo.toml b/Cargo.toml index b3f0e28..771698d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [package] name = "pay-respects" +authors = ["iff "] version = "0.5.12" edition = "2021" @@ -30,7 +31,6 @@ textwrap = { version = "0.16", features = ["terminal_size"], optional = true} pay-respects-parser = "0.2.6" # pay-respects-parser = { path = "../pay-respects-parser" } - [features] runtime-rules = ["dep:serde", "dep:toml"] request-ai = ["dep:serde", "dep:serde_json", "dep:curl", "dep:textwrap"]