Skip to content

Commit

Permalink
Merge branch 'release/sameold-0.2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
cbs228 committed Feb 12, 2023
2 parents cd345d4 + 5ab0e21 commit 5daa2b7
Show file tree
Hide file tree
Showing 15 changed files with 601 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target
.git
.github
297 changes: 297 additions & 0 deletions .github/workflows/rust_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
name: Release

on:
push:
branches: [ "release/**", "develop" ]
tags: [ "samedec-*" ]

permissions:
contents: write

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
# Linux builds, with Docker and qemu as required
release_linux:
runs-on: ubuntu-latest

env:
# See <https://hub.docker.com/_/rust> for list of tags
BUILD_RUST_TAG: 1.67.0
BUILD_OS_GNU: slim-buster
BUILD_OS_MUSL: alpine

strategy:
matrix:
include:
- docker: linux/amd64
os: slim-buster
rust: x86_64-unknown-linux-gnu

- docker: linux/amd64
os: alpine
rust: x86_64-unknown-linux-musl

- docker: linux/arm64
os: slim-buster
rust: aarch64-unknown-linux-gnu

- docker: linux/arm64
os: alpine
rust: aarch64-unknown-linux-musl

- docker: linux/arm/v7
os: slim-buster
rust: armv7-unknown-linux-gnueabihf

steps:
- uses: actions/checkout@v3

- name: Workaround for https://github.com/rust-lang/cargo/issues/8719
run: |
sudo mkdir -p /var/lib/docker
sudo mount -t tmpfs -o size=10G none /var/lib/docker
sudo systemctl restart docker
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Prepare output directory
run: |
mkdir -m 700 -p "install/bin"
# Builds a special target in our Dockerfile which builds
# an empty image containing only our Rust binary. This task
# exports the file to
# install/bin/samedec-x86_64-unknown-linux-gnu
# and the like.
- name: Build
uses: docker/build-push-action@v3
with:
context: .
push: false
load: false
cache-from: type=gha,scope=${{ matrix.os }}_${{ matrix.rust }}
cache-to: type=gha,mode=max,scope=${{ matrix.os }}_${{ matrix.rust }}
tags: samedec:latest
target: localfile
build-args: |
CARGO_BUILD_TARGET=${{ matrix.rust }}
BUILD_OS_TAG=${{ matrix.os }}
BUILD_RUST_TAG=${{ env.BUILD_RUST_TAG }}
platforms: ${{ matrix.docker }}
outputs: "type=local,dest=install/bin"

- name: Copy artifact
run: |
cp install/bin/samedec install/bin/samedec-${{ matrix.rust }}
- name: Store artifact
uses: actions/upload-artifact@v3
with:
name: samedec-${{ matrix.rust }}
path: install/bin/samedec-${{ matrix.rust }}
retention-days: 3

- name: Upload tagged release
uses: svenstaro/upload-release-action@v2
if: startsWith(github.ref, 'refs/tags/samedec-')
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: install/bin/samedec-${{ matrix.rust }}
overwrite: true

- name: Update tag for nightly release
uses: richardsimko/update-tag@v1
if: github.ref == 'refs/heads/develop'
with:
tag_name: latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload nightly release
uses: svenstaro/upload-release-action@v2
if: github.ref == 'refs/heads/develop'
with:
tag: "latest"
release_name: "Nightly Release"
body: "This is a rolling release built from the latest `develop` branch."
prerelease: true
file: install/bin/samedec-${{ matrix.rust }}
overwrite: true

# Win32 build, on whatever machine github has available
release_windows:
runs-on: windows-latest

env:
CARGO_BUILD_TARGET: x86_64-pc-windows-msvc
CARGO_INSTALL_ROOT: 'install/'
RUSTFLAGS: '-C strip=symbols -C target-feature=+crt-static'
samedec_exe: 'install/bin/samedec.exe'
samedec_target_exe: install/bin/samedec-x86_64-pc-windows-msvc.exe

steps:
- uses: actions/checkout@v3

- name: Record environment
shell: bash
run: cargo version

- uses: actions/cache@v3
name: Restore Rust cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}

- name: Build
shell: bash
run: |
mkdir -p 'install' &&
cargo fetch --locked &&
cargo build --offline --tests --frozen --release --workspace
- name: Test and install
shell: bash
run: |
cargo test --offline --frozen --release --workspace &&
cargo install --offline --frozen --path=crates/samedec
- name: Run integration tests
shell: bash
run: |
"$samedec_exe" --version &&
EXPECT="$(cat <sample/long_message.22050.s16le.txt)" &&
OUT="$("$samedec_exe" -r 22050 <sample/long_message.22050.s16le.bin)" &&
echo "$OUT" &&
if [ "$OUT" = "$EXPECT" ]; then
echo "PASS";
else
echo "FAIL!";
exit 1;
fi
- name: Copy artifact
shell: bash
run: |
cp "$samedec_exe" "$samedec_target_exe"
- name: Store artifact
uses: actions/upload-artifact@v3
with:
name: samedec-${{ env.CARGO_BUILD_TARGET }}
path: ${{ env.samedec_target_exe }}
retention-days: 3

- name: Upload tagged release
uses: svenstaro/upload-release-action@v2
if: startsWith(github.ref, 'refs/tags/samedec-')
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.samedec_target_exe }}
overwrite: true

- name: Upload nightly release
uses: svenstaro/upload-release-action@v2
if: github.ref == 'refs/heads/develop'
with:
tag: "latest"
release_name: "Nightly Release"
body: "This is a rolling release built from the latest `develop` branch."
prerelease: true
file: ${{ env.samedec_target_exe }}
overwrite: true

# MacOS build, on whatever machine github has available
release_macos:
runs-on: macos-latest

env:
CARGO_BUILD_TARGET: x86_64-apple-darwin
CARGO_INSTALL_ROOT: 'install/'
RUSTFLAGS: '-C strip=symbols'
samedec_exe: 'install/bin/samedec'
samedec_target_exe: install/bin/samedec-x86_64-apple-darwin

steps:
- uses: actions/checkout@v3

- name: Record environment
run: cargo version

- uses: actions/cache@v3
name: Restore Rust cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}

- name: Build
run: |
mkdir -p 'install' &&
cargo fetch --locked &&
cargo build --offline --tests --frozen --release --workspace
- name: Test and install
run: |
cargo test --offline --frozen --release --workspace &&
cargo install --offline --frozen --path=crates/samedec
- name: Run integration tests
run: |
"$samedec_exe" --version &&
EXPECT="$(cat <sample/long_message.22050.s16le.txt)" &&
OUT="$("$samedec_exe" -r 22050 <sample/long_message.22050.s16le.bin)" &&
echo "$OUT" &&
if [ "$OUT" = "$EXPECT" ]; then
echo "PASS";
else
echo "FAIL!";
exit 1;
fi
- name: Copy artifact
run: |
cp "$samedec_exe" "$samedec_target_exe"
- name: Store artifact
uses: actions/upload-artifact@v3
with:
name: samedec-${{ env.CARGO_BUILD_TARGET }}
path: ${{ env.samedec_target_exe }}
retention-days: 3

- name: Upload tagged release
uses: svenstaro/upload-release-action@v2
if: startsWith(github.ref, 'refs/tags/samedec-')
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.samedec_target_exe }}
overwrite: true

- name: Upload nightly release
uses: svenstaro/upload-release-action@v2
if: github.ref == 'refs/heads/develop'
with:
tag: "latest"
release_name: "Nightly Release"
body: "This is a rolling release built from the latest `develop` branch."
prerelease: true
file: ${{ env.samedec_target_exe }}
overwrite: true
75 changes: 75 additions & 0 deletions .github/workflows/rust_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Test

on:
push:
branches: [ "release/**" ]
pull_request:
branches: [ "develop" ]

env:
CARGO_TERM_COLOR: always

jobs:
test_linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Record environment
run: cat /etc/os-release && cargo version
- uses: actions/cache@v3
name: Restore Rust cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
test_windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Record environment
shell: bash
run: cargo version
- uses: actions/cache@v3
name: Restore Rust cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
shell: bash
run: cargo build --verbose
- name: Run tests
shell: bash
run: cargo test --verbose
test_macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Record environment
run: cargo version
- uses: actions/cache@v3
name: Restore Rust cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
Loading

0 comments on commit 5daa2b7

Please sign in to comment.