Skip to content

Commit 039a6de

Browse files
committed
Build for all targets, and make releases when tagged.
1 parent 051bb8a commit 039a6de

File tree

3 files changed

+82
-10
lines changed

3 files changed

+82
-10
lines changed

.github/workflows/rust.yml

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,65 @@ on: [push, pull_request]
44

55
jobs:
66
build:
7-
7+
name: Build (and Release)
88
runs-on: ubuntu-latest
9-
109
steps:
11-
- name: Checkout
12-
uses: actions/checkout@v1
13-
with:
14-
submodules: true
15-
- name: Add Target
16-
run: rustup target add thumbv7em-none-eabi
17-
- name: Build
18-
run: cargo build --verbose --target=thumbv7em-none-eabi
10+
- name: Checkout
11+
uses: actions/checkout@v1
12+
with:
13+
submodules: true
14+
- name: Check Syntax
15+
run: |
16+
cargo check
17+
- name: Install Targets and Tools
18+
run: |
19+
rustup target add thumbv7em-none-eabi
20+
rustup target add thumbv7m-none-eabi
21+
rustup target add thumbv6m-none-eabi
22+
rustup component add llvm-tools-preview
23+
cargo install cargo-binutils
24+
- name: Build
25+
run: ./build.sh
26+
- name: Get Branch Name
27+
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
28+
id: branch_name
29+
run: |
30+
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
31+
- name: Create Release
32+
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
33+
id: create_release
34+
uses: actions/create-release@v1
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
with:
38+
tag_name: ${{ github.ref }}
39+
release_name: Release ${{ steps.branch_name.outputs.SOURCE_TAG }}
40+
draft: false
41+
prerelease: false
42+
43+
- name: Upload files to Release
44+
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
45+
uses: softprops/action-gh-release@v1
46+
with:
47+
files: |
48+
./release/thumbv6m-none-eabi-flash0002-libneotron_os.bin
49+
./release/thumbv6m-none-eabi-flash0002-libneotron_os.elf
50+
./release/thumbv6m-none-eabi-flash0802-libneotron_os.bin
51+
./release/thumbv6m-none-eabi-flash0802-libneotron_os.elf
52+
./release/thumbv6m-none-eabi-flash1002-libneotron_os.bin
53+
./release/thumbv6m-none-eabi-flash1002-libneotron_os.elf
54+
./release/thumbv7em-none-eabi-flash0002-libneotron_os.bin
55+
./release/thumbv7em-none-eabi-flash0002-libneotron_os.elf
56+
./release/thumbv7em-none-eabi-flash0802-libneotron_os.bin
57+
./release/thumbv7em-none-eabi-flash0802-libneotron_os.elf
58+
./release/thumbv7em-none-eabi-flash1002-libneotron_os.bin
59+
./release/thumbv7em-none-eabi-flash1002-libneotron_os.elf
60+
./release/thumbv7m-none-eabi-flash0002-libneotron_os.bin
61+
./release/thumbv7m-none-eabi-flash0002-libneotron_os.elf
62+
./release/thumbv7m-none-eabi-flash0802-libneotron_os.bin
63+
./release/thumbv7m-none-eabi-flash0802-libneotron_os.elf
64+
./release/thumbv7m-none-eabi-flash1002-libneotron_os.bin
65+
./release/thumbv7m-none-eabi-flash1002-libneotron_os.elf
66+
./release/x86_64-unknown-linux-gnu-libneotron_os.so
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/target
22
**/*.rs.bk
33
Cargo.lock
4+
/release

build.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
RELEASE_DIR=./release
6+
7+
mkdir -p ${RELEASE_DIR}
8+
9+
# Build the embedded binaries for each core type and each flash layout
10+
for TARGET_ARCH in thumbv6m-none-eabi thumbv7m-none-eabi thumbv7em-none-eabi; do
11+
for BINARY in flash0002 flash0802 flash1002; do
12+
# objcopy will do the build for us first
13+
cargo objcopy --verbose --release --target=${TARGET_ARCH} --bin ${BINARY} -- -O binary ${RELEASE_DIR}/${TARGET_ARCH}-${BINARY}-libneotron_os.bin
14+
# Keep the ELF file too (for debugging)
15+
cp ./target/${TARGET_ARCH}/release/${BINARY} ${RELEASE_DIR}/${TARGET_ARCH}-${BINARY}-libneotron_os.elf
16+
done
17+
done
18+
19+
# Build the host version
20+
cargo build --verbose --lib --release --target=x86_64-unknown-linux-gnu
21+
cp ./target/x86_64-unknown-linux-gnu/release/libneotron_os.so ${RELEASE_DIR}/x86_64-unknown-linux-gnu-libneotron_os.so

0 commit comments

Comments
 (0)