Skip to content

Commit

Permalink
Get crate version with cargo-metadata instead of python+tomlkit
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeaurivage authored and ianrrees committed Sep 9, 2024
1 parent e90e500 commit 9922c40
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 35 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/bump-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
steps:
- name: Set up Rust
run: |
sudo apt-get install python3-pip && pip install tomlkit
rustup set profile minimal
rustup override set stable
- uses: actions/checkout@v4
Expand All @@ -48,7 +47,8 @@ jobs:
cargo set-version --manifest-path $manifest --bump ${{ github.event.inputs.pac_bump }}
# Update the changelog
python3 .github/workflows/update_changelog.py $dir
version=$(cargo metadata --manifest-path $manifest --no-deps --format-version 1 | jq -r '.packages[0].version')
python3 .github/workflows/update_changelog.py $dir $version
done
- name: Update HAL deps
Expand All @@ -64,7 +64,8 @@ jobs:
cargo set-version --manifest-path "hal/Cargo.toml" --exclude atsamd-hal-macros --bump ${{ github.event.inputs.hal_bump }}
# Update the changelog
python3 .github/workflows/update_changelog.py hal/
version=$(cargo metadata --manifest-path "hal/Cargo.toml" --no-deps --format-version 1 | jq -r '.packages[0].version')
python3 .github/workflows/update_changelog.py hal/ $version
- name: Update BSP deps
uses: ./.github/actions/sync-bsp-versions
Expand All @@ -82,7 +83,8 @@ jobs:
cargo set-version --manifest-path $manifest --bump ${{ github.event.inputs.bsp_bump }}
# Update the changelog
python3 .github/workflows/update_changelog.py "boards/$dir/"
version=$(cargo metadata --manifest-path $manifest --no-deps --format-version 1 | jq -r '.packages[0].version')
python3 .github/workflows/update_changelog.py "boards/$dir/" $version
done
- name: Generate patch
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/bump-t2-bsp.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Bump crate versions
name: Bump version of a single Tier 2 crate
on:
workflow_dispatch:
inputs:
Expand All @@ -16,7 +16,6 @@ jobs:
steps:
- name: Set up Rust
run: |
sudo apt-get install python3-pip && pip install tomlkit
rustup set profile minimal
rustup override set stable
- uses: actions/checkout@v4
Expand Down Expand Up @@ -47,7 +46,8 @@ jobs:
cargo set-version --manifest-path $manifest --bump ${{ github.event.inputs.bsp_bump }}
# Update the changelog
python3 .github/workflows/update_changelog.py "boards/$bsp/"
version=$(cargo metadata --manifest-path $manifest --no-deps --format-version 1 | jq -r '.packages[0].version')
python3 .github/workflows/update_changelog.py "boards/$bsp/" $version
else
echo "BSP $bsp is not Tier 2."
exit 2
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/crate_version.py

This file was deleted.

4 changes: 1 addition & 3 deletions .github/workflows/release-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,12 @@ jobs:
run: |
set -ex
sudo apt-get install python3-pip && pip install tomlkit
# Force update of the registry
cargo update || true
cd "hal" && cargo publish --no-verify
version=$(python3 ../.github/workflows/crate_version.py Cargo.toml)
version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
git tag -a "v${version}" -m "atsamd-hal release v${version}"
git push origin tag "v${version}"
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/update_changelog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from crate_version import get_crate_version
import argparse
import re
import sys
Expand Down Expand Up @@ -27,13 +26,13 @@ def update_changelog(changelog_path, version):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Update crate changelog by parsing version from Cargo manifest")
parser.add_argument('crate_path', help="Path to the crate")
parser.add_argument('crate_version', help="Version of the crate")

args = parser.parse_args()

# Get the crate version from Cargo.toml
manifest_path = f'{args.crate_path}/Cargo.toml'
crate_version = get_crate_version(manifest_path)

# Update the changelog
crate_changelog_path = f'{args.crate_path}/CHANGELOG.md'
update_changelog(crate_changelog_path, crate_version)
update_changelog(crate_changelog_path, args.crate_version)

0 comments on commit 9922c40

Please sign in to comment.