Skip to content

mono-workflow

mono-workflow #871

name: mono-workflow
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+' # matches 0.1.0, 0.2.1, etc.
schedule:
- cron: '0 1 * * *' # 1am UTC
workflow_dispatch:
permissions:
contents: write
packages: write
actions: read
jobs:
tag:
runs-on: ubuntu-latest
steps:
- name: Update Nightly Tag
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
uses: richardsimko/update-tag@v1
with:
tag_name: nightly
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout code
if: startsWith(github.ref, 'refs/tags/') == true
uses: actions/checkout@v3
- name: Search for version
if: startsWith(github.ref, 'refs/tags/') == true
run: |
if grep -q "version = \"${{ env.GITHUB_REF }}\"" Cargo.toml; then
echo "Match found!"
else
echo "No match found."
exit 1
fi
env:
GITHUB_REF: ${{ github.ref_name }}
# test:
# needs: tag
# if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/') == true
# runs-on: ${{ matrix.config.os }}
# env:
# SCCACHE_AZURE_BLOB_CONTAINER: ${{ secrets.SCCACHE_AZURE_BLOB_CONTAINER }}
# SCCACHE_AZURE_CONNECTION_STRING: ${{ secrets.SCCACHE_AZURE_CONNECTION_STRING }}
# SCCACHE_AZURE_KEY_PREFIX: 'wick-github-actions-test'
# RUSTC_WRAPPER: 'sccache'
# OCI_USERNAME: ${{ secrets.CANDLE_REG_USERNAME }}
# OCI_PASSWORD: ${{ secrets.CANDLE_REG_PASSWORD }}
# strategy:
# matrix:
# config:
# - {
# os: 'ubuntu-latest',
# name: 'linux',
# arch: 'amd64',
# target: 'x86_64-unknown-linux-gnu',
# }
# steps:
# - name: make space
# run: |
# sudo rm -rf /usr/share/dotnet
# sudo rm -rf /opt/ghc
# sudo rm -rf "/usr/local/share/boost"
# sudo rm -rf "$AGENT_TOOLSDIRECTORY"
# - uses: actions/checkout@v3
# - name: install protobuf
# uses: arduino/setup-protoc@v1
# with:
# repo-token: ${{ secrets.GITHUB_TOKEN }}
# - name: setup for cross-compiled linux aarch64 build
# if: matrix.config.target == 'aarch64-unknown-linux-gnu'
# run: |
# sudo apt update
# sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu pkg-config
# echo "PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu" >> $GITHUB_ENV
# echo "PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig" >> $GITHUB_ENV
# echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
# - name: setup for cross-compiled windows build
# if: matrix.config.target == 'x86_64-pc-windows-gnu'
# run: |
# sudo apt update
# sudo apt install mingw-w64
# echo "PKG_CONFIG_SYSROOT_DIR=/usr/x86_64-w64-mingw32" >> $GITHUB_ENV
# echo "PKG_CONFIG_PATH=/usr/lib/x86_64-w64-mingw32/pkgconfig" >> $GITHUB_ENV
# echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
# - name: Install sccache (ubuntu-latest)
# if: matrix.config.os == 'ubuntu-latest'
# run: |
# mkdir -p $HOME/.local/bin
# curl -L "https://github.com/mozilla/sccache/releases/download/v0.3.3/sccache-v0.3.3-x86_64-unknown-linux-musl.tar.gz" | tar xz
# mv -f sccache-v0.3.3-x86_64-unknown-linux-musl/sccache $HOME/.local/bin/sccache
# echo "$HOME/.local/bin" >> $GITHUB_PATH
# - name: Install sccache (macos-latest)
# if: matrix.config.os == 'macos-latest'
# run: |
# mkdir -p $HOME/.local/bin
# curl -L "https://github.com/mozilla/sccache/releases/download/v0.3.3/sccache-v0.3.3-x86_64-apple-darwin.tar.gz" | tar xz
# mv -f sccache-v0.3.3-x86_64-apple-darwin/sccache $HOME/.local/bin/sccache
# echo "$HOME/.local/bin" >> $GITHUB_PATH
# - name: Get Rust version from rust-toolchain.toml
# run: |
# rust_version=$(grep 'channel =' rust-toolchain.toml | awk -F\" '{print $2}')
# echo "RUST_VERSION=$rust_version" >> $GITHUB_ENV
# - name: Rust toolchain cache
# uses: actions/cache@v3
# with:
# path: |
# ~/.cargo/bin/
# ~/.cargo/registry
# ~/.cargo/git
# key: ${{ runner.os }}-${{ matrix.config.target }}-rust-toolchain-${{ env.RUST_VERSION }}
# - name: Install Rust toolchain
# uses: dtolnay/rust-toolchain@stable
# with:
# target: ${{ matrix.config.target }}
# - name: 'rustup updates'
# run: |
# rustup target add wasm32-unknown-unknown wasm32-wasi
# cargo install cargo-deny just cargo-nextest
# #Updating rustup updates means that the github cache needs to be manually deleted.
# - name: Run just ci-tests
# id: just-ci-test
# run: |
# just ci-tests
# # - name: Build wasms for tests
# # id: just-wasm
# # run: |
# # just wasm
# # cargo clean
# # - name: Run just integration
# # id: just-integration
# # run: |
# # just integration
# # cargo clean
build:
needs: tag
runs-on: ${{ matrix.config.os }}
if: github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/') == true || github.event_name == 'workflow_dispatch'
env:
SCCACHE_AZURE_BLOB_CONTAINER: ${{ secrets.SCCACHE_AZURE_BLOB_CONTAINER }}
SCCACHE_AZURE_CONNECTION_STRING: ${{ secrets.SCCACHE_AZURE_CONNECTION_STRING }}
SCCACHE_AZURE_KEY_PREFIX: 'wick-github-actions'
RUSTC_WRAPPER: 'sccache'
CARGO_PROFILE_RELEASE_DEBUG: '0' # https://doc.rust-lang.org/cargo/reference/profiles.html#debug
CARGO_INCREMENTAL: 'true' # https://doc.rust-lang.org/cargo/reference/profiles.html#incremental
CARGO_PROFILE_RELEASE_LTO: 'true' # https://doc.rust-lang.org/cargo/reference/profiles.html#lto
CARGO_PROFILE_RELEASE_OPT_LEVEL: '3' # https://doc.rust-lang.org/cargo/reference/profiles.html#opt-level
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '1' # https://doc.rust-lang.org/cargo/reference/profiles.html#codegen-units
CARGO_PROFILE_RELEASE_STRIP: 'true' # https://doc.rust-lang.org/cargo/reference/unstable.html#profile-strip-option
strategy:
matrix:
config:
- {
os: 'ubuntu-latest',
name: 'linux',
arch: 'amd64',
target: 'x86_64-unknown-linux-gnu',
args: '',
}
- {
os: 'ubuntu-latest',
name: 'linux',
target: 'aarch64-unknown-linux-gnu',
arch: 'aarch64',
args: '--features cross',
}
- {
os: 'macos-latest',
name: 'macos',
target: 'x86_64-apple-darwin',
arch: 'amd64',
}
- {
os: 'macos-latest',
name: 'macos',
target: 'aarch64-apple-darwin',
arch: 'aarch64',
args: '--features cross',
}
- {
os: 'ubuntu-latest',
name: 'win',
target: 'x86_64-pc-windows-gnu',
arch: 'amd64',
args: '--features cross',
}
steps:
- uses: actions/checkout@v3
- name: install protobuf
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: setup for cross-compiled linux aarch64 build
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt update
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu pkg-config
echo "PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig" >> $GITHUB_ENV
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
- name: setup for cross-compiled windows build
if: matrix.config.target == 'x86_64-pc-windows-gnu'
run: |
sudo apt update
sudo apt install mingw-w64
echo "PKG_CONFIG_SYSROOT_DIR=/usr/x86_64-w64-mingw32" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/lib/x86_64-w64-mingw32/pkgconfig" >> $GITHUB_ENV
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
- name: Install sccache (ubuntu-latest)
if: matrix.config.os == 'ubuntu-latest'
run: |
mkdir -p $HOME/.local/bin
curl -L "https://github.com/mozilla/sccache/releases/download/v0.3.3/sccache-v0.3.3-x86_64-unknown-linux-musl.tar.gz" | tar xz
mv -f sccache-v0.3.3-x86_64-unknown-linux-musl/sccache $HOME/.local/bin/sccache
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install sccache (macos-latest)
if: matrix.config.os == 'macos-latest'
run: |
mkdir -p $HOME/.local/bin
curl -L "https://github.com/mozilla/sccache/releases/download/v0.3.3/sccache-v0.3.3-x86_64-apple-darwin.tar.gz" | tar xz
mv -f sccache-v0.3.3-x86_64-apple-darwin/sccache $HOME/.local/bin/sccache
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Get Rust version from rust-toolchain.toml
run: |
rust_version=$(grep 'channel =' rust-toolchain.toml | awk -F\" '{print $2}')
echo "RUST_VERSION=$rust_version" >> $GITHUB_ENV
- name: Rust toolchain cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-${{ matrix.config.target }}-rust-toolchain-${{ env.RUST_VERSION }}
- name: build cache
uses: actions/cache@v3
with:
path: |
target/
crates/**/target
key: ${{ runner.os }}-${{ matrix.config.target }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.config.target }}
- name: 'rustup updates'
run: |
rustup target add wasm32-unknown-unknown wasm32-wasi
- name: 'build binary'
run: |
cargo build --release -p wick-cli --target=${{ matrix.config.target }} ${{ matrix.config.args }}
- name: package release assets
if: matrix.config.target != 'x86_64-pc-windows-gnu'
run: |
mkdir -p _dist
cp README.md LICENSE target/${{ matrix.config.target }}/release/wick _dist/
cd _dist
tar czf wick-${{ matrix.config.name }}-${{ matrix.config.arch }}.tar.gz README.md LICENSE wick
- name: Upload artifacts
if: matrix.config.target != 'x86_64-pc-windows-gnu'
uses: actions/upload-artifact@v2
with:
name: wick-${{ matrix.config.name }}-${{ matrix.config.arch }}.tar.gz
path: _dist/wick-${{ matrix.config.name }}-${{ matrix.config.arch }}.tar.gz
- name: package release assets (windows)
if: matrix.config.target == 'x86_64-pc-windows-gnu'
shell: bash
run: |
mkdir -p _dist
cp README.md LICENSE target/${{ matrix.config.target }}/release/wick.exe _dist/
cd _dist
7z a -tzip wick-${{ matrix.config.name }}-${{ matrix.config.arch }}.zip README.md LICENSE wick.exe
- name: Upload artifacts (windows)
if: matrix.config.target == 'x86_64-pc-windows-gnu'
uses: actions/upload-artifact@v3
with:
name: wick-${{ matrix.config.name }}-${{ matrix.config.arch }}.zip
path: _dist/wick-${{ matrix.config.name }}-${{ matrix.config.arch }}.zip
release:
runs-on: ubuntu-latest
if: github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/') == true || github.event_name == 'workflow_dispatch'
needs: [build]
steps:
- uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Move artifacts to _dist
working-directory: ${{ github.workspace }}
run: |
mkdir -p _dist
for dir in artifacts/*/; do
# Move the contents of each directory to the destination folder
echo "Moving {$dir}"
mv "$dir"* _dist/
done
#Copy the schema manifest into the dist directory
cp crates/wick/wick-config/json-schema/manifest.json _dist/schema.json
#Copy the TypeScript SDKs into the dist directory
cp crates/wick/wick-config/typescript/v1.ts _dist/
ls -la _dist
- name: upload release assets (tag)
uses: svenstaro/upload-release-action@v2
if: startsWith(github.ref, 'refs/tags/') == true
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: _dist/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
- name: upload release assets (nightly)
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: _dist/*
tag: nightly
overwrite: true
file_glob: true
- name: ghcr login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile.nightly
push: true
tags: ghcr.io/candlecorp/wick:nightly
platforms: linux/amd64,linux/arm64
- name: build and push
uses: docker/build-push-action@v2
if: startsWith(github.ref, 'refs/tags/') == true
with:
context: .
file: ./docker/Dockerfile.latest
push: true
tags: ghcr.io/candlecorp/wick:latest, ghcr.io/candlecorp/wick:${{ github.ref_name }}
platforms: linux/amd64,linux/arm64