Skip to content

Commit

Permalink
🤖 add cross-platform binary deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Nov 11, 2023
1 parent f48305d commit 4d10844
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 133 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths-ignore: ['**/*.md']
pull_request:
paths-ignore: ['**/*.md']
workflow_dispatch:

jobs:
linux:
Expand All @@ -14,6 +15,10 @@ jobs:

macOS:
uses: ./.github/workflows/macos.yml
permissions:
contents: write

windows:
uses: ./.github/workflows/windows.yml
permissions:
contents: write
17 changes: 7 additions & 10 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,19 @@ jobs:
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v4
with:
path: ${{ env.REPO_NAME }}
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-
key: ${{ runner.os }}-${{ github.sha }}
fail-on-cache-miss: true

- name: Setup V
uses: vlang/setup-v@v1.3

- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v3
with:
path: ${{ env.REPO_NAME }}

run: vlang/v symlink && v version
- name: Check Formatting
run: v fmt -verify ${{ env.REPO_NAME }}
run: v fmt ${{ env.REPO_NAME }} && v fmt -verify ${{ env.REPO_NAME }}
162 changes: 71 additions & 91 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,29 @@ env:
jobs:
setup:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.REPO_NAME }}
steps:
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v4
with:
path: ${{ env.REPO_NAME }}
- name: Setup Dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libgtk-3-dev libwebkit2gtk-4.0-dev
version: 1.0
- name: Setup V
uses: vlang/setup-v@v1.3
- name: Checkout V
uses: actions/checkout@v4
with:
check-latest: true
- name: Setup Modules
repository: 'vlang/v'
path: vlang
- name: Setup V
run: cd ../vlang && make -j4 && ./v symlink && v version
- name: Setup modules
run: |
v install --git https://github.com/ttytm/webview
v install --git https://github.com/Larpon/miniaudio
v install
~/.vmodules/webview/build.vsh
- name: Cache
uses: actions/cache/save@v3
Expand All @@ -36,78 +45,29 @@ jobs:
needs: setup
uses: ./.github/workflows/lint.yml

build-linux:
build:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [tcc, gcc, clang]
optimization: ['', -cstrict]
cc: [tcc, gcc, clang]
flag: ['', -cstrict]
exclude:
- compiler: clang
optimization: -cstrict
- cc: clang
flag: -cstrict
fail-fast: false
env:
# VFLAGS: -cg -cc ${{ matrix.cc }} ${{ matrix.flag }}
VFLAGS: -cg -cc ${{ matrix.cc }} # currently -cstrict won't work with miniaudio
defaults:
run:
working-directory: ${{ env.REPO_NAME }}
steps:
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
uses: vlang/setup-v@v1.3
- name: Setup Dependencies
if: runner.os == 'Linux'
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libgtk-3-dev libwebkit2gtk-4.0-dev
version: 1.0
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v3
- name: Build
# run: v -cg -cc ${{ matrix.compiler }} ${{ matrix.optimization }} .
run: v -cg -cc ${{ matrix.compiler }} .

build-gcc-sanitized:
needs: build-linux
runs-on: ubuntu-latest
strategy:
matrix:
sanitizer:
- -cflags -fsanitize=leak
- -cflags -fsanitize=address -cflags -fsanitize-address-use-after-scope -cflags -fsanitize=pointer-compare -cflags -fsanitize=pointer-subtract
- -cflags -fsanitize=undefined -cflags -fsanitize=shift -cflags -fsanitize=shift-exponent -cflags -fsanitize=shift-base -cflags -fsanitize=integer-divide-by-zero -cflags -fsanitize=unreachable -cflags -fsanitize=vla-bound -cflags -fsanitize=null -cflags -fsanitize=return -cflags -fsanitize=signed-integer-overflow -cflags -fsanitize=bounds -cflags -fsanitize=bounds-strict -cflags -fsanitize=alignment -cflags -fsanitize=object-size -cflags -fsanitize=float-divide-by-zero -cflags -fsanitize=float-cast-overflow -cflags -fsanitize=nonnull-attribute -cflags -fsanitize=returns-nonnull-attribute -cflags -fsanitize=bool -cflags -fsanitize=enum -cflags -fsanitize=vptr -cflags -fsanitize=pointer-overflow -cflags -fsanitize=builtin
steps:
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
uses: vlang/setup-v@v1.3
- name: Setup dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
uses: actions/checkout@v4
with:
packages: libgtk-3-dev libwebkit2gtk-4.0-dev
version: 1.0
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v3
- name: Build
run: v -cc gcc ${{ matrix.sanitizer }} .

build-clang-sanitized:
needs: build-linux
runs-on: ubuntu-latest
strategy:
matrix:
sanitizer: [address, memory, leak]
steps:
- name: Restore Cache
path: ${{ env.REPO_NAME }}
- name: Restore cache
uses: actions/cache/restore@v3
with:
path: |
Expand All @@ -116,24 +76,33 @@ jobs:
key: ${{ runner.os }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
uses: vlang/setup-v@v1.3
- name: Setup Dependencies
run: ../vlang/v symlink && v version
- name: Setup dependencies
if: runner.os == 'Linux'
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libgtk-3-dev libwebkit2gtk-4.0-dev
version: 1.0
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v3
- name: Build
run: v -cc clang -cflags -fsanitize=${{ matrix.sanitizer }} .
run: v .

deploy:
needs: build-linux
needs: build
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.REPO_NAME }}
permissions:
contents: write
env:
ARTIFACT: emoji-mart-linux-amd64
APPIMAGE_ARTIFACT: emoji-mart-ubuntu-amd64.AppImage
steps:
- name: Restore Cache
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v4
with:
path: ${{ env.REPO_NAME }}
- name: Restore cache
uses: actions/cache/restore@v3
with:
path: |
Expand All @@ -142,33 +111,44 @@ jobs:
key: ${{ runner.os }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
uses: vlang/setup-v@v1.3
- name: Setup apt Packages
run: ../vlang/v symlink && v version
- name: Setup dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libgtk-3-dev libwebkit2gtk-4.0-dev libfuse2
version: 1.0
- name: Setup appimage-builder
- name: Prepare deployment build
run: |
curl -sSLo /usr/local/bin/appimage-builder https://github.com/AppImageCrafters/appimage-builder/releases/latest/download/appimage-builder-1.1.0-x86_64.AppImage
curl -sSLo ./lvb https://github.com/ttytm/LVbag/releases/latest/download/lvb-linux-amd64
sudo chmod +x /usr/local/bin/appimage-builder
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v3
- name: Build AppImage
sudo chmod +x ./lvb
./lvb --version
appimage-builder --version
git fetch --prune --unshallow
- name: Build
run: |
./build.vsh --appimage
- name: Prepare Artifact
./build.vsh
./build.vsh --appimage --skip-ui --skip-bin
- name: Prepare artifacts
run: |
artifact=emoji-mart-desktop-x86_64.AppImage
echo "ARTIFACT=$artifact" >> $GITHUB_ENV
mv "dist/appimage/Emoji Mart-latest-x86_64.AppImage" ./$artifact
- name: Upload Artifacts
mv "dist/emoji-mart" ./$ARTIFACT
mv "dist/appimage/Emoji Mart-latest-x86_64.AppImage" ./$APPIMAGE_ARTIFACT
- name: Upload binary artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT }}
path: ${{ env.ARTIFACT }}
- name: Release Artifacts
path: ${{ env.REPO_NAME }}/${{ env.ARTIFACT }}
- name: Upload appimage artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.APPIMAGE_ARTIFACT }}
path: ${{ env.REPO_NAME }}/${{ env.APPIMAGE_ARTIFACT }}
- name: Release
if: github.ref_type == 'tag'
uses: softprops/action-gh-release@v1
with:
files: ${{ env.ARTIFACT }}
files: |
${{ env.REPO_NAME }}/assets/emoji-mart.desktop
${{ env.REPO_NAME }}/${{ env.ARTIFACT }}
${{ env.REPO_NAME }}/${{ env.APPIMAGE_ARTIFACT }}
82 changes: 70 additions & 12 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@ on:

env:
REPO_NAME: ${{ github.event.repository.name }}
# Path where the module is installed with `v install <giturl>`
MOD_PATH: ~/.vmodules/webview

jobs:
setup:
runs-on: macos-latest
defaults:
run:
working-directory: ${{ env.REPO_NAME }}
steps:
- name: Install V
uses: vlang/setup-v@v1.3
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v4
with:
path: ${{ env.REPO_NAME }}
- name: Checkout V
uses: actions/checkout@v4
with:
check-latest: true
- name: Setup Modules
repository: 'vlang/v'
path: vlang
- name: Setup V
run: cd ../vlang && make -j4 && ./v symlink && v version
- name: Setup modules
run: |
v install --git https://github.com/ttytm/webview
v install --git https://github.com/Larpon/miniaudio
v install
~/.vmodules/webview/build.vsh
- name: Cache
uses: actions/cache/save@v3
Expand All @@ -32,8 +39,15 @@ jobs:
build:
needs: setup
runs-on: macos-latest
defaults:
run:
working-directory: ${{ env.REPO_NAME }}
steps:
- name: Restore Cache
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v4
with:
path: ${{ env.REPO_NAME }}
- name: Restore cache
uses: actions/cache/restore@v3
with:
path: |
Expand All @@ -42,8 +56,52 @@ jobs:
key: ${{ runner.os }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
uses: vlang/setup-v@v1.3
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v3
run: ../vlang/v symlink && v version
- name: Build
run: v -cg .

deploy:
needs: build
runs-on: macos-latest
permissions:
contents: write
defaults:
run:
working-directory: ${{ env.REPO_NAME }}
env:
ARTIFACT: emoji-mart-macos-amd64
steps:
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v4
with:
path: ${{ env.REPO_NAME }}
- name: Restore cache
uses: actions/cache/restore@v3
with:
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
run: ../vlang/v symlink && v version
- name: Prepare deployment build
run: |
curl -sSLo lvb https://github.com/ttytm/LVbag/releases/latest/download/lvb-macos-amd64
sudo chmod +x ./lvb
./lvb --version
git fetch --prune --unshallow
- name: Build
run: ./build.vsh
- name: Prepare artifacts
run: mv "dist/emoji-mart" ./$ARTIFACT
- name: Upload binary artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT }}
path: ${{ env.REPO_NAME }}/${{ env.ARTIFACT }}
- name: Release
if: github.ref_type == 'tag'
uses: softprops/action-gh-release@v1
with:
files: ${{ env.REPO_NAME }}/${{ env.ARTIFACT }}
Loading

0 comments on commit 4d10844

Please sign in to comment.