summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Isidoro <denisidoro@users.noreply.github.com>2021-04-11 12:04:12 -0300
committerGitHub <noreply@github.com>2021-04-11 12:04:12 -0300
commit9095e376aaf2771fc4c41af65c56afbb14f21297 (patch)
treea9ca73ebb663468cba02676bb5bf418405470d2d
parent5a68b695dadc18320901c6d5c26fc8e7f5c33891 (diff)
Publish binaries for more platforms, including Windows (#490)v2.15.1
-rw-r--r--.github/workflows/cd.yml24
-rwxr-xr-xscripts/action80
2 files changed, 86 insertions, 18 deletions
diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml
index c4611c9..4a76091 100644
--- a/.github/workflows/cd.yml
+++ b/.github/workflows/cd.yml
@@ -26,33 +26,43 @@ jobs:
asset_name: navi-${{ steps.get_version.outputs.VERSION }}.alfredworkflow
binary:
- name: Publish binary for ${{ matrix.os }}
+ name: Publish ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
+ fail-fast: false
matrix:
# This should work with only the `include`s but it currently doesn't because of this bug:
# https://github.community/t5/How-to-use-Git-and-GitHub/GitHub-Actions-Matrix-options-dont-work-as-documented/td-p/29558
- target: [x86_64-osx, x86_64-unknown-linux-musl, armv7-unknown-linux-musleabihf, armv7-linux-androideabi, aarch64-linux-android, x86_64-pc-windows-gnu]
+ target:
+ - x86_64-osx
+ - x86_64-unknown-linux-musl
+ - x86_64-pc-windows-gnu
+ - armv7-unknown-linux-musleabihf
+ - armv7-linux-androideabi
+ - aarch64-linux-android
+ - aarch64-apple-ios
include:
- os: macos-latest
target: x86_64-osx
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: ubuntu-latest
+ target: x86_64-pc-windows-gnu
+ - os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
- os: ubuntu-latest
target: armv7-linux-androideabi
- os: ubuntu-latest
target: aarch64-linux-android
- - os: ubuntu-latest
- target: x86_64-pc-windows-gnu
-
+ - os: macos-latest
+ target: aarch64-apple-ios
steps:
- uses: hecrj/setup-rust-action@v1.3.4
with:
rust-version: stable
- uses: actions/checkout@v1
- name: Build
+ id: build
run: scripts/action release ${{ matrix.target }}
- name: Get the version
id: get_version
@@ -61,6 +71,6 @@ jobs:
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: target/tar/navi.tar.gz
+ file: target/tar/navi.${{ steps.build.outputs.EXTENSION }}
tag: ${{ github.ref }}
- asset_name: navi-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar.gz \ No newline at end of file
+ asset_name: navi-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.${{ steps.build.outputs.EXTENSION }} \ No newline at end of file
diff --git a/scripts/action b/scripts/action
index f2ebdc9..61fe162 100755
--- a/scripts/action
+++ b/scripts/action
@@ -6,38 +6,95 @@ set -euo pipefail
export NAVI_HOME="$(cd "$(dirname "$0")/.." && pwd)"
source "${NAVI_HOME}/scripts/install"
+is_windows() {
+ local -r target="$1"
+ echo "$target" | grep -q "windows"
+}
+
+get_env_target() {
+ eval $(rustc --print cfg | grep target)
+ local r raw="${target_arch}-${target_vendor}-${target_os}-${target_env}"
+ echoerr "env_raw: $raw"
+ if echo "$raw" | grep -q "x86_64-apple-macos"; then
+ echo "x86_64-apple-darwin"
+ else
+ echo "$raw"
+ fi
+}
+
+as_cross_target() {
+ echo "$1" | sed "s/osx/apple-darwin/g"
+}
+
+_tap() {
+ echoerr "$@"
+ "$@"
+}
+
release() {
+ local -r target="${1:-}"
+ echoerr "target: $target"
+ local -r cross_target="$(as_cross_target "$target")"
+ echoerr "cross_target: $cross_target"
TAR_DIR="${NAVI_HOME}/target/tar"
+ local use_zip=false
+ local cross=true
+
+ local -r env_target="$(get_env_target)"
+ echoerr "env_target: $env_target"
- target="${1:-}"
- if [[ $target == *"osx"* ]]; then
- echoerr "OSX cross-compile is impossible. Fallbacking to cargo..."
- target=""
+ if [[ $cross_target == $env_target ]]; then
+ cross=false
fi
cd "$NAVI_HOME"
rm -rf "${NAVI_HOME}/target" 2> /dev/null || true
- if [ -n "$target" ]; then
+ if $cross; then
cargo install cross 2> /dev/null || true
- cross build --release --locked --target "$target"
- bin_folder="${target}/release"
+ _tap cross build --release --locked --target "$cross_target"
+ local -r bin_folder="${cross_target}/release"
else
- cargo build --release --locked
- bin_folder="release"
+ _tap cargo build --release --locked
+ local -r bin_folder="release"
fi
- bin_path="${NAVI_HOME}/target/${bin_folder}/navi"
+ _ls "${bin_folder}"
+
+ if is_windows "$target"; then
+ local -r exe_ext=".exe"
+ use_zip=true
+ else
+ local -r exe_ext=""
+ fi
+
+ bin_path="${NAVI_HOME}/target/${bin_folder}/navi${exe_ext}"
+
chmod +x "$bin_path"
mkdir -p "$TAR_DIR" 2> /dev/null || true
cp "$bin_path" "$TAR_DIR"
cd "$TAR_DIR"
- tar -czf navi.tar.gz *
+ if $use_zip; then
+ zip -r navi.zip *
+ echo ::set-output name=EXTENSION::zip
+ else
+ tar -czf navi.tar.gz *
+ echo ::set-output name=EXTENSION::tar.gz
+ fi
+
+ _ls "${bin_path}"
+ _ls "${TAR_DIR}"
+
+}
+
+_ls() {
+ echoerr "contents from $@:"
+ ls -la "$@" || true
}
workflow() {
@@ -62,4 +119,5 @@ shift
case "$cmd" in
"release") release "$@" ;;
"workflow") workflow "$@" ;;
+ *) exit 2 ;;
esac