Skip to content

Commit 3f2a51c

Browse files
committed
automate version sync
1 parent 9accd02 commit 3f2a51c

7 files changed

+81
-28
lines changed

.github/workflows/build_hyperdrivetypes.yml

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
name: build and upload hyperdrivetypes wheel
22

3-
# TODO: We will want to sync the python version with the hyperdrive version & push on hyperdrive tags
4-
#on:
5-
# push:
6-
# tags:
7-
# - "v*"
8-
9-
# TODO: Temp for testing
103
on:
114
push:
5+
# tags:
6+
# - "v*"
127

138
jobs:
14-
# TODO: Temp for testing; will sync version
15-
detect-changes:
16-
uses: ./.github/workflows/check_diff.yaml
17-
with:
18-
pattern: ^python/\hyperdrivetypes/\pyproject.toml
199

2010
build-wheel:
2111
name: build hyperdrivetypes wheel
@@ -46,7 +36,7 @@ jobs:
4636

4737
- name: build hyperdrivetypes package
4838
shell: bash
49-
run: source scripts/build-hyperdrivetypes-wheel.sh
39+
run: scripts/build-hyperdrivetypes-wheel.sh
5040

5141
- name: upload wheel
5242
uses: actions/upload-artifact@v4

CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ If you find a bug, we recommend that you post an [issue](https://github.com/delv
66

77
## Release steps
88

9-
1. [ ] Double-check that the version in `contracts/src/libraries/Constants.sol` matches the version to be tagged. If it doesn't, open a PR to update the version before tagging.
9+
1. [ ] Double-check that the version in `contracts/src/libraries/Constants.sol` matches the version to be tagged. If it doesn't, update it and run `make build` to automatically update the hyperdrivetypes `pyproject.toml` file. Merge a PR with these changes before tagging.
1010
2. [ ] Tag the release with `git tag vX.Y.Z`.
11-
3. [ ] Push the release to Github with `git push --tags`
12-
4. [ ] Go to the `releases` tab in Github and add the new tag as a release. Click the "Generate Release Notes" button to generate release notes.
11+
3. [ ] Push the release to Github with `git push --tags`.
12+
4. [ ] Go to the `releases` tab in Github and add the new tag as a release. Click the "Generate Release Notes" button to generate release notes.

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ build-sol:
1515
# forge build will do nothing if build-sol was previously run,
1616
# but we put it here so this can be called individually
1717
build-hyperdrivetypes:
18-
forge build && pypechain --output-dir python/hyperdrivetypes/hyperdrivetypes --line-length 80 out/
18+
forge build && pypechain --output-dir python/hyperdrivetypes/hyperdrivetypes --line-length 80 out/ && . scripts/set-hyperdrivetypes-version.sh
1919

2020
### Test ###
2121

python/hyperdrivetypes/pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[project]
22
name = "hyperdrivetypes"
3-
version = "0.0.2"
3+
version = "1.0.18"
4+
45
# Authors are the current, primary stewards of the repo
56
# contributors can be found on github
67
authors = [

scripts/build-hyperdrivetypes-wheel.sh

100644100755
+24-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
#!/bin/bash
22

3-
# hyperdrivetypes install
3+
# Set the python project version to match the hyperdrive version
4+
. scripts/set-hyperdrivetypes-version.sh
45

5-
echo "install required packages for building wheels"
6-
python -m venv --upgrade-deps .venv
7-
source .venv/bin/activate
8-
python -m pip install --upgrade pip
6+
# Just in case, check the versions match
7+
. scripts/verify-hyperdrivetypes-version.sh
8+
if [ -z "$HYPERDRIVE_VERSIONS_MATCH" ]; then
9+
echo "Environment variable HYPERDRIVE_VERSIONS_MATCH is not set. Exiting with failure."
10+
exit 1
11+
fi
912

10-
echo "install hyperdrivetypes & test build"
11-
pip install python/hyperdrivetypes build
13+
# Build if the versions match
14+
if [ "$HYPERDRIVE_VERSIONS_MATCH" != "true" ]; then
15+
echo "Version mismatch detected. Exiting with failure."
16+
exit 1
17+
else
18+
echo "Versions match. Installing required packages for building the wheel."
19+
python -m venv --upgrade-deps .venv
20+
source .venv/bin/activate
21+
python -m pip install --upgrade pip
1222

13-
echo "build the wheel for the current platform"
14-
python -m build --sdist --outdir dist python/hyperdrivetypes
15-
python -m pip wheel --no-deps --wheel-dir dist python/hyperdrivetypes
23+
echo "install hyperdrivetypes & test build"
24+
pip install python/hyperdrivetypes build
25+
26+
echo "build the wheel for the current platform"
27+
python -m build --sdist --outdir dist python/hyperdrivetypes
28+
python -m pip wheel --no-deps --wheel-dir dist python/hyperdrivetypes
29+
fi
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
echo "get hyperdrive version"
4+
5+
# Extract version using sed by reading from the file
6+
HYPERDRIVE_FILE="contracts/src/libraries/Constants.sol"
7+
VERSION=$(sed -n -E 's/.*VERSION = "v([0-9]+\.[0-9]+\.[0-9]+)".*/\1/p' "$HYPERDRIVE_FILE")
8+
9+
# Determine the OS using uname
10+
OS_TYPE=$(uname)
11+
12+
# Append the version to hyperdrivetypes
13+
HYPERDRIVETYPES_FILE="python/hyperdrivetypes/pyproject.toml"
14+
echo "found version: v$VERSION"
15+
echo "writing to $HYPERDRIVETYPES_FILE"
16+
# Check the operating system to use the correct sed syntax
17+
if [[ "$OSTYPE" == "Darwin"* ]]; then
18+
# e.g. macOS
19+
sed -i '' -E "s/^(version = \")[0-9]+\.[0-9]+\.[0-9]+(\".*)/\1$VERSION\2/" "$HYPERDRIVETYPES_FILE"
20+
elif [[ "$OSTYPE" == "Linux"* ]]; then
21+
# e.g. Ubuntu
22+
sed -i -E "s/^(version = \")[0-9]+\.[0-9]+\.[0-9]+(\".*)/\1$VERSION\2/" "$HYPERDRIVETYPES_FILE"
23+
else
24+
echo "Unsupported OS: $OSTYPE"
25+
exit 1
26+
fi
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# Extract version from hyperdrive
4+
constants_file="contracts/src/libraries/Constants.sol"
5+
VERSION_CONSTANTS=$(sed -n -E 's/.*VERSION = "v([0-9]+\.[0-9]+\.[0-9]+)".*/\1/p' "$constants_file")
6+
7+
# Extract version from hyperdrivetypes
8+
init_file="python/hyperdrivetypes/pyproject.toml"
9+
VERSION_INIT=$(sed -n -E 's/version = "([0-9]+\.[0-9]+\.[0-9]+)".*/\1/p' "$init_file")
10+
11+
# Compare versions
12+
if [ "$VERSION_CONSTANTS" == "$VERSION_INIT" ]; then
13+
echo "versions match!"
14+
echo "hyperdrive version: $VERSION_CONSTANTS"
15+
echo "hyperdrivetypes version: $VERSION_INIT"
16+
export HYPERDRIVE_VERSIONS_MATCH=true
17+
else
18+
echo "versions do not match!"
19+
echo "hyperdrive version: $VERSION_CONSTANTS"
20+
echo "hyperdrivetypes version: $VERSION_INIT"
21+
export HYPERDRIVE_VERSIONS_MATCH=false
22+
fi

0 commit comments

Comments
 (0)