-
Notifications
You must be signed in to change notification settings - Fork 1
119 lines (115 loc) · 4.13 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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}}"