huge refactoring into independent packages #320
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
macos_x86_64: | |
runs-on: macos-13 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Crystal | |
run: brew update && brew install crystal || true | |
- name: Copy static libraries | |
run: | | |
mkdir -p ./libs | |
# openssl | |
cp $(brew --prefix)/opt/openssl@3/lib/libssl.a ./libs | |
cp $(brew --prefix)/opt/openssl@3/lib/libcrypto.a ./libs | |
# libevent | |
cp $(brew --prefix)/opt/libevent/lib/libevent_pthreads.a ./libs | |
cp $(brew --prefix)/opt/libevent/lib/libevent.a ./libs | |
# libyaml | |
cp $(brew --prefix)/opt/libyaml/lib/libyaml.a ./libs | |
# libgc | |
cp $(brew --prefix)/opt/bdw-gc/lib/libgc.a ./libs | |
# libpcre | |
cp $(brew --prefix)/opt/pcre2/lib/libpcre2-8.a ./libs | |
- name: Build the binary | |
# Statically link most non-system libraries | |
run: | | |
env CRYSTAL_LIBRARY_PATH=`pwd`/libs crystal projects.cr build:cli --no-debug --release -Dpreview_mt | |
mkdir bin | |
mv ./packages/cli/bin/zap ./bin/zap | |
- name: Upload a Build Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: zap_x86_64-apple-darwin | |
path: ./bin/zap | |
if-no-files-found: error | |
macos_arm64: | |
runs-on: macos-14 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Crystal | |
run: brew update && brew install crystal || true | |
- name: Copy static libraries | |
run: | | |
mkdir -p ./libs | |
# openssl | |
cp $(brew --prefix)/opt/openssl@3/lib/libssl.a ./libs | |
cp $(brew --prefix)/opt/openssl@3/lib/libcrypto.a ./libs | |
# libevent | |
cp $(brew --prefix)/opt/libevent/lib/libevent_pthreads.a ./libs | |
cp $(brew --prefix)/opt/libevent/lib/libevent.a ./libs | |
# libyaml | |
cp $(brew --prefix)/opt/libyaml/lib/libyaml.a ./libs | |
# libgc | |
cp $(brew --prefix)/opt/bdw-gc/lib/libgc.a ./libs | |
# libpcre | |
cp $(brew --prefix)/opt/pcre2/lib/libpcre2-8.a ./libs | |
- name: Build the binary | |
run: | | |
env CRYSTAL_LIBRARY_PATH=`pwd`/libs crystal projects.cr build:cli --no-debug --release -Dpreview_mt | |
mkdir bin | |
mv ./packages/cli/bin/zap ./bin/zap | |
- name: Upload a Build Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: zap_arm64-apple-darwin | |
path: ./bin/zap | |
if-no-files-found: error | |
linux: | |
runs-on: ubuntu-latest | |
container: | |
image: crystallang/crystal:latest-alpine | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Build the static binary | |
run: | | |
crystal projects.cr build:cli --production --release --static --no-debug --stats | |
mkdir bin | |
mv ./packages/cli/bin/zap ./bin/zap | |
- name: Upload a Build Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: zap_x86_64-linux-musl | |
path: ./bin/zap | |
if-no-files-found: error | |
windows: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Crystal | |
uses: crystal-lang/install-crystal@v1 | |
- name: Build the binary | |
shell: bash | |
run: | | |
crystal projects.cr build:cli --progress --release --no-debug --stats | |
mkdir bin | |
mv ./packages/cli/bin/zap.exe ./bin/zap.exe | |
ls -al ./bin | |
- name: Upload a Build Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: zap_x86_64-pc-win32.exe | |
path: ${{ github.workspace }}\bin\zap.exe | |
if-no-files-found: error | |
trigger_release: | |
runs-on: ubuntu-latest | |
needs: [macos_x86_64, macos_arm64, linux, windows] | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Check if release is needed | |
run: | | |
needs_release=$(git diff HEAD^1 shard.yml | grep "+version: " | wc -l | xargs) | |
echo "needs_release=$needs_release" >> $GITHUB_ENV | |
- name: Determine release version and tag | |
uses: actions/github-script@v6 | |
id: release-data | |
if: ${{ env.needs_release == 1 }} | |
with: | |
script: | | |
const { version } = require("./npm/zap/package.json") | |
const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ | |
const [, major, minor, patch, prerelease, metadata] = version.match(semverRegex) | |
const data = { | |
version, | |
major, | |
minor, | |
patch, | |
prerelease, | |
metadata, | |
distTag: prerelease ? prerelease.split(".")[0] : "latest" | |
} | |
console.log(data) | |
return data | |
- name: Trigger release | |
if: ${{ env.needs_release == 1 }} | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh workflow run "release.yml" -f workflow_run_id=${{ github.run_id }} -f dist_tag="${{fromJSON(steps.release-data.outputs.result).distTag}}" |