Skip to content

Commit

Permalink
Switch builds to Cirrus
Browse files Browse the repository at this point in the history
  • Loading branch information
bruceadams committed Apr 8, 2021
1 parent 3245756 commit c0fe239
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 121 deletions.
143 changes: 143 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -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
73 changes: 0 additions & 73 deletions .github/workflows/release.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/rust.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yj"
version = "1.1.30"
version = "1.1.33"
authors = ["Bruce Adams <[email protected]>"]
categories = ["command-line-utilities"]
description = "Command line tool that converts YAML to JSON"
Expand Down
41 changes: 20 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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 <[email protected]>
Read YAML, write JSON

USAGE:
yj.exe [FLAGS] [OPTIONS] [input]
yj [FLAGS] [OPTIONS] [input]

ARGS:
<input> 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>
Output file name for the JSON. Defaults to stdout.


ARGS:
<input> Input YAML file name. Defaults to stdin.
-o, --output <output> Output file name for the JSON. Defaults to stdout
```

### Installing
Expand All @@ -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).

Expand All @@ -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
Expand Down
24 changes: 24 additions & 0 deletions upload-binary.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c0fe239

Please sign in to comment.