Skip to content

Commit 86fb5c6

Browse files
authored
Merge pull request #26 from RustLangES/cd-archs
Agregando más arquitecturas
2 parents e252de3 + 77be405 commit 86fb5c6

File tree

18 files changed

+659
-189
lines changed

18 files changed

+659
-189
lines changed

.github/workflows/release.yml

Lines changed: 76 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,78 @@ name: Release Build and Publish
22

33
permissions:
44
contents: write
5+
pull-requests: read
56

67
on:
78
push:
89
tags:
910
- "v*"
11+
pull_request:
1012
workflow_dispatch:
1113
inputs:
1214
release_name:
13-
description: "Name of release"
15+
description: "Name of release (optional)"
1416
required: false
1517
default: ""
18+
create_release:
19+
description: "Create a GitHub release? (true/false)"
20+
required: false
21+
default: "false"
1622

1723
jobs:
1824
build:
1925
runs-on: ubuntu-latest
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
include:
30+
- arch: "x86_64"
31+
rust_target: "x86_64-unknown-none"
32+
name: "x86_64"
33+
- arch: "aarch64"
34+
rust_target: "aarch64-unknown-none"
35+
name: "aarch64"
36+
- arch: "aarch64"
37+
rust_target: "aarch64-unknown-uefi"
38+
name: "aarch64-uefi"
39+
- arch: "riscv64"
40+
rust_target: "riscv64imac-unknown-none-elf"
41+
name: "riscv64-imac"
42+
- arch: "riscv64"
43+
rust_target: "riscv64gc-unknown-none-elf"
44+
name: "riscv64-gc"
45+
env:
46+
RUST_PROFILE: "release"
47+
ARCH: "${{ matrix.arch }}"
48+
RUST_TARGET: "${{ matrix.rust_target }}"
49+
IMAGE_NAME: "memsos_${{ matrix.name }}-${{ github.event.inputs.release_name || (github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.ref_name) }}"
2050

2151
steps:
2252
- uses: actions/checkout@v4
23-
- uses: dtolnay/rust-toolchain@stable
2453

25-
- name: Build release
26-
run: cargo build --release
27-
28-
- name: Install xorriso
29-
run: sudo apt-get install xorriso
54+
- name: Install Nix
55+
uses: cachix/install-nix-action@v30
56+
with:
57+
nix_path: nixpkgs=channel:nixos-unstable
58+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
59+
extra_nix_config: |
60+
experimental-features = nix-command flakes
3061
31-
- name: Convert BIOS image to ISO
62+
- name: Normalize IMAGE_NAME
3263
run: |
33-
mkdir -p isos
34-
cp target/bios.img isos/bios.img
35-
xorriso -as mkisofs -o isos/bios.iso isos/bios.img
64+
IMAGE_NAME=$(echo "${{ env.IMAGE_NAME }}" | tr -cd '[:alnum:]._-')
65+
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
3666
37-
- name: Convert UEFI image to ISO
67+
- name: Build with Nix
3868
run: |
39-
cp target/uefi.img isos/uefi.img
40-
xorriso -as mkisofs -o isos/uefi.iso isos/uefi.img
69+
echo "Building for ${{ matrix.arch }} with target ${{ matrix.rust_target }}..."
70+
nix build .#${{ matrix.name }}
4171
42-
- name: Get tag or manual release name
43-
id: tag_name
72+
mkdir -p isos
73+
cp result/memsos-${{ matrix.name }}.iso isos/${{ env.IMAGE_NAME }}.iso
74+
75+
- name: Get release name
76+
id: release_name
4477
run: |
4578
if [ -n "${{ github.event.inputs.release_name }}" ]; then
4679
echo "RELEASE_NAME=${{ github.event.inputs.release_name }}" >> $GITHUB_ENV
@@ -52,19 +85,39 @@ jobs:
5285
id: commit_history
5386
run: |
5487
if [ -n "${{ github.event.inputs.release_name }}" ]; then
55-
# Si es un lanzamiento manual, muestra los últimos 10 commits
5688
echo "COMMIT_HISTORY=$(git log --pretty=format:'- %s (by @%an)' -n 10)" >> $GITHUB_ENV
5789
else
58-
# Si es un lanzamiento automático, muestra los commits desde el último tag
5990
echo "COMMIT_HISTORY=$(git log --pretty=format:'- %s (by @%an)' $(git describe --tags --abbrev=0)..HEAD)" >> $GITHUB_ENV
6091
fi
6192
93+
- name: Upload ISO as artifact
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: iso-${{ matrix.name }}
97+
path: isos/${{ env.IMAGE_NAME }}.iso
98+
99+
create-release:
100+
runs-on: ubuntu-latest
101+
needs: build
102+
if: ${{ (github.event.inputs.create_release == 'true' || github.event_name == 'push') && github.event_name != 'pull_request' }}
103+
steps:
104+
- name: Download ISOs
105+
uses: actions/download-artifact@v4
106+
with:
107+
path: isos
108+
109+
- name: Combine ISOs into a single folder
110+
run: |
111+
mkdir -p combined_isos
112+
for iso in isos/iso-*/*.iso; do
113+
cp "$iso" combined_isos/
114+
done
115+
62116
- name: Create Release
63117
uses: softprops/action-gh-release@v2
64118
with:
65-
tag_name: ${{ env.RELEASE_NAME }}
66-
name: ${{ env.RELEASE_NAME }}
67-
body: ${{ env.COMMIT_HISTORY }}
119+
tag_name: ${{ needs.build.outputs.RELEASE_NAME }}
120+
name: ${{ needs.build.outputs.RELEASE_NAME }}
121+
body: ${{ needs.build.outputs.COMMIT_HISTORY }}
68122
files: |
69-
isos/bios.iso
70-
isos/uefi.iso
123+
combined_isos/*.iso

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ memfile
55
limine
66
iso_root
77
ovmf
8-
memsos-x86_64.iso
8+
memsos*.iso

Cargo.lock

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ edition = "2021"
77
ovmf-prebuilt = "0.1.0-alpha.1"
88

99
[workspace]
10-
members = [ "crates/core", "crates/os", "kernel"]
10+
members = ["crates/core", "crates/os", "kernel"]

Justfile

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
QEMU_FLAGS := env_var_or_default("QEMU_FLAGS", "")
2-
IMAGE_NAME := "memsos-x86_64"
1+
# Arch: x86_64, aarch64, riscv64
2+
ARCH := env("ARCH", "x86_64")
3+
RUST_TARGET := env("RUST_TARGET", "x86_64-unknown-none")
4+
IMAGE_NAME := env("IMAGE_NAME", "memsos_" + ARCH)
5+
QEMU_FLAGS := env("QEMU_FLAGS", "")
36
OVMF_DIR := "ovmf"
47
LIMINE_DIR := "limine"
5-
ARCH := "x86_64"
68

7-
# Run vm
9+
# UEFI prefix from ARCH
10+
UEFI_SUFFIX := `\
11+
if [ "{{ARCH}}" = "x86_64" ]; then \
12+
echo "X64"; \
13+
elif [ "{{ARCH}}" = "aarch64" ]; then \
14+
echo "AA64"; \
15+
elif [ "{{ARCH}}" = "riscv64" ]; then \
16+
echo "RISCV64"; \
17+
else \
18+
echo "IA32"; \
19+
fi`
820

21+
# Run vm
922
run-uefi: build ovmf
1023
qemu-system-{{ARCH}} \
1124
-M q35 \
@@ -29,7 +42,6 @@ run-bios: build
2942

3043

3144
# OVMF build
32-
3345
ovmf:
3446
test -d {{OVMF_DIR}} || (mkdir -p {{OVMF_DIR}} && curl -Lo {{OVMF_DIR}}/ovmf-code-{{ARCH}}.fd https://github.com/osdev0/edk2-ovmf-nightly/releases/latest/download/ovmf-code-{{ARCH}}.fd && curl -Lo {{OVMF_DIR}}/ovmf-vars-{{ARCH}}.fd https://github.com/osdev0/edk2-ovmf-nightly/releases/latest/download/ovmf-vars-{{ARCH}}.fd)
3547

@@ -40,31 +52,28 @@ limine:
4052
make -C {{LIMINE_DIR}}
4153

4254
# Kernel build
43-
4455
kernel:
4556
just kernel/
4657

4758

4859
# Image build
49-
5060
build: limine kernel
5161
rm -rf iso_root
5262
mkdir -p iso_root/boot
5363
cp -v kernel/kernel iso_root/boot/
5464
mkdir -p iso_root/boot/limine
5565
cp -v limine.conf iso_root/boot/limine/
56-
mkdir -p iso_root/EFI/BOOT
66+
mkdir -p iso_root/EFI/BOOT
5767

5868
cp -v limine/limine-bios.sys limine/limine-bios-cd.bin limine/limine-uefi-cd.bin iso_root/boot/limine/
59-
cp -v limine/BOOTX64.EFI iso_root/EFI/BOOT/
60-
cp -v limine/BOOTIA32.EFI iso_root/EFI/BOOT/
69+
cp -v limine/BOOT{{UEFI_SUFFIX}}.EFI iso_root/EFI/BOOT/
6170
xorriso -as mkisofs -b boot/limine/limine-bios-cd.bin \
6271
-no-emul-boot -boot-load-size 4 -boot-info-table \
6372
--efi-boot boot/limine/limine-uefi-cd.bin \
6473
-efi-boot-part --efi-boot-image --protective-msdos-label \
6574
iso_root -o {{IMAGE_NAME}}.iso
66-
67-
./limine/limine bios-install {{IMAGE_NAME}}.iso
75+
76+
./limine/limine bios-install {{IMAGE_NAME}}.iso
6877
rm -rf iso_root
6978

7079
clean:

0 commit comments

Comments
 (0)