Skip to content

Commit c43b020

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 c43b020

File tree

3 files changed

+111
-1
lines changed

3 files changed

+111
-1
lines changed

.github/workflows/darwin_build.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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: Cache Omnibus Depenedcies
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+
make -C distribution-scripts omnibus_setup
52+
53+
-
54+
name: Create build folders
55+
run: |
56+
sudo mkdir -p /opt/crystal
57+
sudo chown $(whoami) /opt/crystal/
58+
sudo mkdir -p /var/cache
59+
sudo chown $(whoami) /var/cache
60+
61+
-
62+
name: Build Dawin package
63+
run: |
64+
make -C distribution-scripts/darwin \
65+
OMNIBUS_OPTS="--log-level ${{ env.LOG_LEVEL }} --override use_git_caching:false" \
66+
CRYSTAL_REPO=$GITHUB_WORKSPACE/crystal \
67+
CRYSTAL_SRC=$GITHUB_WORKSPACE/crystal \
68+
CRYSTAL_SHA1=master \
69+
CRYSTAL_VERSION=1.11.0 \
70+
PACKAGE_ITERATION=1 \
71+
LLVM_VERSION=15.0.7 \
72+
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
73+
74+
75+
- # Reference: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
76+
name: Extract the package name to be used for the artifact name
77+
run: |
78+
cd distribution-scripts/darwin/build
79+
ls -la
80+
filename=$(ls -1 crystal-*.tar.gz)
81+
echo "ARTIFACT_NAME=${filename%.tar.gz}" >> "$GITHUB_ENV"
82+
83+
- # When an Artifact is uploaded, all the files are assembled into an immutable Zip archive.
84+
# https://github.com/actions/upload-artifact#zip-archives
85+
name: Upload artifact
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: ${{ env.ARTIFACT_NAME }}
89+
path: distribution-scripts/darwin/build/*
90+
retention-days: 1
91+
if-no-files-found: error
92+
compression-level: 0 # package is already compressed

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.PHONY: darwin
2+
darwin: omnibus_setup
3+
FORCE_GIT_TAGGED=0 \
4+
CRYSTAL_REPO=https://github.com/crystal-lang/crystal \
5+
CRYSTAL_SHA1=master \
6+
CRYSTAL_VERSION=1.10.1 \
7+
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 \
8+
make -C darwin
9+
10+
# https://github.com/chef/omnibus
11+
.PHONY: omnibus_setup
12+
omnibus_setup:
13+
cd omnibus && bundle install --path vendor/bundler
14+
15+
.PHONY: clean
16+
clean:
17+
make -C darwin clean

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)