chore: add some benchmarks #272
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-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Install Crystal | |
run: brew update && brew install crystal | |
- name: Build the binary | |
# Statically link most non-system libraries | |
run: | | |
cc=$(env CRYSTAL_LIBRARY_PATH=`pwd`/libs/x86_64-apple-darwin shards build --target="x86_64-apple-darwin" --cross-compile --no-debug --release -Dpreview_mt | tail -n 1) | |
eval $cc | |
- name: Upload a Build Artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: zap_x86_64-apple-darwin | |
path: ./bin/zap | |
if-no-files-found: error | |
macos_arm64: | |
runs-on: macos-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Install Crystal | |
run: brew update && brew install crystal | |
- name: Build the binary | |
# Statically link most non-system libraries | |
run: | | |
cc=$(env CRYSTAL_LIBRARY_PATH=`pwd`/libs/arm64-apple-darwin shards build --target="arm64-apple-darwin" --cross-compile --no-debug --release | tail -n 1 | sed -e "s/-rdynamic/--target=arm64-apple-darwin -rdynamic/g") | |
eval $cc | |
- name: Upload a Build Artifact | |
uses: actions/upload-artifact@v2 | |
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@v2 | |
- name: Build the static binary | |
run: shards build --production --release --static --no-debug --stats | |
- name: Upload a Build Artifact | |
uses: actions/upload-artifact@v2 | |
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@v2 | |
- name: Install Crystal | |
uses: crystal-lang/install-crystal@v1 | |
- name: Build the binary | |
shell: bash | |
run: | | |
shards build --progress --release --no-debug --stats | |
ls -al ./bin | |
- name: Upload a Build Artifact | |
uses: actions/upload-artifact@v2 | |
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@v2 | |
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}}" |