Skip to content

Commit

Permalink
ci,build: [WIP] release via nix+burrito
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <[email protected]>
  • Loading branch information
rvolosatovs committed Apr 29, 2023
1 parent e8f2717 commit dd02db6
Show file tree
Hide file tree
Showing 22 changed files with 1,677 additions and 228 deletions.
20 changes: 20 additions & 0 deletions .github/actions/build-nix/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: build via Nix

inputs:
package:
description: package specification to build
required: true
install-path:
description: path within resulting output, from which to install (e.g. `/lib/libhostcore_wasmcloud_native.a`)

runs:
using: composite
steps:
- run: nix build -L '.#${{ inputs.package }}'
shell: bash
- run: nix run -L --inputs-from . 'nixpkgs#coreutils' -- --coreutils-prog=ginstall -p "./result${{ inputs.install-path }}" '${{ inputs.package }}'
shell: bash
- uses: actions/upload-artifact@v3
with:
name: ${{ inputs.package }}
path: ${{ inputs.package }}
34 changes: 34 additions & 0 deletions .github/actions/install-nix/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: install Nix

inputs:
cachixAuthToken:
description: auth token for https://app.cachix.org/organization/wasmcloud/cache/wasmcloud

env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1 # abort caching attempt if it's slow

runs:
using: composite
steps:
- run: sudo mkdir -p /nix
if: ${{ runner.os == 'Linux' }}
shell: bash
- run: sudo chown $(whoami) /nix
if: ${{ runner.os == 'Linux' }}
shell: bash
- uses: actions/cache@v3
if: ${{ runner.os == 'Linux' }}
with:
path: /nix
key: nix
- uses: nixbuild/nix-quick-install-action@v22
with:
nix_conf: |
accept-flake-config = true
access-tokens = github.com=${{ github.token }}
experimental-features = nix-command flakes
- uses: cachix/cachix-action@v12
continue-on-error: true
with:
name: wasmcloud
authToken: '${{ inputs.cachixAuthToken }}'
173 changes: 39 additions & 134 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,150 +2,55 @@ name: WasmCloud Release

on:
push:
branches: [main]
tags: ["v*"] # Push events to matching v*, i.e. v1.0, v20.15.10
workflow_dispatch: # Allow manual creation of artifacts without a release
pull_request:
branches: [main]
env:
otp-version: 25
elixir-version: 1.14.3

jobs:
create-static-macos:
if: ${{ startswith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
name: Static macOS release
strategy:
matrix:
os: [macos-11]
include:
- os: macos-11
rust-target: x86_64-apple-darwin
release-tarball: x86_64-macos-static.tar.gz
working-directory: wasmcloud_host
runs-on: ${{ matrix.os }}
env:
working-directory: ${{ matrix.working-directory }}
MIX_ENV: release_prod
SECRET_KEY_BASE: ${{ secrets.WASMCLOUD_HOST_SECRET_KEY_BASE }}
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: run macos script
shell: bash
run: |
bash .github/workflows/static_macos
tar -czvf ${{ matrix.release-tarball }} -C wasmcloud_host/_build/prod/rel/bakeware wasmcloud_host
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.release-tarball }}
path: ${{ matrix.release-tarball }}

create-mix-releases:
# Run on tag push or on manual dispatch. Release will not be created for manual dispatch
if: ${{ (startswith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch') && startswith(github.repository.name, 'wasmcloud') }}
name: Mix release
build-darwin-nif:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-11]
working-directory: [wasmcloud_host, host_core]
include:
- os: ubuntu-20.04
rust-target: x86_64-unknown-linux-gnu
release-tarball: x86_64-linux.tar.gz
working-directory: wasmcloud_host
- os: windows-2019
rust-target: x86_64-pc-windows-gnu
release-tarball: x86_64-windows.tar.gz
working-directory: wasmcloud_host
- os: macos-11
rust-target: x86_64-apple-darwin
release-tarball: x86_64-macos.tar.gz
working-directory: wasmcloud_host
- os: ubuntu-20.04
rust-target: x86_64-unknown-linux-gnu
release-tarball: x86_64-linux-core.tar.gz
working-directory: host_core
- os: windows-2019
rust-target: x86_64-pc-windows-gnu
release-tarball: x86_64-windows-core.tar.gz
working-directory: host_core
- os: macos-11
rust-target: x86_64-apple-darwin
release-tarball: x86_64-macos-core.tar.gz
working-directory: host_core
runs-on: ${{ matrix.os }}
env:
working-directory: ${{ matrix.working-directory }}
MIX_ENV: release_prod
SECRET_KEY_BASE: ${{ secrets.WASMCLOUD_HOST_SECRET_KEY_BASE }}
config:
- host: macos-latest
target: aarch64-apple-darwin

steps:
- uses: actions/checkout@v3

# Install Rust
- run: rustup toolchain install stable --profile minimal

# Install erlang/OTP and elixir
- name: Install erlang and elixir
if: ${{ startswith(matrix.os, 'ubuntu') || startswith(matrix.os, 'windows') }}
uses: erlef/setup-beam@v1
with:
otp-version: "=${{ env.otp-version }}"
elixir-version: "${{ env.elixir-version }}"
install-hex: true
install-rebar: true
- name: Install erlang and elixir
if: ${{ startswith(matrix.os, 'macos') }}
run: |
brew install erlang
brew install elixir
- host: macos-latest
target: x86_64-apple-darwin

- name: Retrieve Mix Dependencies Cache
if: ${{ !startswith(matrix.os, 'windows') }} # Windows gets angry about not owning files if you restore from cache
uses: actions/cache@v2
id: mix-cache #id to use in retrieve action
with:
path: |
${{ env.working-directory }}/deps
key: ${{ runner.os }}-${{ env.ERLANG_VERSION }}-${{ env.ELIXIR_VERSION }}-mix-${{ hashFiles('${{ env.working-directory }}/mix.exs', '${{ env.working-directory }}/mix.lock') }}

- name: Install Mix Dependencies
working-directory: ${{env.working-directory}}
shell: bash
run: |
mix local.rebar --force
mix local.hex --force
mix deps.get
- name: Compile Elixir
working-directory: ${{env.working-directory}}
shell: bash
run: |
mix compile
- name: Compile Phoenix Assets
if: ${{ env.working-directory == 'wasmcloud_host' }}
working-directory: ${{env.working-directory}}
shell: bash
run: |
make esbuild
- name: Create Mix Release
working-directory: ${{env.working-directory}}
shell: bash
run: |
mix release
cd _build/${{ env.MIX_ENV }}/rel/${{env.working-directory}}
tar -czvf ${{ matrix.release-tarball }} bin erts-* lib releases
mv ${{ matrix.release-tarball }} ../../../../
name: nif-${{ matrix.config.target }}
runs-on: ${{ matrix.config.host }}
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-nix
with:
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- uses: ./.github/actions/build-nix
with:
package: hostcore_wasmcloud_native-${{ matrix.config.target }}

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.release-tarball }}
path: ${{env.working-directory}}/${{ matrix.release-tarball }}
hostcore:
needs: build-darwin-nif
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-nix
with:
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- uses: actions/download-artifact@v3
with:
path: ./aarch64
name: hostcore_wasmcloud_native-aarch64-apple-darwin
- uses: actions/download-artifact@v3
with:
path: ./x86_64
name: hostcore_wasmcloud_native-x86_64-apple-darwin
- run: nix build --override-input hostcore_wasmcloud_native-aarch64-apple-darwin ./aarch64 --override-input hostcore_wasmcloud_native-x86_64-apple-darwin ./x86_64 -L .#hostcore
#- uses: ./.github/actions/build-nix
# with:
# package: hostcore_wasmcloud_native-${{ matrix.config.target }}
# install-path: ${{ matrix.config.install-path }}

# release-hostcore-docker:
# if: startswith(github.ref, 'refs/tags/') # Only run on tag push
Expand Down Expand Up @@ -364,7 +269,7 @@ jobs:
github-release:
if: startswith(github.ref, 'refs/tags/') # Only run on tag push
needs:
[create-mix-releases, release-wasmcloud-docker]
- hostcore
runs-on: ubuntu-latest
steps:
- name: Download Release Tarballs
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# The directory Mix will write compiled artifacts to.
/_build/
_build/
burrito_out/
result

# If you run "mix test --cover", coverage assets end up here.
/cover/
Expand Down
Loading

0 comments on commit dd02db6

Please sign in to comment.