Skip to content

Commit

Permalink
feat(ci/publish): add caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed Oct 23, 2023
1 parent c0ceb57 commit 54d1c68
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 120 deletions.
84 changes: 0 additions & 84 deletions .github/workflows/build.yml

This file was deleted.

155 changes: 122 additions & 33 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,125 @@
name: Publish Package

on:
workflow_dispatch:
inputs:
test:
type: boolean
description: Skip publishing step
push:
tags:
- "*"

name: 🚀 Publish Package

jobs:
build-container:
runs-on: ubuntu-latest

steps:
- name: 📥 Checkout
uses: actions/checkout@v3

- name: 🤖 Setup Qemu
uses: docker/setup-qemu-action@v3
with:
platforms: "arm64"

- name: 🐋 Setup Buildx
uses: docker/setup-buildx-action@v3

- name: 🦥 Cache Image
id: cache-image
uses: actions/cache@v3
with:
path: venmic-builder.tar
key: venmic-builder-cache

- name: 🏗️ Build Image
if: steps.cache-image.outputs.cache-hit != 'true'
run: |
cd docker
docker buildx build --platform=linux/amd64,linux/arm64 --tag venmic-builder .
docker save > venmic-builder.tar
build-x86_64:
needs: build-container
runs-on: ubuntu-latest

steps:
- name: 📥 Checkout
uses: actions/checkout@v3

- name: 🦥 Pull Image
uses: actions/cache/restore@v3
id: cache-container
with:
fail-on-cache-miss: true
path: venmic-builder.tar
key: venmic-builder-cache

- name: 🐋 Load Container
run: |
docker load < venmic-builder.tar
- name: 🏗️ Build Addon
uses: addnab/docker-run-action@v3
with:
options: -v ${{ github.workspace }}:/work --platform linux/amd64
image: venmic-builder
shell: bash
run: |
cd /work
pnpm install
- name: ♻️ Upload Artifact
uses: actions/upload-artifact@v3
with:
name: addon-x86_64
path: build/Release

build-arm64:
needs: build-container
runs-on: ubuntu-latest

steps:
- name: 📥 Checkout
uses: actions/checkout@v3

- name: 🦥 Pull Image
uses: actions/cache/restore@v3
id: cache-container
with:
fail-on-cache-miss: true
path: venmic-builder.tar
key: venmic-builder-cache

- name: 🤖 Setup Qemu
uses: docker/setup-qemu-action@v3
with:
platforms: "arm64"

- name: 🐋 Load Container
run: |
docker load < venmic-builder.tar
- name: 🏗️ Build Addon
uses: addnab/docker-run-action@v3
with:
options: -v ${{ github.workspace }}:/work --platform linux/arm64
image: venmic-builder
shell: bash
run: |
cd /work
pnpm install
- name: ♻️ Upload Artifact
uses: actions/upload-artifact@v3
with:
name: addon-arm64
path: build/Release

publish:
needs: [build-arm64, build-x86_64]
runs-on: ubuntu-latest
container: fedora:37

steps:
- name: 📥 Checkout
Expand All @@ -36,47 +146,26 @@ jobs:
version: 8
run_install: false

- name: ⏱️ Wait for x86-64 Builds
uses: lewagon/[email protected]
with:
wait-interval: 600
ref: ${{ github.ref }}
check-name: "build-fedora37"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: 📦 Download Build (x86-64)
id: download-artifact
- name: 📦 Download Build (x86_64)
uses: dawidd6/action-download-artifact@v2
with:
workflow: build.yml
name: addon-x86-64
name: addon-x86_64
path: build/Release
allow_forks: false

- name: 🛠️ Prepare Prebuilds (x86-64)
run: pnpm pkg-prebuilds-copy --baseDir build/Release --source venmic-addon.node --name=venmic-addon --strip --napi_version=7

- name: ⏱️ Wait for armv8 Builds
uses: lewagon/[email protected]
with:
wait-interval: 600
ref: ${{ github.ref }}
check-name: "build-fedora37-arm"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: 🛠️ Prepare Prebuilds (x86_64)
run: pnpm pkg-prebuilds-copy --baseDir build/Release --source venmic-addon.node --name=venmic-addon --strip --napi_version=7 --arch=x64

- name: 📦 Download Build (armv8)
id: download-artifact
- name: 📦 Download Build (arm64)
uses: dawidd6/action-download-artifact@v2
with:
workflow: build.yml
name: addon-armv8
name: addon-arm64
path: build/Release
allow_forks: false

- name: 🛠️ Prepare Prebuilds (armv8)
run: pnpm pkg-prebuilds-copy --baseDir build/Release --source venmic-addon.node --name=venmic-addon --strip --napi_version=7
- name: 🛠️ Prepare Prebuilds (x86_64)
run: pnpm pkg-prebuilds-copy --baseDir build/Release --source venmic-addon.node --name=venmic-addon --strip --napi_version=7 --arch=arm64

- name: 🛒 Publish
if: "${{ github.event.inputs.test != 'true' }}"
run: pnpm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
30 changes: 30 additions & 0 deletions .github/workflows/server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
on:
push:
pull_request:

name: 🏗️ Build Server

jobs:
build-fedora:
runs-on: ubuntu-latest
container: fedora:38

steps:
- name: 📥 Checkout
uses: actions/checkout@v3

- name: 👷 Build Dependencies
run: |
dnf install -y make automake gcc gcc-c++ kernel-devel cmake git
dnf install -y pipewire-devel pipewire-libs pulseaudio-libs-devel pipewire-pulseaudio
- name: 🔨 Build
run: |
cmake -B build
cmake --build build
- name: 🚀 Upload Artifact
uses: actions/upload-artifact@v3
with:
name: server-x86-64
path: build/server
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules
.vscode
build
prebuilds
prebuilds
7 changes: 5 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
node_modules
.github
build

docker
server
tests
build

.gitignore
.github

.clang-*
.eslint*
13 changes: 13 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This Dockerfile describes the base image used for compiling the node addon on different CPU-Architectures

FROM fedora:37

# Build dependencies

RUN dnf install -y make automake gcc gcc-c++ kernel-devel cmake git nodejs
RUN dnf install -y pipewire-devel pipewire-libs pulseaudio-libs-devel pipewire-pulseaudio

# PNPM

RUN curl -fsSL https://get.pnpm.io/install.sh | sh -
RUN source /root/.bashrc

0 comments on commit 54d1c68

Please sign in to comment.