Skip to content

Commit 0bec55a

Browse files
chore(.github): additional release binaries
1 parent 80b05a5 commit 0bec55a

2 files changed

Lines changed: 75 additions & 14 deletions

File tree

.github/workflows/release.yml

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,93 @@ on:
99
workflow_dispatch:
1010

1111
jobs:
12-
publish:
12+
build-linux:
1313
runs-on: ubuntu-24.04
1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1717

18-
- name: Set up Bun
19-
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
20-
2118
- name: Set up Rust
2219
uses: dtolnay/rust-toolchain@stable
2320
with:
2421
targets: x86_64-unknown-linux-gnu
2522

23+
- name: Build server binary
24+
run: cargo build --release --bin server --target x86_64-unknown-linux-gnu
25+
26+
- name: Stage binary
27+
run: |
28+
mkdir -p bin
29+
cp target/x86_64-unknown-linux-gnu/release/server bin/freecodecamp-server-x86_64-unknown-linux-gnu
30+
31+
- name: Upload artifact
32+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
33+
with:
34+
name: bin-linux
35+
path: bin/freecodecamp-server-x86_64-unknown-linux-gnu
36+
37+
build-mac:
38+
runs-on: macos-14
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
42+
43+
- name: Set up Rust
44+
uses: dtolnay/rust-toolchain@stable
45+
with:
46+
targets: aarch64-apple-darwin,x86_64-apple-darwin
47+
48+
- name: Build server binary (arm64)
49+
run: cargo build --release --bin server --target aarch64-apple-darwin
50+
51+
- name: Build server binary (x86_64)
52+
run: cargo build --release --bin server --target x86_64-apple-darwin
53+
54+
- name: Stage binaries
55+
run: |
56+
mkdir -p bin
57+
cp target/aarch64-apple-darwin/release/server bin/freecodecamp-server-aarch64-apple-darwin
58+
cp target/x86_64-apple-darwin/release/server bin/freecodecamp-server-x86_64-apple-darwin
59+
60+
- name: Upload artifacts
61+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
62+
with:
63+
name: bin-mac
64+
path: |
65+
bin/freecodecamp-server-aarch64-apple-darwin
66+
bin/freecodecamp-server-x86_64-apple-darwin
67+
68+
publish:
69+
needs: [build-linux, build-mac]
70+
runs-on: ubuntu-24.04
71+
steps:
72+
- name: Checkout
73+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
74+
75+
- name: Set up Bun
76+
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
77+
2678
- name: Build client
2779
run: bun install && bun run build:client
2880

29-
- name: Build server binary
30-
run: cargo build --release --bin server --target x86_64-unknown-linux-gnu
81+
- name: Download binaries
82+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
83+
with:
84+
merge-multiple: true
85+
path: bin/
3186

32-
- name: Rename binary
33-
run: cp target/x86_64-unknown-linux-gnu/release/server freecodecamp-server-x86_64-unknown-linux-gnu
87+
- name: Mark binaries executable
88+
run: chmod +x bin/freecodecamp-server-*
3489

35-
- name: Upload binary to release
90+
- name: Upload binaries to release
3691
if: github.event_name == 'release'
3792
env:
3893
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3994
run: |
4095
gh release upload "${{ github.ref_name }}" \
41-
freecodecamp-server-x86_64-unknown-linux-gnu \
96+
bin/freecodecamp-server-x86_64-unknown-linux-gnu \
97+
bin/freecodecamp-server-aarch64-apple-darwin \
98+
bin/freecodecamp-server-x86_64-apple-darwin \
4299
--clobber
43100
44101
- name: Set up Node
@@ -48,6 +105,6 @@ jobs:
48105
registry-url: 'https://registry.npmjs.org'
49106

50107
- name: Publish to npm
51-
run: npm publish
108+
run: npm publish --access public
52109
env:
53110
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}

scripts/postinstall.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ if (!__dirname.includes('node_modules')) {
1313

1414
const PLATFORM_MAP = {
1515
'linux-x64': 'x86_64-unknown-linux-gnu',
16+
'darwin-x64': 'x86_64-apple-darwin',
17+
'darwin-arm64': 'aarch64-apple-darwin',
1618
};
1719

1820
const key = `${process.platform}-${process.arch}`;
@@ -29,10 +31,12 @@ const url = `https://github.com/freeCodeCamp/freeCodeCampOS/releases/download/v$
2931

3032
mkdirSync(binDir, { recursive: true });
3133

32-
// Binary was bundled with the published package — just ensure it's executable
33-
if (existsSync(binPath)) {
34+
// Binary was bundled with the published package — copy the platform binary into place
35+
const bundledBin = join(binDir, `freecodecamp-server-${target}`);
36+
if (existsSync(bundledBin)) {
37+
require('fs').copyFileSync(bundledBin, binPath);
3438
chmodSync(binPath, 0o755);
35-
console.log('freecodecamp-os: binary already present at', binPath);
39+
console.log('freecodecamp-os: installed bundled binary for', target);
3640
process.exit(0);
3741
}
3842

0 commit comments

Comments
 (0)