Skip to content

Commit 203f1ae

Browse files
Merge pull request #9 from RusPiRo/master
Prepare Release and crates.io publishing
2 parents 6314b4a + 0565f8e commit 203f1ae

File tree

10 files changed

+441
-183
lines changed

10 files changed

+441
-183
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
**/*.rs.bk
33
**/release
44
.vscode
5-
*.lock
5+
*.lock
6+
*.log
7+
*.ld

.travis.yml

Lines changed: 96 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,122 @@
33
branches:
44
only:
55
- master
6+
- release
67

78
language: rust
89

910
rust:
1011
# build nightly only for the time beeing
1112
- nightly
1213

13-
matrix:
14-
fast_finish: true
14+
# increase build speed by caching installed cargo dependencies
15+
cache: cargo
16+
17+
# define the stages and their order
18+
stages:
19+
- compile
20+
- test
21+
- publish_dry
22+
- name: prepare_release
23+
if: branch = master AND type != pull_request
24+
- name: deploy
25+
if: branch = release AND type != pull_request
26+
- name: publish
27+
if: branch = release AND type != pull_request
28+
29+
jobs:
1530
include:
16-
- name: "build 64Bit"
31+
- stage: compile
32+
name: "Compile The Crate"
1733
install:
18-
- sudo apt-get install gcc-aarch64-linux-gnu
34+
- sudo apt-get install -y gcc-aarch64-linux-gnu
1935
- cargo install cargo-xbuild
2036
- cargo install cargo-make
21-
- rustup target add aarch64-unknown-linux-gnu
37+
- rustup target add aarch64-unknown-none
2238
- rustup component add rust-src
2339
- rustup component add llvm-tools-preview
2440
# if we not build a PR we remove the patch of the dependencies to their github repo's
25-
- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sed -i "/^\[patch\.crates-io\]$/ {N; s/^.*//g}" Cargo.toml; fi'
26-
script: cargo make --profile a64-travis pi3
41+
- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sed -i "/\[patch\.crates-io\]/,$ s/^ruspiro-.*\(git\|path\).*//g" Cargo.toml; fi'
42+
script: cargo make --profile travis pi3
2743

28-
- name: "build 32Bit"
44+
- stage: test
45+
name: "Run Doc Tests"
2946
install:
30-
- sudo apt-get install gcc-arm-linux-gnueabihf
31-
- cargo install cargo-xbuild
3247
- cargo install cargo-make
33-
- rustup target add armv7-unknown-linux-gnueabihf
34-
- rustup component add rust-src
35-
- rustup component add llvm-tools-preview
3648
# if we not build a PR we remove the patch of the dependencies to their github repo's
37-
- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sed -i "/^\[patch\.crates-io\]$/ {N; s/^.*//g}" Cargo.toml; fi'
38-
script: cargo make --profile a32 pi3
39-
40-
- name: "unit tests"
49+
- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sed -i "/{^\[patch\.crates-io\] /{:a;N;/\Z}/!ba};/^ruspiro-.*\(git\|path\).*/d" Cargo.toml; fi'
50+
script: cargo make doctest --profile dummy
51+
- stage: test
52+
name: "Run Unit Tests"
4153
install:
54+
- cargo install cargo-make
4255
# if we not build a PR we remove the patch of the dependencies to their github repo's
43-
- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sed -i "/^\[patch\.crates-io\]$/ {N; s/^.*//g}" Cargo.toml; fi'
44-
script: cargo test --tests
56+
- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sed -i "/{^\[patch\.crates-io\] /{:a;N;/\Z}/!ba};/^ruspiro-.*\(git\|path\).*/d" Cargo.toml; fi'
57+
script: cargo make unittest --profile dummy
4558

46-
- name: "doc tests"
59+
- stage: publish_dry
60+
name: "Run Cargo Publish Dry-Run"
4761
install:
48-
# if we not build a PR we remove the patch of the dependencies to their github repo's
49-
- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sed -i "/^\[patch\.crates-io\]$/ {N; s/^.*//g}" Cargo.toml; fi'
50-
- cat Cargo.toml
51-
script: cargo test --doc
62+
- sudo apt-get install -y gcc-aarch64-linux-gnu
63+
- cargo install cargo-xbuild
64+
- cargo install cargo-make
65+
- rustup target add aarch64-unknown-none
66+
- rustup component add rust-src
67+
- rustup component add llvm-tools-preview
68+
script: cargo make publish_dry --profile travis
69+
70+
- stage: prepare_release
71+
name: "Create PR against the release branch"
72+
script:
73+
- 'curl -H ''Authorization: Token ''"$GIT_API_TOKEN"'''' -X POST -H ''Content-type: application/json'' --data ''{"title":"Prepare Release and crates.io publishing", "head":"master", "base":"release", "draft":false, "body":"Automatic PR to the release branch as preperation to publish the library"}'' https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls > /dev/null'
5274

53-
75+
- stage: deploy
76+
name: "Create GitHub release"
77+
script: echo "creating github release"
78+
before_deploy:
79+
# extract current crate version from argo.toml
80+
- export CRATE_VERSION=v`sed -En 's/^version.*=.*\"(.*)\".*$/\1/p' < Cargo.toml`
81+
# retrieve last release version from github
82+
- export LAST_VERSION="$(curl --silent "https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')"
83+
# use default version if none yet published (required for proper release note extraction)
84+
- export LAST_VERSION=${LAST_VERSION:-v0.0.0}
85+
- echo $CRATE_VERSION
86+
- echo $LAST_VERSION
87+
- git config --local user.name "2ndTaleStudio"
88+
- git config --local user.email "[email protected]"
89+
# create the TAG required for the release
90+
- git tag $CRATE_VERSION -m "$CRATE_VERSION"
91+
# extract the release notes of the current release from the changelog
92+
- sed -En '/##.*:.*:.*'"$LAST_VERSION"'/q;p' CHANGELOG.md > RELEASENOTES.md
93+
- sed -i -e 's/^# Changelog/# Release Notes/g' RELEASENOTES.md
94+
deploy:
95+
provider: releases
96+
# use dpl v2 version for deployments to support the release_notes_file option
97+
edge: true
98+
api_key: "$GIT_API_TOKEN"
99+
name: "$CRATE_VERSION"
100+
release_notes_file: "RELEASENOTES.md"
101+
file: "RELEASENOTES.md"
102+
skip_cleanup: true
103+
on:
104+
branch: release
105+
106+
- stage: publish
107+
name: "Run Cargo Publish"
108+
install:
109+
- sudo apt-get install -y gcc-aarch64-linux-gnu
110+
- cargo install cargo-xbuild
111+
- cargo install cargo-make
112+
- rustup target add aarch64-unknown-none
113+
- rustup component add rust-src
114+
- rustup component add llvm-tools-preview
115+
# extract current crate version from argo.toml
116+
- export CRATE_VERSION=`sed -En 's/^version.*=.*\"(.*)\".*$/\1/p' < Cargo.toml`
117+
# before actually publishing replace the final version for doc and repository in the Crago.toml
118+
- sed -i -e 's/||VERSION||/'$CRATE_VERSION'/g' Cargo.toml
119+
# also update the version in the lib.rs doc root url
120+
- sed -i -e 's/||VERSION||/'$CRATE_VERSION'/g' src/lib.rs
121+
# and the README.md
122+
- sed -i -e 's/||VERSION||/'$CRATE_VERSION'/g' README.md
123+
# publish with token and dirty flag as we just updated some files and won't commit them back to the branch
124+
script: cargo make publish --profile travis --env CRATES_TOKEN="$CRATES_TOKEN" > /dev/null

CHANGELOG.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
2-
## :banana: v0.4.3
3-
- ### :detective: Fixes
4-
- remove `asm!` macro usages and replace with `llvm_asm!`
5-
- use `cargo make` to stabilize cross-platform builds
2+
3+
## :peach: v0.4.0
4+
5+
- ### :bulb: Features
6+
7+
- Introduce the ability to lazylie initialize the value stored inside the `Singleton` using a closure. The initialization is evaluated on first access to the `Singleton` contents.
8+
9+
- ### :wrench: Maintenance
10+
11+
- Enable proper and stable pipeline to support release and publishing process
12+
13+
## :banana: v0.3.1
14+
15+
- ### :detective: Fixes
16+
17+
- remove `asm!` macro usages and replace with `llvm_asm!`
18+
- use `cargo make` to stabilize cross-platform builds

Cargo.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
22
name = "ruspiro-singleton"
33
authors = ["André Borrmann <[email protected]>"]
4-
version = "0.3.1" # remember to update html_root_url
4+
version = "0.4.0" # remember to update html_root_url
55
description = "Simple and easy to use singleton pattern"
66
license = "Apache-2.0"
7-
repository = "https://github.com/RusPiRo/ruspiro-singleton/tree/v0.3.1"
8-
documentation = "https://docs.rs/ruspiro-singleton/0.3.1"
7+
repository = "https://github.com/RusPiRo/ruspiro-singleton/tree/v||VERSION||"
8+
documentation = "https://docs.rs/ruspiro-singleton/||VERSION||"
99
readme = "README.md"
1010
keywords = ["RusPiRo", "singleton", "raspberrypi"]
1111
categories = ["no-std", "embedded"]
@@ -18,10 +18,13 @@ maintenance = { status = "actively-developed" }
1818

1919
[lib]
2020

21+
[dev-dependencies]
22+
2123
[dependencies]
22-
ruspiro-lock = "0.3"
24+
ruspiro-lock = "0.4.0"
2325

2426
[features]
27+
ruspiro_pi3 = [ ]
2528

2629
[patch.crates-io]
27-
ruspiro-lock = { git = "https://github.com/RusPiRo/ruspiro-lock.git" }
30+
ruspiro-lock = { git = "https://github.com/RusPiRo/ruspiro-lock.git" }
File renamed without changes.

LICENSE-MIT

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 André Borrmann <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile.toml

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,74 @@
11
#***********************************************************************************************************************
22
# cargo make tasks to build the example for the Raspberry Pi
33
#***********************************************************************************************************************
4-
[env.a64]
4+
5+
# AARCH64 specific profile environment varialbles
6+
[env.development]
57
CC = "aarch64-none-elf-gcc"
68
AR = "aarch64-none-elf-ar"
7-
OC = "aarch64-none-elf-objcopy"
89
CFLAGS = "-march=armv8-a -Wall -O3 -nostdlib -nostartfiles -ffreestanding -mtune=cortex-a53"
910
RUSTFLAGS = "-C linker=${CC} -C target-cpu=cortex-a53 -C link-arg=-nostartfiles -C link-arg=-T./link64.ld"
10-
BUILD_TARGET = "aarch64-unknown-linux-gnu"
11-
12-
[env.a32]
13-
CC = "arm-none-eabi-gcc"
14-
AR = "arm-none-eabi-ar"
15-
OC = "arm-none-eabi-objcopy"
16-
CFLAGS = "-mcpu=cortex-a53 -march=armv7-a -mfpu=neon -mfloat-abi=softfp -Wall -O3 -nostdlib -nostartfiles"
17-
RUSTFLAGS = "-C linker=${CC} -C target-cpu=cortex-a53 -C link-arg=-nostartfiles"
18-
BUILD_TARGET = "armv7a-none-eabi"
19-
20-
# Travis CI need a different CC/AR alltogether as the aarch64-none-elf is not available there as it seems
21-
[env.a64-travis]
11+
BUILD_TARGET = "aarch64-unknown-none"
12+
13+
# AARCH64 specific Travis CI env. variables. "aarch64-none-elf" is not available there as it seems
14+
[env.travis]
2215
CC = "aarch64-linux-gnu-gcc"
2316
AR = "aarch64-linux-gnu-ar"
24-
OC = "aarch64-linux-gnu-objcopy"
2517
CFLAGS = "-march=armv8-a -Wall -O3 -nostdlib -nostartfiles -ffreestanding -mtune=cortex-a53"
26-
RUSTFLAGS = "-C linker=${CC} -C target-cpu=cortex-a53 -C link-arg=-nostartfiles"
27-
BUILD_TARGET = "aarch64-unknown-linux-gnu"
18+
RUSTFLAGS = "-C linker=${CC} -C target-cpu=cortex-a53 -C link-arg=-nostartfiles -C link-arg=-T./link64.ld"
19+
BUILD_TARGET = "aarch64-unknown-none"
2820

2921
[tasks.xbuild]
3022
command = "cargo"
31-
args = ["xbuild", "--target", "${BUILD_TARGET}", "--release", "--features", "${FEATURES}"]
23+
args = ["build", "--target", "${BUILD_TARGET}", "--release", "--features", "${FEATURES}"]
3224

3325
[tasks.pi3]
34-
env = { FEATURES = "" }
35-
run_task = [
36-
{ name = "xbuild" }
37-
]
26+
env = { FEATURES = "ruspiro_pi3" }
27+
run_task = "xbuild"
28+
29+
[tasks.clippy]
30+
env = { FEATURES = "ruspiro_pi3" }
31+
command = "cargo"
32+
args = ["clippy", "--target", "${BUILD_TARGET}", "--features", "${FEATURES}"]
33+
34+
[tasks.doc]
35+
env = { FEATURES = "ruspiro_pi3" }
36+
command = "cargo"
37+
args = ["doc", "--target", "${BUILD_TARGET}", "--features", "${FEATURES}", "--open"]
38+
39+
[tasks.unittest]
40+
env = { FEATURES = "ruspiro_pi3" }
41+
command = "cargo"
42+
args = ["test", "--tests", "--features", "${FEATURES}"]
43+
44+
45+
[tasks.doctest]
46+
env = { FEATURES = "ruspiro_pi3" }
47+
command = "cargo"
48+
args = ["test", "--doc", "--features", "${FEATURES}"]
49+
50+
[tasks.publish_dry]
51+
env = { FEATURES = "ruspiro_pi3" }
52+
command = "cargo"
53+
args = ["publish", "--dry-run", "--target", "${BUILD_TARGET}", "--features", "${FEATURES}"]
54+
55+
[tasks.publish]
56+
env = { FEATURES = "ruspiro_pi3" }
57+
command = "cargo"
58+
args = ["publish", "--token", "${CRATES_TOKEN}", "--allow-dirty", "--target", "${BUILD_TARGET}", "--features", "${FEATURES}"]
3859

3960
[tasks.clean]
4061
command = "cargo"
41-
args = ["clean"]
62+
args = ["clean"]
63+
64+
[tasks.qemu-test-objcopy]
65+
command = "aarch64-none-elf-objcopy"
66+
args = ["-O", "binary", "${CARGO_MAKE_TASK_ARGS}", "./target/kernel-test.img"]
67+
68+
[tasks.qemu-test]
69+
script = [
70+
"qemu-system-aarch64 -semihosting -display none -M raspi3 -kernel ./target/kernel-test.img -serial null -serial stdio -d int,mmu -D qemu-test.log"
71+
]
72+
dependencies = [
73+
"qemu-test-objcopy"
74+
]

0 commit comments

Comments
 (0)