From c0fe2398bb9ca1cc2710855804576c2cf4867661 Mon Sep 17 00:00:00 2001 From: Bruce Adams Date: Wed, 7 Apr 2021 21:09:01 -0400 Subject: [PATCH] Switch builds to Cirrus --- .cirrus.yml | 143 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 73 ----------------- .github/workflows/rust.yml | 25 ------ Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 41 +++++----- upload-binary.sh | 24 ++++++ 7 files changed, 189 insertions(+), 121 deletions(-) create mode 100644 .cirrus.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/rust.yml create mode 100755 upload-binary.sh diff --git a/.cirrus.yml b/.cirrus.yml new file mode 100644 index 0000000..bcfaf6f --- /dev/null +++ b/.cirrus.yml @@ -0,0 +1,143 @@ +env: + GITHUB_TOKEN: ENCRYPTED[1c2ef2877c7f171e40a831f61367e810b57010d6b2eded04f68177e3ec096c3c85619be02f3f0c081fd1eb9b64dd15bb] + +macos_universal_task: + macos_instance: + image: big-sur-xcode + env: + RUST_HOME: $HOME/macos + CARGO_HOME: $RUST_HOME/cargo + RUSTUP_HOME: $RUST_HOME/rustup + PATH: $CARGO_HOME/bin:$PATH + rust_cache: + folder: $RUST_HOME + reupload_on_changes: true + fingerprint_script: + - echo $CIRRUS_OS + - date +%Y + populate_script: > + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | + sh -s -- -y --verbose --no-modify-path --target aarch64-apple-darwin + update_script: rustup --verbose update + target_cache: + folder: target + reupload_on_changes: true + fingerprint_script: + - echo $CIRRUS_OS + - rustc --version + build_script: + - cargo build --verbose --release --target aarch64-apple-darwin + - mv target/aarch64-apple-darwin/release/yj yj.macos.aarch64 + - cargo build --verbose --release --target x86_64-apple-darwin + - mv target/x86_64-apple-darwin/release/yj yj.macos.x86_64 + - lipo -create -output yj.macos.universal yj.macos.aarch64 yj.macos.x86_64 + - file yj.macos.universal + binary_artifacts: + path: yj.macos.* + release_script: ./upload-binary.sh yj.macos.* + before_cache_script: rm -f target/.rustc_info.json + +linux_x68_64_task: + container: + image: rust:latest + registry_cache: + folder: $CARGO_HOME/registry + reupload_on_changes: true + fingerprint_script: date +%Y + target_cache: + folder: target + reupload_on_changes: true + fingerprint_script: + - echo $CIRRUS_OS + - rustc --version + setup_script: + - echo NOPE apt-get update + - echo NOPE apt-get --yes install musl-tools + - rustup target add x86_64-unknown-linux-musl + build_script: + - cargo build --verbose --release --target x86_64-unknown-linux-musl + - mv target/x86_64-unknown-linux-musl/release/yj yj.$CIRRUS_OS.x86_64 + - file yj.$CIRRUS_OS.x86_64 + - ldd yj.$CIRRUS_OS.x86_64 + binary_artifacts: + path: yj.$CIRRUS_OS.* + release_script: ./upload-binary.sh yj.$CIRRUS_OS.* + before_cache_script: rm -f target/.rustc_info.json + +freebsd_x86_task: + freebsd_instance: + image_family: freebsd-12-2 + env: + RUST_HOME: $HOME/freebsd + CARGO_HOME: $RUST_HOME/cargo + RUSTUP_HOME: $RUST_HOME/rustup + PATH: $CARGO_HOME/bin:$PATH + rust_cache: + folder: $RUST_HOME + reupload_on_changes: true + fingerprint_script: + - echo $CIRRUS_OS + - date +%Y + populate_script: > + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | + sh -s -- -y --verbose --no-modify-path + update_script: rustup --verbose update + target_cache: + folder: target + reupload_on_changes: true + fingerprint_script: + - echo $CIRRUS_OS + - rustc --version + build_script: + - cargo build --verbose --release + - mv target/release/yj yj.$CIRRUS_OS.x86_64 + - file yj.$CIRRUS_OS.x86_64 + binary_artifacts: + path: yj.$CIRRUS_OS.* + release_script: ./upload-binary.sh yj.$CIRRUS_OS.* + before_cache_script: rm -f target/.rustc_info.json + +windows_x86_task: + windows_container: + image: cirrusci/windowsservercore:2019 + env: + RUST_HOME: C:\Users\ContainerAdministrator\rust + CARGO_HOME: $RUST_HOME\cargo + RUSTUP_HOME: $RUST_HOME\rustup + PATH: $CARGO_HOME\bin;$PATH + vs_cpp_script: + - curl -fSLo vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe + - > + vs_buildtools.exe --quiet --wait --norestart --nocache + --installPath C:\BuildTools + --add Microsoft.Component.MSBuild + --add Microsoft.VisualStudio.Component.Windows10SDK.18362 + --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 + --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 + rust_cache: + folder: $RUST_HOME + reupload_on_changes: true + fingerprint_script: + - echo %CIRRUS_OS% + - echo plusarm + - date /t + populate_script: + - curl -fSLo rustup-init.exe https://win.rustup.rs/x86_64 + - rustup-init.exe -y --verbose --target aarch64-pc-windows-msvc + - del rustup-init.exe + update_script: + - rustup --verbose update + target_cache: + folder: target + reupload_on_changes: true + fingerprint_script: + - echo %CIRRUS_OS% + - rustc --version + build_script: + - cargo build --verbose --release --target aarch64-pc-windows-msvc + - move target\aarch64-pc-windows-msvc\release\yj.exe yj.%CIRRUS_OS%.aarch64.exe + - cargo build --verbose --release --target x86_64-pc-windows-msvc + - move target\x86_64-pc-windows-msvc\release\yj.exe yj.%CIRRUS_OS%.x86_64.exe + binary_artifacts: + path: yj.%CIRRUS_OS%.* + before_cache_script: del target\.rustc_info.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index d82fe72..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Release Binaries - -on: - release: - types: [created] - -env: - GITHUB_TOKEN: ${{ github.token }} - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: [macos-11.0, ubuntu-latest, windows-latest] - include: - - os: macos-11.0 - x86_64: ./target/release/yj - aarch64: ./target/aarch64-apple-darwin/release/yj - name: macos - - os: ubuntu-latest - x86_64: ./target/x86_64-unknown-linux-musl/release/yj - aarch64: ./target/aarch64-unknown-linux-gnu/release/yj - name: linux - - os: windows-latest - x86_64: ./target/release/yj.exe - aarch64: ./target/aarch64-pc-windows-msvc/release/yj.exe - name: exe - - steps: - - name: Checkout - uses: actions/checkout@v1 - - name: Get Release - id: get_release - uses: bruceadams/get-release@v1.2.0 - - name: Update - run: rustup update - - name: Linux build - if: runner.os == 'Linux' - run: | - sudo apt-get install musl-tools - rustup target add x86_64-unknown-linux-musl - rustup target add aarch64-unknown-linux-gnu - cargo build --release --target x86_64-unknown-linux-musl --verbose - cargo build --release --target aarch64-unknown-linux-gnu --verbose - - name: macOS Build - if: runner.os == 'macOS' - run: | - rustup toolchain install beta - rustup target add --toolchain beta aarch64-apple-darwin - cargo build --release --verbose - cargo +beta build --release --target aarch64-apple-darwin --verbose - - name: Windows build - if: runner.os == 'Windows' - run: | - rustup target add aarch64-pc-windows-msvc - cargo build --release --verbose - cargo build --release --target aarch64-pc-windows-msvc --verbose - - name: Upload x86_64 Binary - uses: actions/upload-release-asset@v1.0.1 - with: - upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ${{ matrix.x86_64 }} - asset_name: yj.x86_64.${{ matrix.name }} - asset_content_type: application/octet-stream - - name: Upload aarch64 Binary - uses: actions/upload-release-asset@v1.0.1 - with: - upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ${{ matrix.aarch64 }} - asset_name: yj.aarch64.${{ matrix.name }} - asset_content_type: application/octet-stream diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml deleted file mode 100644 index 689a9ca..0000000 --- a/.github/workflows/rust.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Rust - -on: [push, pull_request] - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - - steps: - - name: Checkout - uses: actions/checkout@v1 - - name: Update - run: | - rustup update - rustup component add clippy - - name: Build - run: cargo build --verbose - - name: Clippy - run: cargo clippy --verbose - - name: Run tests - run: cargo test --verbose diff --git a/Cargo.lock b/Cargo.lock index 8d7debd..26f1b0d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -454,7 +454,7 @@ dependencies = [ [[package]] name = "yj" -version = "1.1.30" +version = "1.1.33" dependencies = [ "clap", "exitfailure", diff --git a/Cargo.toml b/Cargo.toml index 33f1193..6f972a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yj" -version = "1.1.30" +version = "1.1.33" authors = ["Bruce Adams "] categories = ["command-line-utilities"] description = "Command line tool that converts YAML to JSON" diff --git a/README.md b/README.md index 29c2887..db986fd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # YJ - YAML to JSON -![Rust](https://github.com/bruceadams/yj/workflows/Rust/badge.svg) +![Rust](https://api.cirrus-ci.com/github/bruceadams/yj.svg) Simple command line tool to convert a YAML input file into a JSON output file. @@ -9,34 +9,30 @@ Simple command line tool to convert a YAML input file into a JSON output file. ```bash $ yj --help -yj 1.1.25 +yj 1.1.33 Bruce Adams Read YAML, write JSON USAGE: - yj.exe [FLAGS] [OPTIONS] [input] + yj [FLAGS] [OPTIONS] [input] + +ARGS: + Input YAML file name. Defaults to stdin FLAGS: - -c, --compact Use compact formatting for the JSON output. + -c, --compact Use compact formatting for the JSON output -h, --help Prints help information - -j, --json Parse the input as JSON. For most use - cases, this option makes no difference. - Valid JSON is valid YAML, so JSON input - will (should?) parse correctly even when - being handled with the YAML parser. Use - this option when you want failure (instead - of weird results) when the input is invalid - JSON. + -j, --json Parse the input as JSON. For most use cases, this option + makes no difference. Valid JSON is valid YAML, so JSON + input will (should?) parse correctly even when being + handled with the YAML parser. Use this option when you + want failure (instead of weird results) when the input is + invalid JSON -V, --version Prints version information - -y, --yaml Format the output as YAML instead of JSON. + -y, --yaml Format the output as YAML instead of JSON OPTIONS: - -o, --output - Output file name for the JSON. Defaults to stdout. - - -ARGS: - Input YAML file name. Defaults to stdin. + -o, --output Output file name for the JSON. Defaults to stdout ``` ### Installing @@ -47,7 +43,9 @@ Local build and install with `cargo`: $ cargo install yj ``` -Prebuilt binaries are available on [Github releases](https://github.com/bruceadams/yj/releases) for 64bit x86 for Windows, Linux and macOS. +Prebuilt binaries are available on +[Github releases](https://github.com/bruceadams/yj/releases) +for some common platforms. On macOS, the prebuilt binary can be installed using [Homebrew](https://brew.sh). @@ -56,7 +54,8 @@ $ brew tap bruceadams/utilities $ brew install yj ``` -Minimal Docker images are available on [Docker Hub](https://cloud.docker.com/repository/docker/bruceadams/yj): +Minimal Docker images are available on +[Docker Hub](https://cloud.docker.com/repository/docker/bruceadams/yj): ```bash $ docker pull bruceadams/yj diff --git a/upload-binary.sh b/upload-binary.sh new file mode 100755 index 0000000..9795bd8 --- /dev/null +++ b/upload-binary.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +if [ -z "$CIRRUS_RELEASE" ]; then + echo "Not a release. No need to deploy!" + exit 0 +fi + +if [ -z "$GITHUB_TOKEN" ]; then + echo "Please provide GitHub access token via GITHUB_TOKEN environment variable!" + exit 1 +fi + +UPLOAD_URL=https://uploads.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases/$CIRRUS_RELEASE/assets +CONTENT_TYPE=application/octet-stream + +for path in "$@"; do + echo "Uploading $path..." + curl -X POST \ + --header "Accept: application/vnd.github.v3+json" \ + --header "Authorization: token $GITHUB_TOKEN" \ + --header "Content-Type: $CONTENT_TYPE" \ + --data-binary "@$path" \ + "$UPLOAD_URL?name=$(basename "$path")" +done