Skip to content

Commit 9b04d46

Browse files
authored
CI: Fix Release.yml (#4)
* chore(ci): rename artifacts and optimize release workflow * chore(ci): add pull_request trigger to release workflow * docs: rename project from "Mortar DSL" to "Mortar Language" * feat: add test-build job for PR validation in release workflow
1 parent 7328283 commit 9b04d46

3 files changed

Lines changed: 94 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ on:
44
push:
55
tags:
66
- 'v*'
7+
pull_request:
8+
branches: [ main ]
9+
paths:
10+
- '.github/workflows/release.yml'
11+
- 'Cargo.toml'
12+
- 'src/**'
713

814
env:
915
CARGO_TERM_COLOR: always
@@ -12,9 +18,89 @@ permissions:
1218
contents: write
1319

1420
jobs:
21+
test-build:
22+
name: Test Release Build
23+
runs-on: ${{ matrix.os }}
24+
if: github.event_name == 'pull_request'
25+
strategy:
26+
matrix:
27+
os: [ubuntu-latest, windows-latest, macos-latest]
28+
include:
29+
- os: ubuntu-latest
30+
target: x86_64-unknown-linux-gnu
31+
artifact_name: mortar_language
32+
- os: windows-latest
33+
target: x86_64-pc-windows-msvc
34+
artifact_name: mortar_language.exe
35+
- os: macos-latest
36+
target: x86_64-apple-darwin
37+
arm_target: aarch64-apple-darwin
38+
artifact_name: mortar_language
39+
40+
steps:
41+
- uses: actions/checkout@v5
42+
43+
- name: Install dependencies (Ubuntu)
44+
if: matrix.os == 'ubuntu-latest'
45+
run: |
46+
sudo apt-get update
47+
sudo apt-get install -y \
48+
libasound2-dev \
49+
libudev-dev \
50+
libwayland-dev \
51+
libxkbcommon-dev \
52+
libxrandr-dev \
53+
libx11-dev \
54+
libxi-dev \
55+
libxinerama-dev \
56+
libxcursor-dev \
57+
libgl1-mesa-dev \
58+
pkg-config
59+
60+
- name: Install Rust
61+
uses: dtolnay/rust-toolchain@stable
62+
with:
63+
targets: ${{ matrix.target }}
64+
65+
- name: Install additional targets for macOS
66+
if: matrix.os == 'macos-latest'
67+
run: rustup target add ${{ matrix.arm_target }}
68+
69+
- name: Cache cargo registry
70+
uses: actions/cache@v4
71+
with:
72+
path: ~/.cargo/registry
73+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
74+
75+
- name: Cache cargo index
76+
uses: actions/cache@v4
77+
with:
78+
path: ~/.cargo/git
79+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
80+
81+
- name: Build release (Linux/Windows)
82+
if: matrix.os != 'macos-latest'
83+
run: cargo build --release --target ${{ matrix.target }}
84+
85+
- name: Build and Combine (macOS Universal Binary)
86+
if: matrix.os == 'macos-latest'
87+
run: |
88+
cargo build --release --target ${{ matrix.target }}
89+
cargo build --release --target ${{ matrix.arm_target }}
90+
lipo -create \
91+
target/${{ matrix.target }}/release/${{ matrix.artifact_name }} \
92+
target/${{ matrix.arm_target }}/release/${{ matrix.artifact_name }} \
93+
-output target/release/mortar-macos-universal
94+
strip target/release/mortar-macos-universal
95+
96+
- name: Strip binary (Linux)
97+
if: matrix.os == 'ubuntu-latest'
98+
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
99+
15100
create-release:
16101
name: Create Release
17102
runs-on: ubuntu-latest
103+
if: startsWith(github.ref, 'refs/tags/v')
18104
outputs:
19105
release_id: ${{ steps.create_release.outputs.id }}
20106
steps:
@@ -49,23 +135,24 @@ jobs:
49135
build-and-upload:
50136
name: Build and Upload
51137
needs: create-release
138+
if: startsWith(github.ref, 'refs/tags/v')
52139
runs-on: ${{ matrix.os }}
53140
strategy:
54141
matrix:
55142
os: [ubuntu-latest, windows-latest, macos-latest]
56143
include:
57144
- os: ubuntu-latest
58145
target: x86_64-unknown-linux-gnu
59-
artifact_name: mortar
146+
artifact_name: mortar_language
60147
asset_name: mortar-linux-x86_64
61148
- os: windows-latest
62149
target: x86_64-pc-windows-msvc
63-
artifact_name: mortar.exe
150+
artifact_name: mortar_language.exe
64151
asset_name: mortar-windows-x86_64.exe
65152
- os: macos-latest
66153
target: x86_64-apple-darwin
67154
arm_target: aarch64-apple-darwin
68-
artifact_name: mortar
155+
artifact_name: mortar_language
69156
asset_name: mortar-macos-universal
70157

71158
steps:
@@ -122,11 +209,12 @@ jobs:
122209
target/${{ matrix.target }}/release/${{ matrix.artifact_name }} \
123210
target/${{ matrix.arm_target }}/release/${{ matrix.artifact_name }} \
124211
-output target/release/${{ matrix.asset_name }}
212+
strip target/release/${{ matrix.asset_name }}
125213
echo "FINAL_ARTIFACT_PATH=target/release/${{ matrix.asset_name }}" >> $GITHUB_ENV
126214
echo "FINAL_ARTIFACT_NAME=${{ matrix.asset_name }}" >> $GITHUB_ENV
127215
128216
- name: Strip binary (Linux and macOS)
129-
if: matrix.os == 'ubuntu-latest' || (matrix.os == 'macos-latest' && env.FINAL_ARTIFACT_PATH == '')
217+
if: matrix.os == 'ubuntu-latest'
130218
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
131219

132220
- name: Upload Release Asset

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Mortar DSL
1+
# Mortar Language
22

33
[![license](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue)](LICENSE-MIT)
44
[![Crates.io](https://img.shields.io/crates/v/mortar.svg)](https://crates.io/crates/mortar)

readme_zh-hant.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Mortar DSL
1+
# Mortar Language
22

33
[![license](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue)](LICENSE-MIT)
44
[![Crates.io](https://img.shields.io/crates/v/mortar.svg)](https://crates.io/crates/mortar)

0 commit comments

Comments
 (0)