Skip to content

Commit

Permalink
chore: Add GitHub Actions workflow for building and releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
royshil committed Jul 12, 2024
1 parent 1496cd4 commit 0c6f256
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: "Build"

on:
push:
branches:
- "main"
tags:
- "*"
pull_request:
branches:
- "main"

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: "${{ github.ref != 'refs/heads/main' }}"

env:
OPENSSL_VERSION: "3.3.1"

jobs:
BuildMac:
runs-on: "macos-13"

strategy:
matrix:
config:
- "Debug"
- "Release"

defaults:
run:
shell: "bash"

steps:
- name: "Get version"
run: |
if [[ $GITHUB_REF =~ ^refs/tags/ ]]
then version="${GITHUB_REF#refs/tags/}"
else version=main
fi
printf "version=%s" "$version" > "$GITHUB_OUTPUT"
id: "get-version"

- name: "Checkout"
uses: "actions/checkout@v4"

- name: "Run build-macos.sh"
run: "./build-macos.sh ${{ matrix.config }} ${{ steps.get-version.outputs.version }}"

- name: "Upload artifact"
uses: "actions/upload-artifact@v4"
with:
name: "opencv-macos-${{ matrix.config }}"
path: "release/*.tar.gz"

Release:
runs-on: "ubuntu-22.04"

if: "github.event_name == 'push' && contains(github.ref, 'refs/tags/')"

needs:
- "BuildMac"
- "BuildWindows"

permissions:
contents: "write"

defaults:
run:
shell: "bash"

steps:
- name: "Get version"
run: |
if [[ $GITHUB_REF =~ ^refs/tags/ ]]
then version="${GITHUB_REF#refs/tags/}"
else version=main
fi
printf "version=%s" "$version" > "$GITHUB_OUTPUT"
id: "get-version"

- name: "Download build artifacts"
uses: "actions/download-artifact@v4"

- name: "Create Release"
uses: "softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5"
with:
draft: true
tag_name: "${{ steps.get-version.outputs.version }}"
name: "${{ steps.get-version.outputs.version }}"
files: |
${{ github.workspace }}/**/*.tar.gz
${{ github.workspace }}/**/*.zip
23 changes: 23 additions & 0 deletions build-macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

OPENSSL_VERSION="3.3.1"

curl -O http://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_arm64
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
rm openssl-$OPENSSL_VERSION.tar.gz

mv openssl-$OPENSSL_VERSION openssl_x86_64
cd openssl_arm64
./Configure darwin-arm64-cc -shared
make
cd ../

cd openssl_x86_64
./Configure darwin64-x86_64-cc -shared
make
cd ../

lipo -create openssl_arm64/libcrypto.$OPENSSL_VERSION.dylib openssl_x86_64/libcrypto.$OPENSSL_VERSION.dylib -output libcrypto.$OPENSSL_VERSION.dylib
lipo -create openssl_arm64/libssl.$OPENSSL_VERSION.dylib openssl_x86_64/libssl.$OPENSSL_VERSION.dylib -output libssl.$OPENSSL_VERSION.dylib

0 comments on commit 0c6f256

Please sign in to comment.