Skip to content

OSX

OSX #51

Workflow file for this run

name: OSX
on:
workflow_dispatch:
push:
branches: [main]
tags: ['[0-9]+.[0-9]+.[0-9]+']
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: jiro4989/setup-nim-action@v2
with:
nim-version: stable
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: nimble install -y --depsOnly
- name: Compute build flags
shell: bash
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
# autoupdate on releases only
echo "BUILD_FLAGS=-d:autoUpdate" >> "$GITHUB_ENV"
fi
- name: Build
run: nimble build -y -d:release ${{ env.BUILD_FLAGS }}
- name: Build x86_64 and create universal binary
run: |
mv 3code 3code-arm64
rm -rf ~/.cache/nim/threecode_r
nim c -d:release ${{ env.BUILD_FLAGS }} --passC:"-arch x86_64" --passL:"-arch x86_64" --cpu:amd64 -o:3code-x86_64 src/threecode.nim
lipo -create 3code-arm64 3code-x86_64 -output 3code
file 3code
- name: Run tests
run: nimble test
timeout-minutes: 20
- name: Package
run: |
mkdir -p 3code-macos-universal
cp 3code 3code-macos-universal/
cp README.md LICENSE 3code-macos-universal/
OPENSSL_PREFIX="$(brew --prefix openssl@3)"
cp "${OPENSSL_PREFIX}/lib/libssl.3.dylib" 3code-macos-universal/
cp "${OPENSSL_PREFIX}/lib/libcrypto.3.dylib" 3code-macos-universal/
chmod +w 3code-macos-universal/libssl.3.dylib 3code-macos-universal/libcrypto.3.dylib
install_name_tool -id @loader_path/libcrypto.3.dylib 3code-macos-universal/libcrypto.3.dylib
install_name_tool -id @loader_path/libssl.3.dylib 3code-macos-universal/libssl.3.dylib
install_name_tool -change "${OPENSSL_PREFIX}/lib/libcrypto.3.dylib" \
@loader_path/libcrypto.3.dylib 3code-macos-universal/libssl.3.dylib
ln -sf libssl.3.dylib 3code-macos-universal/libssl.dylib
ln -sf libcrypto.3.dylib 3code-macos-universal/libcrypto.dylib
curl -fsSL https://curl.se/ca/cacert.pem -o 3code-macos-universal/cacert.pem
tar czf 3code-macos-universal.tar.gz 3code-macos-universal
- name: Upload artifact (GitHub Actions)
uses: actions/upload-artifact@v4
with:
name: 3code-macos-universal
path: 3code-macos-universal.tar.gz
- name: Upload artifact to 3code.capocasa.dev
if: github.ref == 'refs/heads/main'
run: |
curl -f -H "Authorization: Bearer ${{ secrets.RELEASE_SECRET }}" -F "file=@3code-macos-universal.tar.gz" \
https://3code.capocasa.dev/main/upload.nim