@@ -2,45 +2,78 @@ name: Release Build and Publish
22
33permissions :
44 contents : write
5+ pull-requests : read
56
67on :
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
1723jobs :
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
0 commit comments