Skip to content

Commit

Permalink
Github Actions for CI/CD: Cross-platform release with proper naming
Browse files Browse the repository at this point in the history
Create releases from github workflow
  • Loading branch information
deephbz committed Dec 30, 2024
1 parent 6e0b199 commit a93beed
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build and Release

on:
push:
branches: [ main, master ]
tags: [ 'v*' ]
pull_request:
branches: [ main, master ]

jobs:
build:
strategy:
matrix:
include:
# Linux x86_64 (LDC)
- os: ubuntu-latest
platform_name: x86_64-linux
compiler: ldc-1.32.0

# macOS x86_64 (LDC)
- os: macos-latest
platform_name: x86_64-darwin
compiler: ldc-1.32.0

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Dlang
uses: dlang-community/setup-dlang@v2
with:
compiler: ${{ matrix.compiler }}

- name: Cache DUB dependencies
uses: actions/cache@v3
with:
path: ~/.dub
key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.json', '**/dub.sdl') }}
restore-keys: |
${{ runner.os }}-dub-
- name: Build Artifacts
run: make release

- name: Package Binary
if: startsWith(github.ref, 'refs/tags/')
run: |
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}" # Remove 'v' prefix if present
BINARY_NAME="literate-${{ matrix.platform_name }}"
mkdir -p release
cp bin/lit release/
cd release
tar czf "${BINARY_NAME}.tar.gz" lit
echo "ARTIFACT_PATH=release/${BINARY_NAME}.tar.gz" >> $GITHUB_ENV
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: literate-${{ matrix.platform_name }}
path: bin/lit

- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: ${{ env.ARTIFACT_PATH }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit a93beed

Please sign in to comment.