Skip to content

Commit 851ea63

Browse files
committed
Introduce Github Action to build Darwin packages.
Allow to run build scripts for darwin to test changes in PR.
1 parent 9d6e645 commit 851ea63

File tree

2 files changed

+95
-1
lines changed

2 files changed

+95
-1
lines changed

.github/workflows/darwin_build.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Darwin Package Build
2+
3+
on: [push, pull_request]
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
9+
env:
10+
LOG_LEVEL: debug
11+
12+
jobs:
13+
dist_darwin:
14+
runs-on: macos-11
15+
16+
steps:
17+
-
18+
name: Select Xcode
19+
uses: maxim-lobanov/setup-xcode@v1
20+
with:
21+
xcode-version: '13.2.1'
22+
23+
- # Reference: https://github.com/actions/checkout#Checkout-multiple-repos-side-by-side
24+
name: Download distribution-scripts sources
25+
uses: actions/checkout@v4
26+
with:
27+
path: distribution-scripts
28+
29+
-
30+
name: Download crystal sources
31+
uses: actions/checkout@v4
32+
with:
33+
repository: crystal-lang/crystal
34+
path: crystal
35+
fetch-tags: true
36+
fetch-depth: 0
37+
38+
-
39+
name: Restore Omnibus Depenedcies' cache
40+
uses: actions/cache@v3
41+
with:
42+
path: distribution-scripts/omnibus/vendor/bundler
43+
key: ${{ runner.os }}-omnibus-bundler-${{ hashFiles('distribution-scripts/omnibus/Gemfile.lock') }}
44+
restore-keys: |
45+
${{ runner.os }}-omnibus-bundler-
46+
${{ runner.os }}-
47+
48+
-
49+
name: Install Omnibus Depenedcies
50+
run: |
51+
cd omnibus
52+
bundle install --path vendor/bundler
53+
54+
-
55+
name: Create build folders
56+
run: |
57+
sudo mkdir -p /opt/crystal
58+
sudo chown $(whoami) /opt/crystal/
59+
sudo mkdir -p /var/cache
60+
sudo chown $(whoami) /var/cache
61+
62+
-
63+
name: Build Dawin package
64+
run: |
65+
make -C distribution-scripts/darwin \
66+
OMNIBUS_OPTS="--log-level ${{ env.LOG_LEVEL }} --override use_git_caching:false" \
67+
CRYSTAL_REPO=$GITHUB_WORKSPACE/crystal \
68+
CRYSTAL_SRC=$GITHUB_WORKSPACE/crystal \
69+
CRYSTAL_SHA1=master \
70+
CRYSTAL_VERSION=1.11.0 \
71+
PACKAGE_ITERATION=1 \
72+
LLVM_VERSION=15.0.7 \
73+
PREVIOUS_CRYSTAL_RELEASE_DARWIN_TARGZ=https://github.com/crystal-lang/crystal/releases/download/1.10.1/crystal-1.10.1-1-darwin-universal.tar.gz
74+
75+
76+
- # Reference: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
77+
name: Extract the package name to be used for the artifact name
78+
run: |
79+
cd distribution-scripts/darwin/build
80+
ls -la
81+
filename=$(ls -1 crystal-*.tar.gz)
82+
echo "ARTIFACT_NAME=${filename%.tar.gz}" >> "$GITHUB_ENV"
83+
84+
- # When an Artifact is uploaded, all the files are assembled into an immutable Zip archive.
85+
# https://github.com/actions/upload-artifact#zip-archives
86+
name: Upload artifact
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: ${{ env.ARTIFACT_NAME }}
90+
path: distribution-scripts/darwin/build/*
91+
retention-days: 1
92+
if-no-files-found: error
93+
compression-level: 0 # package is already compressed

darwin/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ FORCE_GIT_TAGGED ?= 1 ## Require build to be based on git tag/branc
1111

1212
PREVIOUS_CRYSTAL_RELEASE_DARWIN_TARGZ ?= ## url to crystal-{version}-{package}-darwin-x86_64.tar.gz
1313

14+
OMNIBUS_OPTS ?= ## Build arguments for omnibus command line
1415
OUTPUT_DIR = build
1516

1617
# mimics the tgz_package.rb version mangling
@@ -65,7 +66,7 @@ endif
6566
&& export MACOSX_DEPLOYMENT_TARGET=11.0 \
6667
&& export SDKROOT=$(shell xcrun --sdk macosx --show-sdk-path) \
6768
&& bundle exec omnibus clean crystal shards \
68-
&& bundle exec omnibus build crystal \
69+
&& bundle exec omnibus build crystal $(OMNIBUS_OPTS) \
6970
&& cp ./pkg/$(DARWIN_NAME) $(CURDIR)/$(OUTPUT_DIR)/$(subst x86_64,universal,$(DARWIN_NAME)) \
7071
&& cp ./pkg/$(DARWIN_PKG_NAME) $(CURDIR)/$(OUTPUT_DIR)/$(subst x86_64,universal,$(DARWIN_PKG_NAME))
7172

0 commit comments

Comments
 (0)