Skip to content

Commit c4c852c

Browse files
committed
Github Actions for CI/CD: Cross-platform release with proper naming
Create releases from github workflow
1 parent 6a9a3af commit c4c852c

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/build.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
tags: [ 'v*' ]
7+
pull_request:
8+
branches: [ main, master ]
9+
10+
jobs:
11+
build:
12+
strategy:
13+
matrix:
14+
include:
15+
# Linux x86_64 (LDC)
16+
- os: ubuntu-latest
17+
platform_name: x86_64-linux
18+
compiler: ldc-1.32.0
19+
20+
# macOS x86_64 (LDC)
21+
- os: macos-latest
22+
platform_name: x86_64-darwin
23+
compiler: ldc-1.32.0
24+
25+
runs-on: ${{ matrix.os }}
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
submodules: recursive
31+
32+
- name: Setup Dlang
33+
uses: dlang-community/setup-dlang@v2
34+
with:
35+
compiler: ${{ matrix.compiler }}
36+
37+
- name: Cache DUB dependencies
38+
uses: actions/cache@v3
39+
with:
40+
path: ~/.dub
41+
key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.json', '**/dub.sdl') }}
42+
restore-keys: |
43+
${{ runner.os }}-dub-
44+
45+
- name: Build Artifacts
46+
run: make release
47+
48+
- name: Package Binary
49+
if: startsWith(github.ref, 'refs/tags/')
50+
run: |
51+
VERSION="${{ github.ref_name }}"
52+
VERSION="${VERSION#v}" # Remove 'v' prefix if present
53+
BINARY_NAME="literate-${{ matrix.platform_name }}"
54+
cd bin
55+
tar czf "${BINARY_NAME}.tar.gz" lit
56+
echo "ARTIFACT_PATH=bin/${BINARY_NAME}.tar.gz" >> $GITHUB_ENV
57+
58+
- name: Upload Artifact
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: literate-${{ matrix.platform_name }}
62+
path: bin/lit
63+
64+
- name: Create Release
65+
if: startsWith(github.ref, 'refs/tags/')
66+
uses: softprops/action-gh-release@v1
67+
with:
68+
files: ${{ env.ARTIFACT_PATH }}
69+
draft: false
70+
prerelease: false
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)