Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script to install from the terminal #427

Merged
merged 7 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .Dockerignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.git
.github
config
docs
target
utils
Cargo.lock
Docker*
flake*
LICENSE
README.md
screenshot.png

76 changes: 37 additions & 39 deletions .github/workflows/automated-build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

name: Automated build
env:
CI_INTERMEDIATES_DIR: "_ci-intermediates"
Expand All @@ -17,9 +18,11 @@ jobs:
job:
- {os: ubuntu-20.04, target: arm-unknown-linux-gnueabihf, use-cross: true}
- {os: ubuntu-20.04, target: arm-unknown-linux-musleabihf, use-cross: true}
- {os: ubuntu-20.04, target: aarch64-unknown-linux-musl, use-cross: true}
- {os: ubuntu-20.04, target: aarch64-unknown-linux-gnu, use-cross: true}
- {os: ubuntu-20.04, target: x86_64-unknown-linux-gnu}
- {os: ubuntu-20.04, target: x86_64-unknown-linux-musl, use-cross: true}
- {os: ubuntu-20.04, target: x86_64-unknown-linux-gnu}
- {os: macos-latest, target: aarch64-apple-darwin}
- {os: macos-13, target: x86_64-apple-darwin}
steps:
- name: Checkout source code
Expand Down Expand Up @@ -60,8 +63,8 @@ jobs:
use-cross: ${{ matrix.job.use-cross }}
command: build
args: --locked --release --target=${{ matrix.job.target }}
- name: Strip debug information from executable
id: strip
- name: Create tarball
id: package
shell: bash
run: |
# Figure out suffix of binary
Expand All @@ -70,45 +73,16 @@ jobs:
*-pc-windows-*) EXE_suffix=".exe" ;;
esac;

# Figure out what strip tool to use if any
STRIP="strip"
case ${{ matrix.job.target }} in
arm-unknown-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;
aarch64-unknown-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;;
*-pc-windows-msvc) STRIP="" ;;
esac;

# Setup paths
BIN_DIR="${{ env.CI_INTERMEDIATES_DIR }}/stripped-release-bin/"
mkdir -p "${BIN_DIR}"
BIN_NAME="${{ env.PROJECT_NAME }}${EXE_suffix}"
BIN_PATH="${BIN_DIR}/${BIN_NAME}"

# Copy the release build binary to the result location
cp "target/${{ matrix.job.target }}/release/${BIN_NAME}" "${BIN_DIR}"

# Also strip if possible
if [ -n "${STRIP}" ]; then
"${STRIP}" "${BIN_PATH}"
fi

# Let subsequent steps know where to find the (stripped) bin
echo ::set-output name=BIN_PATH::${BIN_PATH}
echo ::set-output name=BIN_NAME::${BIN_NAME}
- name: Create tarball
id: package
shell: bash
run: |
PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac;
PKG_BASENAME=${PROJECT_NAME}-v${PROJECT_VERSION}-${{ matrix.job.target }}
PKG_NAME=${PKG_BASENAME}${PKG_suffix}
echo ::set-output name=PKG_NAME::${PKG_NAME}
PKG_STAGING="${{ env.CI_INTERMEDIATES_DIR }}/package"
ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/"
mkdir -p "${ARCHIVE_DIR}"

# Binary
cp "${{ steps.strip.outputs.BIN_PATH }}" "$ARCHIVE_DIR"
cp "target/${{ matrix.job.target }}/release/${BIN_NAME}" "$ARCHIVE_DIR"

# base compressed package
pushd "${PKG_STAGING}/" >/dev/null
Expand All @@ -119,23 +93,47 @@ jobs:
popd >/dev/null

# Let subsequent steps know where to find the compressed package
echo ::set-output name=PKG_PATH::"${PKG_STAGING}/${PKG_NAME}"
echo "PKG_PATH=${PKG_STAGING}/${PKG_NAME}" >> $GITHUB_ENV
echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_ENV
echo "PKG_STAGING=${PKG_STAGING}" >> $GITHUB_ENV
- name: "Generate checksum"
id: checksum
shell: bash
run: |
SUM_NAME=${{ env.PKG_NAME }}.sha256sum
SUM_PATH=${PKG_STAGING}/${SUM_NAME}
OS="$(uname -s)"

if [ "$OS" == "Linux" ]; then
sha256sum ${PKG_PATH} > ${SUM_PATH}
elif [ "$OS" == "Darwin" ]; then
shasum -a 256 ${PKG_PATH} > ${SUM_PATH}
fi

echo "SUM_NAME=${SUM_NAME}" >> $GITHUB_ENV
echo "SUM_PATH=${SUM_PATH}" >> $GITHUB_ENV
- name: "Artifact upload: tarball"
uses: actions/upload-artifact@master
with:
name: ${{ steps.package.outputs.PKG_NAME }}
path: ${{ steps.package.outputs.PKG_PATH }}
name: ${{ env.PKG_NAME }}
path: ${{ env.PKG_PATH }}
- name: "Artifact upload: checksum"
uses: actions/upload-artifact@master
with:
name: ${{ env.SUM_NAME }}
path: ${{ env.SUM_PATH }}
- name: Check for release
id: is-release
shell: bash
run: |
unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/v[0-9].* ]]; then IS_RELEASE='true' ; fi
echo ::set-output name=IS_RELEASE::${IS_RELEASE}
echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_ENV
- name: Publish archives and packages
uses: softprops/action-gh-release@v1
if: steps.is-release.outputs.IS_RELEASE
if: env.IS_RELEASE
with:
files: |
${{ steps.package.outputs.PKG_PATH }}
${{ env.PKG_PATH }}
${{ env.SUM_PATH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ edition = "2021"
keywords = ["tui-rs", "ranger", "file_manager", "termion"]
categories = ['command-line-interface', 'command-line-utilities']

[profile.release]
strip = true

[dependencies]
alphanumeric-sort = "^1"
ansi-to-tui = { version = "^3.1.0", optional = true }
Expand Down
15 changes: 0 additions & 15 deletions Dockerfile

This file was deleted.

36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,42 @@ Also see [Cargo.toml](Cargo.toml)
~# cargo install --path=. --force --root=/usr/local # /usr also works
```

#### From pre-compiled binary

Dependencies:
- curl
- openssl

##### Latest release

Installs the latest version using the default installation path (_$HOME/.local/bin/_).

``` bash
~$ bash <(curl -s https://raw.githubusercontent.com/kamiyaa/joshuto/master/utils/install.sh)
```

##### Custom Installation path

Allows you to install Joshuto to a custom directory by setting the INSTALL_PREFIX variable.

``` bash
~$ INSTALL_PREFIX="$HOME" bash <(curl -s https://raw.githubusercontent.com/kamiyaa/joshuto/master/utils/install.sh)
```

##### System wide

``` bash
~# INSTALL_PREFIX="/usr/local/bin" bash <(curl -s https://raw.githubusercontent.com/kamiyaa/joshuto/master/utils/install.sh)
```

##### Specific release

Installs a specific release version of Joshuto by the desired version number.

``` bash
~$ RELEASE_VER='v0.9.4' bash <(curl -s https://raw.githubusercontent.com/kamiyaa/joshuto/master/utils/install.sh)
```

#### Packaging status

##### Fedora ([COPR](https://copr.fedorainfracloud.org/coprs/atim/joshuto/))
Expand Down
19 changes: 19 additions & 0 deletions utils/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# For images like alpine, busybox, scratch with no libc you can use musl targets instead
#
# docker build -t joshuto:local-dev -f utils/docker/Dockerfile \
# --build-arg TARGET="x86_64-unknown-linux-musl" \
# --build-arg RELEASE_I="scratch" .

ARG RELEASE_I="ubuntu:lunar"
ARG TARGET

FROM ${RELEASE_I}

ARG TARGET

COPY ./target/${TARGET}/release/joshuto /usr/local/bin/joshuto
COPY ./config/ /root/.config/joshuto/

WORKDIR /root

ENTRYPOINT ["/usr/local/bin/joshuto"]
28 changes: 28 additions & 0 deletions utils/docker/builder.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# docker build -t joshuto:local-dev -f utils/docker/builder.Dockerfile \
# --build-arg TARGET="x86_64-unknown-linux-musl" \
# --build-arg RELEASE_I="scratch" .

ARG RELEASE_I="busybox:latest"
ARG TARGET="x86_64-unknown-linux-musl"

FROM rust:latest AS builder

ARG TARGET

COPY . /usr/src/joshuto

WORKDIR /usr/src/joshuto

RUN rustup target add ${TARGET} && rustup target add ${TARGET}
RUN cargo build --target ${TARGET} --release

FROM ${RELEASE_I} AS release

ARG TARGET

COPY --from=builder /usr/src/joshuto/target/${TARGET}/release/joshuto /usr/local/bin/joshuto
COPY ./config/ /root/.config/joshuto/

WORKDIR /root

ENTRYPOINT ["/usr/local/bin/joshuto"]
Loading