|
9 | 9 | workflow_dispatch: |
10 | 10 |
|
11 | 11 | jobs: |
12 | | - publish: |
| 12 | + build-linux: |
13 | 13 | runs-on: ubuntu-24.04 |
14 | 14 | steps: |
15 | 15 | - name: Checkout |
16 | 16 | uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
17 | 17 |
|
18 | | - - name: Set up Bun |
19 | | - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 |
20 | | - |
21 | 18 | - name: Set up Rust |
22 | 19 | uses: dtolnay/rust-toolchain@stable |
23 | 20 | with: |
24 | 21 | targets: x86_64-unknown-linux-gnu |
25 | 22 |
|
| 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 | + |
26 | 78 | - name: Build client |
27 | 79 | run: bun install && bun run build:client |
28 | 80 |
|
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/ |
31 | 86 |
|
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-* |
34 | 89 |
|
35 | | - - name: Upload binary to release |
| 90 | + - name: Upload binaries to release |
36 | 91 | if: github.event_name == 'release' |
37 | 92 | env: |
38 | 93 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
39 | 94 | run: | |
40 | 95 | 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 \ |
42 | 99 | --clobber |
43 | 100 |
|
44 | 101 | - name: Set up Node |
|
48 | 105 | registry-url: 'https://registry.npmjs.org' |
49 | 106 |
|
50 | 107 | - name: Publish to npm |
51 | | - run: npm publish |
| 108 | + run: npm publish --access public |
52 | 109 | env: |
53 | 110 | NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} |
0 commit comments