Skip to content

Commit 5ec663e

Browse files
committed
thx gemini
1 parent 4324ce7 commit 5ec663e

File tree

3 files changed

+92
-4
lines changed

3 files changed

+92
-4
lines changed

.github/workflows/release.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Release Toy OS
2+
3+
on:
4+
push:
5+
branches: [ "main", "master" ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build-and-release:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup Rust (OS)
19+
uses: dtolnay/rust-toolchain@nightly
20+
with:
21+
targets: riscv64gc-unknown-none-elf
22+
components: rust-src, llvm-tools-preview
23+
24+
- name: Setup Rust (User)
25+
# This step ensures the specific toolchain defined in user/rust-toolchain.toml is installed
26+
# before the build script runs, avoiding timeouts or silenced output during make.
27+
working-directory: user
28+
run: cargo --version
29+
30+
- name: Install cargo-binutils
31+
run: cargo install cargo-binutils
32+
33+
- name: Setup Emscripten
34+
uses: mymindstorm/setup-emsdk@v14
35+
36+
- name: Download OpenSBI
37+
run: |
38+
wget https://github.com/riscv-software-src/opensbi/releases/download/v1.5.1/opensbi-1.5.1-rv-bin.tar.xz
39+
tar -xf opensbi-1.5.1-rv-bin.tar.xz
40+
41+
- name: Build OS
42+
working-directory: os
43+
run: |
44+
# Use the makefile to build the kernel and fs-img
45+
make build_env_check MODE=release
46+
47+
- name: Package with Emscripten
48+
run: |
49+
file_packager toy-os.data \
50+
--preload ./opensbi-1.5.1-rv-bin/share/opensbi/lp64/generic/firmware/fw_jump.bin@fw_jump.bin \
51+
--preload ./os/target/riscv64gc-unknown-none-elf/release/[email protected] \
52+
--preload ./user/target/riscv64gc-unknown-none-elf/release/[email protected] \
53+
--js-output=load-toy-os.js \
54+
--export-es6
55+
56+
- name: Create Tag Name
57+
run: echo "TAG_NAME=v0.1.${{ github.run_number }}" >> $GITHUB_ENV
58+
59+
- name: Create Release
60+
uses: softprops/action-gh-release@v1
61+
with:
62+
tag_name: ${{ env.TAG_NAME }}
63+
name: Release ${{ env.TAG_NAME }}
64+
files: |
65+
toy-os.data
66+
load-toy-os.js
67+
./os/target/riscv64gc-unknown-none-elf/release/toy-os.bin
68+
./user/target/riscv64gc-unknown-none-elf/release/fs-nvme.img
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
72+
# - name: Trigger External Pipeline
73+
# uses: peter-evans/repository-dispatch@v3
74+
# with:
75+
# # You must create a Personal Access Token (PAT) with repo scope and add it as a secret named PAT_TOKEN
76+
# token: ${{ secrets.PAT_TOKEN }}
77+
# # TODO: Replace with the actual repository you want to trigger (e.g., username/repo-name)
78+
# repository: username/other-repo
79+
# event-type: toy-os-release
80+
# client-payload: '{"version": "${{ env.TAG_NAME }}"}'

os/.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
/target
2-
/src/link_app.S
2+
/src/link_app.S
3+
*.bin
4+
*.js
5+
*.img
6+
*.data

os/Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ else ifeq ($(BOARD), nobios)
3737
ENTRY_POINT := start
3838
endif
3939

40-
build: env $(KERNEL_BIN) fs-img
40+
build_env_check: env build
41+
42+
build: $(KERNEL_BIN) fs-img
43+
@ln -sf ../os/$(KERNEL_BIN) ./toy-os.bin
44+
@ln -sf ../user/$(FS_IMG) ./fs.img
4145

4246
env:
43-
# (rustup target list | grep "riscv64gc-unknown-none-elf (installed)") || rustup target add $(TARGET)
44-
# cargo install cargo-binutils
47+
(rustup target list | grep "riscv64gc-unknown-none-elf (installed)") || rustup target add $(TARGET)
48+
cargo install cargo-binutils
4549

4650
$(KERNEL_BIN): kernel
4751
@$(OBJCOPY) $(KERNEL_ELF) --strip-all -O binary $@

0 commit comments

Comments
 (0)