-
Notifications
You must be signed in to change notification settings - Fork 1
155 lines (151 loc) · 5.4 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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@v2
- 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@v2
- 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@v2
- 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@v2
- 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 ./bin/zap
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@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}}"