Skip to content

Commit d07821e

Browse files
authored
Merge pull request #22 from WyliodrinEmbeddedIoT/microbit_v2_release
Microbit v2 serial bootloader release workflow
2 parents 0d3504d + 962e14f commit d07821e

File tree

3 files changed

+84
-14
lines changed

3 files changed

+84
-14
lines changed

.github/workflows/release.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Micro:bit v2 Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version'
8+
required: true
9+
10+
jobs:
11+
release:
12+
runs-on: "ubuntu-latest"
13+
14+
# Steps represent a sequence of tasks that will be executed as part of the job
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: actions-rs/toolchain@v1 # pulls version from rust-toolchain file
18+
- name: build bootloader
19+
run: |
20+
cd boards/microbit_v2-bootloader
21+
export BOOTLOADER_VERSION="${{ github.event.inputs.version }}"
22+
export BOOTLOADER_HASH="$(git rev-parse HEAD)"
23+
export BOOTLOADER_KERNEL_HASH="$(cat Cargo.lock | grep https://github.com/tock/tock?branch=remove-submodule | uniq | cut -d '#' -f 2 | cut -d '"' -f 1)"
24+
make
25+
- name: Version
26+
run: |
27+
echo "Version: ${{ github.event.inputs.version }}" > tock-bootloader.microbit_v2.version
28+
echo "Toolchain: $(rustc --version)" >> tock-bootloader.microbit_v2.version
29+
echo "Tock Bootloader Hash: $(git rev-parse HEAD)" >> tock-bootloader.microbit_v2.version
30+
echo Tock Hash: $(cat boards/microbit_v2-bootloader/Cargo.lock | grep https://github.com/tock/tock?branch=remove-submodule | uniq | cut -d '#' -f 2 | cut -d '"' -f 1) >> tock-bootloader.microbit_v2.version
31+
echo "Bootloader SHA256: $(sha256sum target/thumbv7em-none-eabi/release/microbit_v2-bootloader.bin | cut -d ' ' -f 1)" >> tock-bootloader.microbit_v2.version
32+
echo "Build Date: $(date)" >> tock-bootloader.microbit_v2.version
33+
- name: Upload bootloader release
34+
uses: svenstaro/upload-release-action@v2
35+
with:
36+
release_name: Micro:bit v2 ${{ github.event.inputs.version }}
37+
prerelease: true
38+
repo_token: ${{ secrets.GITHUB_TOKEN }}
39+
file: target/thumbv7em-none-eabi/release/microbit_v2-bootloader.bin
40+
asset_name: tock-bootloader.microbit_v2.v${{ github.event.inputs.version }}.bin
41+
tag: microbit_v2-v${{ github.event.inputs.version }}
42+
overwrite: true
43+
body: "Bootloader for Micro:bit v2 v${{ github.event.inputs.version }}"
44+
- name: Upload bootloader version
45+
uses: svenstaro/upload-release-action@v2
46+
with:
47+
release_name: Micro:bit v2 ${{ github.event.inputs.version }}
48+
prerelease: true
49+
repo_token: ${{ secrets.GITHUB_TOKEN }}
50+
file: tock-bootloader.microbit_v2.version
51+
asset_name: tock-bootloader.microbit_v2.v${{ github.event.inputs.version }}.version
52+
tag: microbit_v2-v${{ github.event.inputs.version }}

boards/microbit_v2-bootloader/Cargo.lock

Lines changed: 19 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
extern crate bootloader_attributes;
2+
use std::env;
23

34
fn main() {
45
println!("cargo:rerun-if-changed=layout.ld");
56
println!("cargo:rerun-if-changed=../kernel_layout.ld");
67

78
let mut f = bootloader_attributes::get_file();
8-
bootloader_attributes::write_flags(&mut f, "1.1.1", 0x8000);
9+
let version = if let Ok(v) = env::var("BOOTLOADER_VERSION") {
10+
v
11+
} else {
12+
String::from("1.1.1")
13+
};
14+
bootloader_attributes::write_flags(&mut f, &version, 0x8000);
915
bootloader_attributes::write_attribute(&mut f, "board", "microbit_v2");
1016
bootloader_attributes::write_attribute(&mut f, "arch", "cortex-m4");
1117
bootloader_attributes::write_attribute(&mut f, "appaddr", "0x40000");
18+
if let Ok(bootloader) = env::var("BOOTLOADER_HASH") {
19+
bootloader_attributes::write_attribute(&mut f, "boothash", &bootloader);
20+
}
21+
if let Ok(bootloader_kernel) = env::var("BOOTLOADER_KERNEL_HASH") {
22+
bootloader_attributes::write_attribute(&mut f, "kernhash", &bootloader_kernel);
23+
}
1224
}

0 commit comments

Comments
 (0)