Skip to content

Commit 53ccad0

Browse files
Fix reporting of the version number.
You need fetch-depth: 0 to get the history. Then you need the right arguments to `git describe` to avoid it returning some older tag.
1 parent 985b5d1 commit 53ccad0

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

.github/workflows/build_and_release.yml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
on: [push, pull_request]
22
name: Build (and Release)
33

4+
env:
5+
CARGO_TERM_COLOR: always
6+
47
jobs:
58
build:
69
name: Build (and Release)
710
runs-on: ubuntu-latest
811
steps:
912
- name: Checkout
10-
uses: actions/checkout@v1
13+
uses: actions/checkout@v3
1114
with:
1215
submodules: true
16+
fetch-depth: 0
1317

1418
- name: Add targets
1519
run: |
@@ -28,24 +32,6 @@ jobs:
2832
- name: Build neotron-bmc-nucleo
2933
run: cd neotron-bmc-nucleo && DEFMT_LOG=info cargo build --release --verbose --target=thumbv7em-none-eabihf
3034

31-
- name: Get Branch Name
32-
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
33-
id: branch_name
34-
run: |
35-
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
36-
37-
- name: Create Release
38-
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
39-
id: create_release
40-
uses: actions/create-release@v1
41-
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43-
with:
44-
tag_name: ${{ github.ref }}
45-
release_name: Release ${{ steps.branch_name.outputs.SOURCE_TAG }}
46-
draft: false
47-
prerelease: false
48-
4935
- name: Upload files to Release
5036
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
5137
uses: softprops/action-gh-release@v1

neotron-bmc-pico/build.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ fn main() {
1919
// Generate a file containing the firmware version
2020
let version_output = std::process::Command::new("git")
2121
.current_dir(env::var_os("CARGO_MANIFEST_DIR").unwrap())
22-
.args(["describe", "--long", "--dirty"])
22+
.args(["describe", "--tags", "--dirty"])
2323
.output()
2424
.expect("running git-describe");
25+
26+
println!(
27+
"Version is {:?}",
28+
std::str::from_utf8(&version_output.stdout)
29+
);
30+
println!("Error is {:?}", std::str::from_utf8(&version_output.stderr));
2531
assert!(version_output.status.success());
2632

2733
// Remove the trailing newline
@@ -32,6 +38,7 @@ fn main() {
3238
panic!("Version too long!");
3339
}
3440

41+
// Pad it
3542
while output.len() < 32 {
3643
output.push(0);
3744
}

0 commit comments

Comments
 (0)