Skip to content

Commit 576cc43

Browse files
committed
Add alpine support
1 parent 15cca56 commit 576cc43

File tree

3 files changed

+72
-12
lines changed

3 files changed

+72
-12
lines changed

.github/workflows/ci.yml

+40-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
name: Artifacts
2-
on: [push]
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
39
jobs:
410
build:
511
strategy:
@@ -32,6 +38,7 @@ jobs:
3238
dub -b release -- list -v
3339
dub -b release -- run -v -- --version
3440
- uses: actions/upload-artifact@v4
41+
if: github.ref == 'refs/heads/main'
3542
with:
3643
name: ldcup-${{ matrix.os }}-${{ matrix.arch }}
3744
path: bin
@@ -40,7 +47,7 @@ jobs:
4047
runs-on: ubuntu-latest
4148
steps:
4249
- uses: actions/checkout@v4
43-
- name: Test in FreeBSD
50+
- name: Run FreeBSD VM
4451
uses: vmactions/freebsd-vm@v1
4552
with:
4653
usesh: true
@@ -55,6 +62,37 @@ jobs:
5562
dub -b release -- list -v
5663
dub -b release -- run -v -- --version
5764
- uses: actions/upload-artifact@v4
65+
if: github.ref == 'refs/heads/main'
5866
with:
5967
name: ldcup-freebsd-14.2-amd64
6068
path: bin
69+
70+
alpine:
71+
strategy:
72+
fail-fast: false
73+
runs-on: ubuntu-latest
74+
container:
75+
image: alpine:latest
76+
defaults:
77+
run:
78+
shell: sh
79+
steps:
80+
- uses: actions/checkout@v4
81+
82+
- name: Prepare
83+
run: |
84+
apk update
85+
apk add --no-cache ldc dub clang
86+
- name: Build
87+
run: |
88+
dub -b release
89+
# - name: Tests
90+
# run: |
91+
# dub -b release -- install ldc2-nightly -v
92+
# dub -b release -- list -v
93+
94+
- uses: actions/upload-artifact@v4
95+
if: github.ref == 'refs/heads/main'
96+
with:
97+
name: ldcup-alpine-amd64
98+
path: bin

dub.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ldcup",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "Download and manage D compiler [ldc2].",
55
"license": "Apache-2.0",
66
"targetPath": "bin",

source/impl.d

+31-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public import std;
44

55
enum OS
66
{
7+
alpine,
78
android,
89
freebsd,
910
linux,
@@ -85,14 +86,17 @@ class CompilerManager
8586
else version (FreeBSD)
8687
this.currentOS = OS.freebsd;
8788
else version (linux)
88-
this.currentOS = OS.linux;
89+
version (CRuntime_Musl)
90+
this.currentOS = OS.alpine;
91+
else
92+
this.currentOS = OS.linux;
8993
else version (Windows)
90-
{
91-
this.currentOS = OS.windows;
92-
this.currentArch = Arch.multilib;
93-
}
94-
else
95-
static assert(0, "Unsupported operating system");
94+
{
95+
this.currentOS = OS.windows;
96+
this.currentArch = Arch.multilib;
97+
}
98+
else
99+
static assert(0, "Unsupported operating system");
96100
}
97101

98102
void installCompiler(string compilerSpec) @safe
@@ -231,9 +235,27 @@ class CompilerManager
231235
{
232236
try
233237
{
234-
version (linux)
238+
version (FreeBSD)
239+
{
240+
auto result = execute([
241+
"getent", "passwd", environment.get("USER", "root")
242+
]);
243+
if (result.status == 0)
244+
{
245+
246+
string[] parts = result.output.split(":");
247+
if (parts.length > 6)
248+
{
249+
250+
return parts[6].strip();
251+
}
252+
}
253+
}
254+
else version (linux)
235255
{
236-
auto result = execute(["getent", "passwd", environment["USER"]]);
256+
auto result = execute([
257+
"getent", "passwd", environment.get("USER", "root")
258+
]);
237259
if (result.status == 0)
238260
{
239261
string[] parts = result.output.split(":");

0 commit comments

Comments
 (0)