index : static-web-server.git

ascending towards madness

author Jose Quintana <joseluisquintana20@gmail.com> 2021-07-02 20:31:43.0 +00:00:00
committer Jose Quintana <joseluisquintana20@gmail.com> 2021-07-02 20:31:43.0 +00:00:00
commit
f66eb6d60f918e014cb3e9a4c7b6217feaa5390f [patch]
tree
3c082cb86696e247b26503a99e9b26e4daed53ef
parent
59cf8bc5ec768cf95371ff983fc68b0e3f4abd57
download
f66eb6d60f918e014cb3e9a4c7b6217feaa5390f.tar.gz

feat: freebsd i686/x86_64 targets

- i686-unknown-freebsd
- x86_64-unknown-freebsd

Diff

 .cirrus.yml        | 38 ++++++++++++++++++++++++++++++++++++--
 scripts/release.sh | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index d1301dd..794764b 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -6,9 +6,9 @@ freebsd_instance:
# 64-bit kernel and in a 64-bit environment. Our tests don't execute
# any of the system's binaries, so the environment shouldn't matter.
task:
  name: FreeBSD
  name: freebsd-test
  only_if: $CIRRUS_TAG == ''
  env:
    LOOM_MAX_PREEMPTIONS: 2
    RUSTFLAGS: -Dwarnings
  setup_script:
    - pkg install -y bash curl
@@ -30,3 +30,37 @@ task:
    - . $HOME/.cargo/env
    - |
      cargo build --verbose

task:
  name: freebsd-release
  only_if: $CIRRUS_TAG != ''
  env:
    RUSTFLAGS: -Dwarnings
    GITHUB_TOKEN: ENCRYPTED[d1766ef328d83729917d2ffb875d64c35d1c0177edf8f32e66ec464daf5c1b7b145d65fc6c044a73fffe2235d3b38349]
  setup_script:
    - pkg install -y bash curl
    - curl https://sh.rustup.rs -sSf --output rustup.sh
    - sh rustup.sh -y --profile minimal --default-toolchain stable
    - . $HOME/.cargo/env
    - rustup target add i686-unknown-freebsd
    - |
      echo "~~~~ rustc --version ~~~~"
      rustc --version
  build_script:
    - cargo build --verbose --release --target=x86_64-unknown-freebsd
    - cargo build --verbose --release --target=i686-unknown-freebsd
  archive_x86_64_script:
    - |
      staging="static-web-server-$CIRRUS_TAG-x86_64-unknown-freebsd"
      mkdir -p "$staging/"
      cp "target/release/static-web-server" "$staging/"
      cp {README.md,LICENSE-APACHE,LICENSE-MIT} "$staging/"
      tar czf "$staging.tar.gz" "$staging"
  archive_i686_script:
    - |
      staging="static-web-server-$CIRRUS_TAG-i686-unknown-freebsd"
      mkdir -p "$staging/"
      cp "target/i686-unknown-freebsd/release/static-web-server" "$staging/"
      cp {README.md,LICENSE-APACHE,LICENSE-MIT} "$staging/"
      tar czf "$staging.tar.gz" "$staging"
  upload_script: ./scripts/release.sh
diff --git a/scripts/release.sh b/scripts/release.sh
new file mode 100755
index 0000000..b08fe18
--- /dev/null
+++ b/scripts/release.sh
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

echo "Creating a Github release..."

if [[ "$CIRRUS_RELEASE" == "" ]]; then
  echo "Not a Github release. Nothing to deploy!"
  exit 0
fi

if [[ "$GITHUB_TOKEN" == "" ]]; then
  echo "Please provide GitHub access token via GITHUB_TOKEN environment variable!"
  exit 1
fi

file_content_type="application/octet-stream"
files_to_upload=(
  static-web-server-$CIRRUS_TAG-i686-unknown-freebsd.tar.gz
  static-web-server-$CIRRUS_TAG-x86_64-unknown-freebsd.tar.gz
)

for fpath in $files_to_upload
do
  echo "Uploading Github release asset $fpath..."
  name=$(basename "$fpath")
  url_to_upload="https://uploads.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases/$CIRRUS_RELEASE/assets?name=$name"
  curl -X POST \
    --data-binary @$fpath \
    --header "Authorization: token $GITHUB_TOKEN" \
    --header "Content-Type: $file_content_type" \
    $url_to_upload
done

echo
echo "Releases published successfully."