Skip to content

Commit

Permalink
cd: support more targets
Browse files Browse the repository at this point in the history
Signed-off-by: azjezz <azjezz@protonmail.com>
  • Loading branch information
azjezz committed Dec 19, 2024
1 parent 6d42654 commit 8ce888d
Showing 1 changed file with 26 additions and 33 deletions.
59 changes: 26 additions & 33 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,35 +62,30 @@ jobs:
# Windows ( MinGW )
- { target: x86_64-pc-windows-gnu, os: windows-2019 }
# Windows ( MSVC )
- { target: i686-pc-windows-msvc, os: windows-2019 }
- { target: x86_64-pc-windows-msvc, os: windows-2019 }
- { target: i686-pc-windows-msvc, os: windows-2019, test: true }
- { target: x86_64-pc-windows-msvc, os: windows-2019, test: true }
# macOS
- { target: aarch64-apple-darwin, os: macos-15 }
- { target: x86_64-apple-darwin, os: macos-15 }
# *BSD
- { target: aarch64-apple-darwin, os: macos-15, test: true }
- { target: x86_64-apple-darwin, os: macos-15, test: true }
# FreeBSD
- { target: i686-unknown-freebsd, os: ubuntu-20.04 }
- { target: x86_64-unknown-freebsd, os: ubuntu-20.04 }
- { target: x86_64-unknown-netbsd, os: ubuntu-20.04 }
# Linux
- { target: aarch64-unknown-linux-gnu, os: ubuntu-20.04 }
- { target: aarch64-unknown-linux-gnu, os: ubuntu-20.04, test: true }
- { target: arm-unknown-linux-gnueabi, os: ubuntu-20.04 }
- { target: arm-unknown-linux-gnueabihf, os: ubuntu-20.04 }
- { target: armv7-unknown-linux-gnueabihf, os: ubuntu-20.04 }
- { target: arm-unknown-linux-musleabi, os: ubuntu-20.04 }
- { target: arm-unknown-linux-musleabihf, os: ubuntu-20.04 }
- { target: armv7-unknown-linux-musleabihf, os: ubuntu-20.04 }
- { target: i686-unknown-linux-gnu, os: ubuntu-20.04 }
- { target: i686-unknown-linux-musl, os: ubuntu-20.04 }
- { target: mips-unknown-linux-gnu, os: ubuntu-20.04, nightly: true }
- { target: mips64-unknown-linux-gnuabi64, os: ubuntu-20.04, nightly: true }
- { target: mipsel-unknown-linux-gnu, os: ubuntu-20.04, nightly: true }
- { target: mips64el-unknown-linux-gnuabi64, os: ubuntu-20.04, nightly: true }
- { target: i686-unknown-linux-gnu, os: ubuntu-20.04, test: true }
- { target: i686-unknown-linux-musl, os: ubuntu-20.04, test: true }
- { target: powerpc-unknown-linux-gnu, os: ubuntu-20.04 }
- { target: powerpc64-unknown-linux-gnu, os: ubuntu-20.04 }
- { target: powerpc64le-unknown-linux-gnu, os: ubuntu-20.04 }
- { target: s390x-unknown-linux-gnu, os: ubuntu-20.04 }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04 }
- { target: x86_64-unknown-linux-musl, os: ubuntu-20.04 }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04, test: true }
- { target: x86_64-unknown-linux-musl, os: ubuntu-20.04, test: true }

env:
BUILD_CMD: cargo
Expand All @@ -99,12 +94,10 @@ jobs:
- name: checkout source code
uses: actions/checkout@v4

- name: Determine tag version
- name: set version env variable
id: version
shell: bash
run: |
CLEAN_TAG=${GITHUB_REF_NAME#v}
echo "CLEAN_TAG=$CLEAN_TAG" >> $GITHUB_OUTPUT
run: echo "VERSION=${{ needs.crate_metadata.outputs.version }}" >> $GITHUB_OUTPUT

- name: install prerequisites
shell: bash
Expand All @@ -117,9 +110,8 @@ jobs:
- name: install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.job.nightly == 'true' && 'nightly' || 'stable' }}
toolchain: ${{ needs.crate_metadata.outputs.msrv }}
targets: ${{ matrix.job.target }}
override: true

- name: install cross
if: startsWith(matrix.job.os, 'ubuntu')
Expand Down Expand Up @@ -163,6 +155,7 @@ jobs:
echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_OUTPUT
- name: run tests
if: matrix.job.test
shell: bash
run: $BUILD_CMD test --workspace --locked --target=${{ matrix.job.target }}

Expand All @@ -182,18 +175,18 @@ jobs:
id: package
shell: bash
run: |
CLEAN_TAG="${{ steps.version.outputs.CLEAN_TAG }}"
VERSION="${{ steps.version.outputs.VERSION }}"
TARGET="${{ matrix.job.target }}"
PKG_SUFFIX=".tar.gz"
case "$TARGET" in
*-pc-windows-msvc) PKG_SUFFIX=".zip" ;;
esac
PKG_NAME="mago-${CLEAN_TAG}-${TARGET}${PKG_SUFFIX}"
PKG_NAME="mago-${VERSION}-${TARGET}${PKG_SUFFIX}"
echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_OUTPUT
PKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/package"
ARCHIVE_DIR="${PKG_STAGING}/mago-${CLEAN_TAG}-${TARGET}/"
ARCHIVE_DIR="${PKG_STAGING}/mago-${VERSION}-${TARGET}/"
mkdir -p "${ARCHIVE_DIR}"
# Binary
Expand All @@ -205,10 +198,10 @@ jobs:
pushd "${PKG_STAGING}/" >/dev/null
case "$PKG_SUFFIX" in
.zip)
7z -y a "${PKG_NAME}" "mago-${CLEAN_TAG}-${TARGET}/*"
7z -y a "${PKG_NAME}" "mago-${VERSION}-${TARGET}/*"
;;
.tar.gz)
tar czf "${PKG_NAME}" "mago-${CLEAN_TAG}-${TARGET}"/*
tar czf "${PKG_NAME}" "mago-${VERSION}-${TARGET}"/*
;;
esac
popd >/dev/null
Expand All @@ -220,9 +213,9 @@ jobs:
if: matrix.job.target == 'x86_64-unknown-linux-gnu'
shell: bash
run: |
CLEAN_TAG="${{ steps.version.outputs.CLEAN_TAG }}"
# Since WASM is universal, just name it 'mago-{CLEAN_TAG}-wasm.tar.gz'
WASM_PKG_NAME="mago-${CLEAN_TAG}-wasm.tar.gz"
VERSION="${{ steps.version.outputs.VERSION }}"
# Since WASM is universal, just name it 'mago-{VERSION}-wasm.tar.gz'
WASM_PKG_NAME="mago-${VERSION}-wasm.tar.gz"
echo "WASM_PKG_NAME=${WASM_PKG_NAME}" >> $GITHUB_OUTPUT
WASM_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/wasm"
Expand All @@ -235,9 +228,9 @@ jobs:
- name: create Debian package
id: debian-package
shell: bash
if: startsWith(matrix.job.os, 'ubuntu') && !endsWith(matrix.job.target, 'bsd')
if: startsWith(matrix.job.os, 'ubuntu') && !endsWith(matrix.job.target, 'freebsd')
run: |
CLEAN_TAG="${{ steps.version.outputs.CLEAN_TAG }}"
VERSION="${{ steps.version.outputs.VERSION }}"
TARGET="${{ matrix.job.target }}"
# Derive arch from target:
Expand All @@ -252,7 +245,7 @@ jobs:
*s390x*) DPKG_ARCH="s390x" ;;
esac
DPKG_NAME="mago-${CLEAN_TAG}-${TARGET}.deb"
DPKG_NAME="mago-${VERSION}-${TARGET}.deb"
echo "DPKG_NAME=${DPKG_NAME}" >> $GITHUB_OUTPUT
Expand All @@ -269,7 +262,7 @@ jobs:
mkdir -p "${DPKG_DIR}/DEBIAN"
cat > "${DPKG_DIR}/DEBIAN/control" <<EOF
Package: mago
Version: ${CLEAN_TAG}
Version: ${VERSION}
Section: devel
Priority: optional
Maintainer: ${{ needs.crate_metadata.outputs.maintainer }}
Expand Down

0 comments on commit 8ce888d

Please sign in to comment.