fix(ci): make cross compilation work with the no-web variant (#4330)
* add no_web flag to ci cross compilation * chore(ci): refactor release to web/no-web variants * fix ci for cross building with no-web
This commit is contained in:
parent
b5a893f36a
commit
b7bf364c09
3 changed files with 148 additions and 91 deletions
203
.github/workflows/release.yml
vendored
203
.github/workflows/release.yml
vendored
|
|
@ -6,9 +6,25 @@ on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-release:
|
create-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
steps:
|
||||||
|
- name: create_release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.event_name == 'workflow_dispatch' && '' || github.ref }}
|
||||||
|
release_name: Release ${{ github.event_name == 'workflow_dispatch' && 'main' || github.ref }}
|
||||||
|
draft: ${{ github.event_name == 'workflow_dispatch' }}
|
||||||
|
prerelease: false
|
||||||
|
|
||||||
|
build-release-normal:
|
||||||
needs: create-release
|
needs: create-release
|
||||||
name: build-release
|
name: build-release-normal
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
env:
|
env:
|
||||||
RUST_BACKTRACE: 1
|
RUST_BACKTRACE: 1
|
||||||
|
|
@ -62,129 +78,146 @@ jobs:
|
||||||
with:
|
with:
|
||||||
toolchain: ${{ matrix.rust }}
|
toolchain: ${{ matrix.rust }}
|
||||||
target: "${{ matrix.target }},wasm32-wasip1"
|
target: "${{ matrix.target }},wasm32-wasip1"
|
||||||
# Just to make sure the cache doesn't interfere with the build here
|
|
||||||
cache: false
|
cache: false
|
||||||
rustflags: ""
|
rustflags: ""
|
||||||
|
|
||||||
- name: Build release binary (normal)
|
- name: Build release binary
|
||||||
run: cargo xtask ci cross ${{ matrix.target }}
|
run: cargo xtask ci cross ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Preserve normal binary and build no-web variant
|
- name: Create artifact
|
||||||
|
id: make-artifact
|
||||||
run: |
|
run: |
|
||||||
# Copy the normal binary to a safe location outside target/
|
asset_name="zellij-${{ matrix.target }}.tar.gz"
|
||||||
mkdir -p ./release-artifacts
|
tar cvzf "${asset_name}" -C "target/${{ matrix.target }}/release" zellij
|
||||||
cp "target/${{ matrix.target }}/release/zellij" "./release-artifacts/zellij-normal"
|
echo "asset_name=${asset_name}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
# Clean and build the no-web version
|
|
||||||
cargo clean
|
|
||||||
cargo xtask ci cross ${{ matrix.target }} --no-web
|
|
||||||
|
|
||||||
# Copy the no-web binary to our safe location too
|
|
||||||
cp "target/${{ matrix.target }}/release/zellij" "./release-artifacts/zellij-no-web"
|
|
||||||
|
|
||||||
# this breaks on aarch64 and this if conditional isn't working for some reason: TODO: investigate
|
- name: Create checksum
|
||||||
#- name: Strip release binary
|
id: make-checksum
|
||||||
# if: runner.target != 'aarch64-unknown-linux-musl' && runner.target != 'aarch64-apple-darwin'
|
|
||||||
# run: strip "target/${{ matrix.target }}/release/zellij"
|
|
||||||
|
|
||||||
- name: Create artifacts for both variants
|
|
||||||
id: make-artifacts
|
|
||||||
working-directory: ./release-artifacts
|
|
||||||
run: |
|
run: |
|
||||||
# Create normal version artifact
|
checksum_name="zellij-${{ matrix.target }}.sha256sum"
|
||||||
normal_name="zellij-${{ matrix.target }}.tar.gz"
|
|
||||||
cp zellij-normal zellij
|
|
||||||
tar cvzf "${normal_name}" zellij
|
|
||||||
rm zellij
|
|
||||||
echo "normal_name=${normal_name}" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
# Create no-web version artifact
|
|
||||||
noweb_name="zellij-no-web-${{ matrix.target }}.tar.gz"
|
|
||||||
cp zellij-no-web zellij
|
|
||||||
tar cvzf "${noweb_name}" zellij
|
|
||||||
rm zellij
|
|
||||||
echo "noweb_name=${noweb_name}" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Create checksums
|
|
||||||
id: make-checksums
|
|
||||||
working-directory: ./release-artifacts
|
|
||||||
run: |
|
|
||||||
normal_checksum="zellij-${{ matrix.target }}.sha256sum"
|
|
||||||
noweb_checksum="zellij-no-web-${{ matrix.target }}.sha256sum"
|
|
||||||
|
|
||||||
# Create checksum for normal version
|
|
||||||
cp zellij-normal zellij
|
|
||||||
if [[ "$RUNNER_OS" != "macOS" ]]; then
|
if [[ "$RUNNER_OS" != "macOS" ]]; then
|
||||||
sha256sum zellij > "${normal_checksum}"
|
sha256sum "target/${{ matrix.target }}/release/zellij" > "${checksum_name}"
|
||||||
else
|
else
|
||||||
shasum -a 256 zellij > "${normal_checksum}"
|
shasum -a 256 "target/${{ matrix.target }}/release/zellij" > "${checksum_name}"
|
||||||
fi
|
fi
|
||||||
rm zellij
|
echo "checksum_name=${checksum_name}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
# Create checksum for no-web version
|
|
||||||
cp zellij-no-web zellij
|
|
||||||
if [[ "$RUNNER_OS" != "macOS" ]]; then
|
|
||||||
sha256sum zellij > "${noweb_checksum}"
|
|
||||||
else
|
|
||||||
shasum -a 256 zellij > "${noweb_checksum}"
|
|
||||||
fi
|
|
||||||
rm zellij
|
|
||||||
|
|
||||||
echo "normal_checksum=${normal_checksum}" >> "$GITHUB_OUTPUT"
|
- name: Upload release archive
|
||||||
echo "noweb_checksum=${noweb_checksum}" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Upload normal release archive
|
|
||||||
uses: actions/upload-release-asset@v1.0.2
|
uses: actions/upload-release-asset@v1.0.2
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||||
asset_path: ./release-artifacts/${{ steps.make-artifacts.outputs.normal_name }}
|
asset_path: ${{ steps.make-artifact.outputs.asset_name }}
|
||||||
asset_name: zellij-${{matrix.target}}.tar.gz
|
asset_name: zellij-${{matrix.target}}.tar.gz
|
||||||
asset_content_type: application/octet-stream
|
asset_content_type: application/octet-stream
|
||||||
|
|
||||||
- name: Upload normal checksum
|
- name: Upload checksum
|
||||||
uses: actions/upload-release-asset@v1.0.2
|
uses: actions/upload-release-asset@v1.0.2
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||||
asset_path: ./release-artifacts/${{ steps.make-checksums.outputs.normal_checksum }}
|
asset_path: ${{ steps.make-checksum.outputs.checksum_name }}
|
||||||
asset_name: zellij-${{matrix.target}}.sha256sum
|
asset_name: zellij-${{matrix.target}}.sha256sum
|
||||||
asset_content_type: text/plain
|
asset_content_type: text/plain
|
||||||
|
|
||||||
- name: Upload no-web release archive
|
build-release-noweb:
|
||||||
|
needs: create-release
|
||||||
|
name: build-release-noweb
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
RUST_BACKTRACE: 1
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
build:
|
||||||
|
- linux musl x64
|
||||||
|
- linux musl aarch64
|
||||||
|
- macos x64
|
||||||
|
- macos aarch64
|
||||||
|
include:
|
||||||
|
- build: linux musl x64
|
||||||
|
os: ubuntu-latest
|
||||||
|
rust: stable
|
||||||
|
target: x86_64-unknown-linux-musl
|
||||||
|
- build: linux musl aarch64
|
||||||
|
os: ubuntu-latest
|
||||||
|
rust: stable
|
||||||
|
target: aarch64-unknown-linux-musl
|
||||||
|
- build: macos x64
|
||||||
|
os: macos-latest
|
||||||
|
rust: stable
|
||||||
|
target: x86_64-apple-darwin
|
||||||
|
- build: macos aarch64
|
||||||
|
os: macos-latest
|
||||||
|
rust: stable
|
||||||
|
target: aarch64-apple-darwin
|
||||||
|
steps:
|
||||||
|
- name: Set release tag
|
||||||
|
run: |
|
||||||
|
if [ "$GITHUB_EVENT_NAME" == 'workflow_dispatch' ]; then
|
||||||
|
echo "RELEASE_TAG=main" >> "$GITHUB_ENV"
|
||||||
|
else
|
||||||
|
echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> "$GITHUB_ENV"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install Protoc
|
||||||
|
uses: arduino/setup-protoc@v2
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Install musl-tools
|
||||||
|
if: matrix.os == 'ubuntu-latest'
|
||||||
|
run: sudo apt-get install -y --no-install-recommends musl-tools
|
||||||
|
|
||||||
|
- name: Install Rust
|
||||||
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ matrix.rust }}
|
||||||
|
target: "${{ matrix.target }},wasm32-wasip1"
|
||||||
|
cache: false
|
||||||
|
rustflags: ""
|
||||||
|
|
||||||
|
- name: Build release binary (no-web)
|
||||||
|
run: cargo xtask ci cross ${{ matrix.target }} --no-web
|
||||||
|
|
||||||
|
- name: Create artifact
|
||||||
|
id: make-artifact
|
||||||
|
run: |
|
||||||
|
asset_name="zellij-no-web-${{ matrix.target }}.tar.gz"
|
||||||
|
tar cvzf "${asset_name}" -C "target/${{ matrix.target }}/release" zellij
|
||||||
|
echo "asset_name=${asset_name}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Create checksum
|
||||||
|
id: make-checksum
|
||||||
|
run: |
|
||||||
|
checksum_name="zellij-no-web-${{ matrix.target }}.sha256sum"
|
||||||
|
if [[ "$RUNNER_OS" != "macOS" ]]; then
|
||||||
|
sha256sum "target/${{ matrix.target }}/release/zellij" > "${checksum_name}"
|
||||||
|
else
|
||||||
|
shasum -a 256 "target/${{ matrix.target }}/release/zellij" > "${checksum_name}"
|
||||||
|
fi
|
||||||
|
echo "checksum_name=${checksum_name}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Upload release archive
|
||||||
uses: actions/upload-release-asset@v1.0.2
|
uses: actions/upload-release-asset@v1.0.2
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||||
asset_path: ./release-artifacts/${{ steps.make-artifacts.outputs.noweb_name }}
|
asset_path: ${{ steps.make-artifact.outputs.asset_name }}
|
||||||
asset_name: zellij-no-web-${{matrix.target}}.tar.gz
|
asset_name: zellij-no-web-${{matrix.target}}.tar.gz
|
||||||
asset_content_type: application/octet-stream
|
asset_content_type: application/octet-stream
|
||||||
|
|
||||||
- name: Upload no-web checksum
|
- name: Upload checksum
|
||||||
uses: actions/upload-release-asset@v1.0.2
|
uses: actions/upload-release-asset@v1.0.2
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||||
asset_path: ./release-artifacts/${{ steps.make-checksums.outputs.noweb_checksum }}
|
asset_path: ${{ steps.make-checksum.outputs.checksum_name }}
|
||||||
asset_name: zellij-no-web-${{matrix.target}}.sha256sum
|
asset_name: zellij-no-web-${{matrix.target}}.sha256sum
|
||||||
asset_content_type: text/plain
|
asset_content_type: text/plain
|
||||||
|
|
||||||
create-release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
steps:
|
|
||||||
- name: create_release
|
|
||||||
id: create_release
|
|
||||||
uses: actions/create-release@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
tag_name: ${{ github.event_name == 'workflow_dispatch' && '' || github.ref }}
|
|
||||||
release_name: Release ${{ github.event_name == 'workflow_dispatch' && 'main' || github.ref }}
|
|
||||||
draft: ${{ github.event_name == 'workflow_dispatch' }}
|
|
||||||
prerelease: false
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
build,
|
build,
|
||||||
flags::{self, CiCmd, Cross, E2e},
|
flags::{self, CiCmd, Cross, E2e},
|
||||||
|
metadata,
|
||||||
};
|
};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use std::{
|
use std::{
|
||||||
|
|
@ -38,7 +39,7 @@ pub fn main(sh: &Shell, flags: flags::Ci) -> anyhow::Result<()> {
|
||||||
test: true,
|
test: true,
|
||||||
args,
|
args,
|
||||||
}) => e2e_test(sh, args),
|
}) => e2e_test(sh, args),
|
||||||
CiCmd::Cross(Cross { triple }) => cross_compile(sh, &triple),
|
CiCmd::Cross(Cross { triple, no_web }) => cross_compile(sh, &triple, no_web),
|
||||||
}
|
}
|
||||||
.context(err_context)
|
.context(err_context)
|
||||||
}
|
}
|
||||||
|
|
@ -134,7 +135,7 @@ fn e2e_test(sh: &Shell, args: Vec<OsString>) -> anyhow::Result<()> {
|
||||||
.context(err_context)
|
.context(err_context)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cross_compile(sh: &Shell, target: &OsString) -> anyhow::Result<()> {
|
fn cross_compile(sh: &Shell, target: &OsString, no_web: bool) -> anyhow::Result<()> {
|
||||||
let err_context = || format!("failed to cross-compile for {target:?}");
|
let err_context = || format!("failed to cross-compile for {target:?}");
|
||||||
|
|
||||||
crate::cargo()
|
crate::cargo()
|
||||||
|
|
@ -155,7 +156,7 @@ fn cross_compile(sh: &Shell, target: &OsString) -> anyhow::Result<()> {
|
||||||
release: true,
|
release: true,
|
||||||
no_plugins: false,
|
no_plugins: false,
|
||||||
plugins_only: true,
|
plugins_only: true,
|
||||||
no_web: false,
|
no_web,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.and_then(|_| build::manpage(sh))
|
.and_then(|_| build::manpage(sh))
|
||||||
|
|
@ -163,9 +164,29 @@ fn cross_compile(sh: &Shell, target: &OsString) -> anyhow::Result<()> {
|
||||||
|
|
||||||
cross()
|
cross()
|
||||||
.and_then(|cross| {
|
.and_then(|cross| {
|
||||||
cmd!(sh, "{cross} build --verbose --release --target {target}")
|
if no_web {
|
||||||
.run()
|
match metadata::get_no_web_features(sh, ".")
|
||||||
.map_err(anyhow::Error::new)
|
.context("Failed to check web features for cross compilation")?
|
||||||
|
{
|
||||||
|
Some(features) => {
|
||||||
|
let mut cmd = cmd!(sh, "{cross} build --verbose --release --target {target} --no-default-features");
|
||||||
|
if !features.is_empty() {
|
||||||
|
cmd = cmd.arg("--features").arg(features);
|
||||||
|
}
|
||||||
|
cmd.run().map_err(anyhow::Error::new)
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
// Main crate doesn't have web_server_capability, build normally
|
||||||
|
cmd!(sh, "{cross} build --verbose --release --target {target}")
|
||||||
|
.run()
|
||||||
|
.map_err(anyhow::Error::new)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cmd!(sh, "{cross} build --verbose --release --target {target}")
|
||||||
|
.run()
|
||||||
|
.map_err(anyhow::Error::new)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.with_context(err_context)
|
.with_context(err_context)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@ xflags::xflags! {
|
||||||
cmd cross {
|
cmd cross {
|
||||||
/// Target-triple to compile the application for
|
/// Target-triple to compile the application for
|
||||||
required triple: OsString
|
required triple: OsString
|
||||||
|
/// Compile without web server support
|
||||||
|
optional --no-web
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,6 +165,7 @@ pub struct E2e {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Cross {
|
pub struct Cross {
|
||||||
pub triple: OsString,
|
pub triple: OsString,
|
||||||
|
pub no_web: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue