Skip to content

Commit a93beed

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

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

.github/workflows/build.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
mkdir -p release
55+
cp bin/lit release/
56+
cd release
57+
tar czf "${BINARY_NAME}.tar.gz" lit
58+
echo "ARTIFACT_PATH=release/${BINARY_NAME}.tar.gz" >> $GITHUB_ENV
59+
60+
- name: Upload Artifact
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: literate-${{ matrix.platform_name }}
64+
path: bin/lit
65+
66+
- name: Create Release
67+
if: startsWith(github.ref, 'refs/tags/')
68+
uses: softprops/action-gh-release@v1
69+
with:
70+
files: ${{ env.ARTIFACT_PATH }}
71+
draft: false
72+
prerelease: false
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)