Skip to content

Commit 9c0f2d8

Browse files
aabmetsMattias Aabmets
andauthored
Add static musl builds for Linux and conditional crate publishing (#10)
* Release workflow now skips Cargo crate publishing if CARGO_REGISTRY_TOKEN is missing * Dynamically link amd64 linux build on lower Ubuntu version for better glibc compatibility, add statically-linked musl compilation targets * Add build step to install missing musl-tool dependencies for musl targets --------- Co-authored-by: Mattias Aabmets <mattias.aabmets@tietoevry.com>
1 parent 08dd9c0 commit 9c0f2d8

1 file changed

Lines changed: 32 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
outputs:
2727
version: ${{ steps.check.outputs.version }}
2828
is_release: ${{ steps.check.outputs.is_release }}
29+
has_token: ${{ steps.check.outputs.has_token }}
2930
steps:
3031
- name: Checkout repository
3132
uses: actions/checkout@v4
@@ -65,12 +66,19 @@ jobs:
6566
echo "ℹ️ Version normalized to: $version"
6667
fi
6768
69+
has_token="false"
70+
if [ -n "${{ secrets.CARGO_REGISTRY_TOKEN }}" ]; then
71+
has_token="true"
72+
fi
73+
6874
echo "version=$version" >> $GITHUB_OUTPUT
6975
echo "is_release=$is_release" >> $GITHUB_OUTPUT
76+
echo "has_token=$has_token" >> $GITHUB_OUTPUT
7077
7178
echo "📊 Build Summary:"
7279
echo " - Version: $version"
7380
echo " - Is release: $is_release"
81+
echo " - Publish crate: $has_token"
7482
7583
build:
7684
name: Build (${{ matrix.os_name }}-${{ matrix.arch }})
@@ -83,7 +91,7 @@ jobs:
8391
matrix:
8492
include:
8593
# Linux
86-
- os: ubuntu-latest
94+
- os: ubuntu-22.04
8795
target: x86_64-unknown-linux-gnu
8896
os_name: linux
8997
arch: amd64
@@ -96,6 +104,20 @@ jobs:
96104
artifact_name: rc
97105
cross: true
98106

107+
- os: ubuntu-latest
108+
target: x86_64-unknown-linux-musl
109+
os_name: linux
110+
arch: amd64-musl
111+
artifact_name: rc
112+
cross: false
113+
114+
- os: ubuntu-latest
115+
target: aarch64-unknown-linux-musl
116+
os_name: linux
117+
arch: arm64-musl
118+
artifact_name: rc
119+
cross: true
120+
99121
# macOS (both targets built on ARM64 runner with cross-compilation)
100122
- os: macos-latest
101123
target: x86_64-apple-darwin
@@ -130,6 +152,13 @@ jobs:
130152
with:
131153
key: ${{ matrix.target }}
132154

155+
- name: Add Rust target
156+
run: rustup target add ${{ matrix.target }}
157+
158+
- name: Install musl-tools
159+
if: contains(matrix.target, 'musl')
160+
run: sudo apt-get update && sudo apt-get install -y musl-tools
161+
133162
# Install cross for cross-compilation
134163
- name: Install cross
135164
if: matrix.cross
@@ -407,7 +436,7 @@ jobs:
407436
408437
```bash
409438
brew tap rustfs/homebrew-tap
410-
439+
411440
brew install rustfs/tap/rc
412441
```
413442
@@ -424,7 +453,7 @@ jobs:
424453
name: Publish to crates.io
425454
needs: [ build-check, build ]
426455
runs-on: ubuntu-latest
427-
if: needs.build-check.outputs.is_release == 'true'
456+
if: needs.build-check.outputs.is_release == 'true' && needs.build-check.outputs.has_token == 'true'
428457
steps:
429458
- name: Checkout repository
430459
uses: actions/checkout@v4

0 commit comments

Comments
 (0)