Skip to content

Commit 8c61171

Browse files
authored
Release workflow (luau-lang#104)
1 parent d0250a8 commit 8c61171

File tree

4 files changed

+160
-3
lines changed

4 files changed

+160
-3
lines changed

.github/workflows/release.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Build and Release
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
include:
13+
- os: ubuntu-latest
14+
artifact_name: lute-linux-x86_64
15+
options: --c-compiler=clang --cxx-compiler=clang++
16+
- os: ubuntu-24.04-arm
17+
artifact_name: lute-linux-aarch64
18+
options: --c-compiler=clang --cxx-compiler=clang++
19+
- os: macos-latest
20+
artifact_name: lute-macos-aarch64
21+
- os: windows-latest
22+
artifact_name: lute-windows-x86_64
23+
fail-fast: false
24+
25+
runs-on: ${{ matrix.os }}
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: '3.11'
35+
36+
- name: Install dependencies (Linux)
37+
if: runner.os == 'Linux'
38+
run: |
39+
sudo apt-get update
40+
sudo apt-get install -y ninja-build clang
41+
42+
- name: Install dependencies (macOS)
43+
if: runner.os == 'macOS'
44+
run: |
45+
brew update
46+
brew install cmake ninja
47+
48+
- name: Install dependencies (Windows)
49+
if: runner.os == 'Windows'
50+
run: |
51+
choco install ninja
52+
53+
- if: runner.os == 'Windows'
54+
uses: ilammy/msvc-dev-cmd@v1
55+
56+
- name: Configure
57+
run: python ./tools/luthier.py configure lute --config release ${{ matrix.options }}
58+
59+
- name: Build
60+
run: python ./tools/luthier.py build lute --config release ${{ matrix.options }}
61+
62+
- name: Get Artifact Path
63+
id: artifact_path
64+
shell: bash
65+
run: |
66+
exe_path=$(python ./tools/luthier.py build lute --config release --which)
67+
echo "Executable path: $exe_path" # Debug print
68+
echo "exe_path=$exe_path" >> "$GITHUB_OUTPUT"
69+
70+
- name: Upload Artifact
71+
uses: actions/upload-artifact@v4
72+
with:
73+
path: ${{ steps.artifact_path.outputs.exe_path }}
74+
name: ${{ matrix.artifact_name }}
75+
76+
release:
77+
needs: build
78+
runs-on: ubuntu-latest
79+
80+
permissions:
81+
contents: write
82+
83+
steps:
84+
- name: Checkout code
85+
uses: actions/checkout@v4
86+
with:
87+
sparse-checkout: get_version.cmake
88+
89+
- name: Download Artifact
90+
uses: actions/download-artifact@v4
91+
with:
92+
path: artifacts
93+
94+
- run: |
95+
mkdir release
96+
for dir in ./artifacts/*; do
97+
base_name=$(basename "$dir")
98+
zip -rj release/"${base_name}.zip" "$dir"/*
99+
done
100+
101+
- name: Get project version
102+
id: get_version
103+
run: |
104+
VERSION=$(cmake -P get_version.cmake 2>&1)
105+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
106+
107+
- name: Create Nightly Tag
108+
id: tag_step
109+
if: github.event_name == 'schedule'
110+
run: |
111+
DATE=$(date +%Y%m%d)
112+
TAG="-nightly.$DATE"
113+
echo "tag=$TAG" >> $GITHUB_OUTPUT
114+
115+
- name: Create Release Tag
116+
id: tag_release
117+
run: |
118+
VERSION=${{ steps.get_version.outputs.version }}
119+
NIGHTLY_TAG=${{ steps.tag_step.outputs.tag }}
120+
RELEASE_TAG="$VERSION$NIGHTLY_TAG"
121+
echo "tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
122+
123+
- name: Create Release
124+
uses: softprops/action-gh-release@v2
125+
with:
126+
tag_name: ${{ steps.tag_release.outputs.tag }}
127+
name: ${{ steps.tag_release.outputs.tag }}
128+
draft: false
129+
prerelease: ${{ github.event_name == 'schedule' }}
130+
files: release/*.zip

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
55

66
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
77

8-
project(Lute LANGUAGES CXX C)
8+
include(get_version.cmake)
9+
10+
project(Lute LANGUAGES CXX C VERSION ${LUTE_VERSION})
911

1012
add_library(Lute.Runtime STATIC)
1113
add_library(Lute.Fs STATIC)

get_version.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
3+
set(LUTE_VERSION 0.1.0)
4+
message("${LUTE_VERSION}")

tools/luthier.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ class ReportableError(Exception):
6363
help='print out the path to the compiled binary and exit'
6464
)
6565

66+
argParser.add_argument(
67+
'--cxx-compiler', dest='cxx_compiler', action='store',
68+
help='C++ compiler to use',
69+
)
70+
71+
argParser.add_argument(
72+
'--c-compiler', dest='c_compiler', action='store',
73+
help='C compiler to use',
74+
)
75+
6676
if isWindows:
6777
vsVersionGroup = argParser.add_mutually_exclusive_group()
6878

@@ -150,7 +160,10 @@ def getProjectPath(args):
150160

151161
config = getConfig(args).lower()
152162

153-
return os.path.join(buildDir, getCompiler(args), config)
163+
if isLinux:
164+
return os.path.join(buildDir, config)
165+
else:
166+
return os.path.join(buildDir, getCompiler(args), config)
154167

155168
def projectPathExists(args):
156169
projectPath = getProjectPath(args)
@@ -176,7 +189,6 @@ def getExePath(args):
176189
return os.path.join(
177190
buildDir,
178191
config.lower(),
179-
container,
180192
exeName
181193
)
182194

@@ -206,6 +218,9 @@ def build(args):
206218
targetName = args.target
207219
projectPath = getProjectPath(args)
208220

221+
if isWindows:
222+
targetName = targetName + '.exe'
223+
209224
if args.clean:
210225
call(['ninja', '-C', projectPath, 'clean'])
211226

@@ -239,6 +254,12 @@ def getConfigureArguments(args):
239254
'-DCMAKE_EXPORT_COMPILE_COMMANDS=1',
240255
]
241256

257+
if args.cxx_compiler:
258+
configArgs.append('-DCMAKE_CXX_COMPILER=' + args.cxx_compiler)
259+
260+
if args.c_compiler:
261+
configArgs.append('-DCMAKE_C_COMPILER=' + args.c_compiler)
262+
242263
return configArgs
243264

244265
def configure(args):

0 commit comments

Comments
 (0)