Repository navigation
163 lines (133 loc) · 4.75 KB
/
Copy pathbuild.yml
File metadata and controls
163 lines (133 loc) · 4.75 KB
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
156
157
158
159
160
161
162
163
name: Build
on:
workflow_dispatch:
permissions:
contents: write
jobs:
build:
name: Build
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
openssl: default
# macOS 15 (Intel) with OpenSSL 1.1
- os: macos-15-intel
openssl: default
# macOS 15 (Intel) with OpenSSL 3
- os: macos-15-intel
openssl: 3
# macOS latest (ARM64) with OpenSSL 1.1
- os: macos-latest
openssl: default
# macOS latest (ARM64) with OpenSSL 3
- os: macos-latest
openssl: 3
- os: windows-latest
openssl: default
runs-on: ${{ matrix.os }}
steps:
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: 1.21.1
- name: Checkout source code
uses: actions/checkout@v7
- name: Install dependencies
run: shards install
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v5
- name: Set architecture environment variable
shell: bash
run: |
if [ "$RUNNER_ARCH" == "X64" ]; then
echo "ARCH=x86_64" >> $GITHUB_ENV
elif [ "$RUNNER_ARCH" == "ARM64" ]; then
echo "ARCH=arm64" >> $GITHUB_ENV
else
echo "ARCH=unknown" >> $GITHUB_ENV
fi
- name: Set OpenSSL suffix
shell: bash
run: |
if [ "${{ matrix.openssl }}" == "3" ]; then
echo "OPENSSL_SUFFIX=-openssl3" >> $GITHUB_ENV
else
echo "OPENSSL_SUFFIX=" >> $GITHUB_ENV
fi
- name: Install OpenSSL 3 via Homebrew (macOS)
if: startsWith(matrix.os, 'macos') && matrix.openssl == '3'
run: |
echo "Installing OpenSSL 3 via Homebrew..."
brew update
# Install or upgrade OpenSSL 3
if brew list openssl@3 &>/dev/null; then
echo "OpenSSL 3 found, upgrading..."
brew upgrade openssl@3 || true
else
echo "Installing OpenSSL 3..."
brew install openssl@3
fi
# Try to link, but don't fail if it doesn't work
brew link openssl@3 --force --overwrite || true
# Determine the correct paths based on architecture
if [ "$RUNNER_ARCH" == "ARM64" ]; then
BREW_PREFIX="/opt/homebrew"
else
BREW_PREFIX="/usr/local"
fi
# Use the actual installation path
OPENSSL3_PATH="${BREW_PREFIX}/opt/openssl@3"
# Verify OpenSSL 3 is installed
if [ ! -d "$OPENSSL3_PATH" ]; then
echo "Error: OpenSSL 3 not found at $OPENSSL3_PATH"
exit 1
fi
echo "OpenSSL 3 found at: $OPENSSL3_PATH"
# Set environment variables using the correct path
echo "${OPENSSL3_PATH}/bin" >> $GITHUB_PATH
echo "PKG_CONFIG_PATH=${OPENSSL3_PATH}/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
echo "LDFLAGS=-L${OPENSSL3_PATH}/lib" >> $GITHUB_ENV
echo "CPPFLAGS=-I${OPENSSL3_PATH}/include" >> $GITHUB_ENV
echo "OPENSSL_DIR=${OPENSSL3_PATH}" >> $GITHUB_ENV
# Crystal specific
echo "CRYSTAL_LIBRARY_PATH=${OPENSSL3_PATH}/lib:$CRYSTAL_LIBRARY_PATH" >> $GITHUB_ENV
- if: matrix.os == 'ubuntu-latest'
name: Build binary (Linux)
run: |
mkdir build
docker compose run --rm app crystal build src/mint.cr \
-o build/mint-${GITHUB_REF_SLUG}-linux-${ARCH} \
--static --no-debug --release
- if: startsWith(matrix.os, 'macos')
name: Build binary (macOS)
run: |
mkdir build
crystal build src/mint.cr \
-o build/mint-${GITHUB_REF_SLUG}-osx-${ARCH}${OPENSSL_SUFFIX} \
--no-debug --release
# We are linking statically so the binary can be used on its own,
# otherwise the DLLs it's linked against need to be next to it.
- if: matrix.os == 'windows-latest'
name: Build binary (Windows)
shell: bash
run: |
mkdir build
crystal build src/mint.cr \
-o build/mint-${GITHUB_REF_SLUG}-windows-${ARCH}.exe \
--static --no-debug --release
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: build-${{ matrix.os }}-${{ matrix.openssl }}
path: build
- if: startsWith(github.ref, 'refs/tags/')
name: Upload to GitHub Releases
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
overwrite: true
file_glob: true
file: build/*