diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2c2e096..96a2d2a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,52 +6,93 @@ on: - "*" jobs: - release: - name: Release binary for ${{ matrix.os }} - runs-on: ${{ matrix.os }} + release-to-github: + name: Release to GitHub for ${{ matrix.job.target }} + runs-on: ${{ matrix.job.os }} strategy: matrix: - target: - [ - x86_64-osx, - x86_64-unknown-linux-musl, - armv7-unknown-linux-musleabihf, - armv7-linux-androideabi, - aarch64-linux-android, - ] - include: - - os: macos-latest - target: x86_64-osx - - os: ubuntu-latest - target: x86_64-unknown-linux-musl - - os: ubuntu-latest - target: armv7-unknown-linux-musleabihf - - os: ubuntu-latest - target: armv7-linux-androideabi - - os: ubuntu-latest - target: aarch64-linux-android + job: + - { + os: ubuntu-latest, + target: x86_64-unknown-linux-gnu, + use-cross: true, + } + - { + os: ubuntu-latest, + target: aarch64-unknown-linux-gnu, + use-cross: true, + } + - { os: macos-latest, target: x86_64-apple-darwin, use-cross: false } + - { os: macos-latest, target: aarch64-apple-darwin, use-cross: false } + - { + os: ubuntu-latest, + target: x86_64-pc-windows-gnu, + use-cross: true, + } + - { + os: windows-latest, + target: x86_64-pc-windows-msvc, + use-cross: false, + } + - { + os: windows-latest, + target: aarch64-pc-windows-msvc, + use-cross: false, + } steps: - - name: Install libssl-dev - if: ${{ matrix.os == 'ubuntu-latest' }} - run: sudo apt-get update && sudo apt-get install libssl-dev + - name: Install dependencies + shell: bash + run: | + if [[ ${{ matrix.job.target }} == "aarch64-unknown-linux-gnu" ]]; then + sudo apt update + sudo apt install -y binutils-aarch64-linux-gnu + fi - - uses: hecrj/setup-rust-action@v1 + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 with: - rust-version: stable + toolchain: stable + target: ${{ matrix.job.target }} + profile: minimal + override: true - - uses: actions/checkout@v1 - - name: Build - run: meta/build.sh release ${{ matrix.target }} + - name: Checkout repository + uses: actions/checkout@v2 - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + - name: Cargo build + uses: actions-rs/cargo@v1 + with: + command: build + use-cross: ${{ matrix.job.use-cross }} + args: --release --target ${{ matrix.job.target }} + + - name: Package final binary + shell: bash + env: + TARGET: ${{ matrix.job.target }} + PROJECT_NAME: koji + OS_NAME: ${{ matrix.job.os }} + run: ./meta/ci/package.sh + + - name: Release assets + uses: softprops/action-gh-release@v1 + with: + files: koji-*-${{ matrix.job.target }}.* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Upload binaries to release - uses: svenstaro/upload-release-action@v1-release + release-to-cargo: + name: Release to Cargo + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + - uses: actions-rs/cargo@v1 with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: target/tar/koji.tar.gz - tag: ${{ github.ref }} - asset_name: koji-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar.gz + command: publish + args: --token ${{ secrets.CARGO_API_KEY }} --allow-dirty diff --git a/Cargo.lock b/Cargo.lock index 0c60d02..77f1ffa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -576,6 +576,7 @@ dependencies = [ "emojis", "git2", "linked-hash-map", + "openssl-sys", "requestty", "rusty-hook", "serde", @@ -760,6 +761,15 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" +[[package]] +name = "openssl-src" +version = "111.18.0+1.1.1n" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7897a926e1e8d00219127dc020130eca4292e5ca666dd592480d72c3eca2ff6c" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.72" @@ -769,6 +779,7 @@ dependencies = [ "autocfg", "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] diff --git a/Cargo.toml b/Cargo.toml index fb51dbf..ec757a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ dirs = "4.0.0" emojis = "0.4.0" git2 = "0.14.3" linked-hash-map = "0.5.4" +openssl-sys = { version = "0.9.72", features = [ "vendored" ] } requestty = "0.3.0" serde = { version = "1.0.136", features = [ "derive" ] } toml = "0.5.9" diff --git a/LICENSE b/LICENSE index 65efab1..1d0aea1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021-Present Danny Tatom +Copyright (c) 2021 Danny Tatom and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/README.md b/README.md index b01a2e8..eb6f23b 100644 --- a/README.md +++ b/README.md @@ -27,17 +27,19 @@ for automatic versioning, changelog generation, and more ## Installation +### webi + ```bash curl -sS https://webinstall.dev/koji | bash ``` -Make sure to have both [git](https://git-scm.com/) and openssl installed first. +### cargo -There are offical releases for OSX and Linux. Windows should work if you build manually, -I'm just not sure how to automate it with the current release setup. +```bash +cargo install --locked koji +``` -**Note:** Refer to [this comment](https://github.com/its-danny/koji/issues/53#issuecomment-1076690486) -for getting it to work on an M1 Macbook Pro. +Be sure to have [git](https://git-scm.com/) installed first. ## Usage @@ -131,4 +133,4 @@ autocomplete = true name = "feat" emoji = "✨" description = "A new feature" -``` \ No newline at end of file +``` diff --git a/meta/build.sh b/meta/build.sh deleted file mode 100755 index 47bdbe4..0000000 --- a/meta/build.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -export KOJI_HOME="$(cd "$(dirname "$0")/.." && pwd)" - -echoerr() { - echo "$@" 1>&2 -} - -release() { - TAR_DIR="${KOJI_HOME}/target/tar" - - target="${1:-}" - - if [[ $target == *"osx"* ]]; then - echoerr "OSX cross-compile is impossible. Fallbacking to cargo..." - target="" - fi - - cd "$KOJI_HOME" - - rm -rf "${KOJI_HOME}/target" 2> /dev/null || true - - if [ -n "$target" ]; then - cargo install --version 0.1.16 cross 2> /dev/null || true - cross build --release --target "$target" - bin_folder="${target}/release" - else - cargo build --release - bin_folder="release" - fi - - koji_bin_path="${KOJI_HOME}/target/${bin_folder}/koji" - chmod +x "$koji_bin_path" - mkdir -p "$TAR_DIR" 2> /dev/null || true - - cp "$koji_bin_path" "$TAR_DIR" - cp "$KOJI_HOME/LICENSE" "$TAR_DIR" - - cd "$TAR_DIR" - tar -czf koji.tar.gz * -} - -cmd="$1" -shift - -release "$@" \ No newline at end of file diff --git a/meta/ci/package.sh b/meta/ci/package.sh new file mode 100755 index 0000000..c395f8b --- /dev/null +++ b/meta/ci/package.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +set -ex + +pack() { + local tempdir + local out_dir + local package_name + local gcc_prefix + local extension + + tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp) + out_dir=$(pwd) + package_name="$PROJECT_NAME-${GITHUB_REF/refs\/tags\//}-$TARGET" + + if [[ $TARGET == "aarch64-unknown-linux-gnu" ]]; then + gcc_prefix="aarch64-linux-gnu-" + else + gcc_prefix="" + fi + + if [[ $TARGET == *"windows"* ]]; then + extension=".exe" + else + extension="" + fi + + mkdir "$tempdir/$package_name" + + cp "target/$TARGET/release/$PROJECT_NAME$extension" "$tempdir/$package_name/" + + if [[ $OS_NAME != "windows-latest" ]]; then + "${gcc_prefix}"strip "$tempdir/$package_name/$PROJECT_NAME$extension" + fi + + cp LICENSE "$tempdir/$package_name" + + pushd "$tempdir" + if [[ $OS_NAME == "windows-latest" ]]; then + 7z a "$out_dir/$package_name.zip" "$package_name"/* + else + tar czf "$out_dir/$package_name.tar.gz" "$package_name"/* + fi + popd + + rm -r "$tempdir" +} + +pack