Skip to content

Commit dd7da2a

Browse files
authored
Merge branch 'main' into ud/fix-env-vars
2 parents 0d510c1 + 41b78cf commit dd7da2a

9 files changed

+96
-14
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ release-python-apiclient: resolve-earthly
162162
################################################################################
163163
.PHONY: release-python-sdk
164164
release-python-sdk: build-python-sdk
165-
cd python && ${EARTHLY} --push +publish --PYPI_TOKEN=${PYPI_TOKEN}
165+
cd python && ${MAKE} publish
166166
@echo "Python SDK pushed to PyPi."
167167

168168
################################################################################

buildkite/pipelines/bacalhau-python.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11

22

33
steps:
4-
- label: ":swagger: Generate Swagger"
5-
command: "./scripts/generate_swagger.sh"
4+
- label: ":python: Generate Swagger"
5+
command: "./buildkite/scripts/generate_swagger.sh"
66

77
- wait: ~
88

99
- label: ":python: Build Python API Client"
10-
command: "make build-python-apiclient"
10+
command: "./buildkite/scripts/build_python_client.sh"
1111

1212
- label: ":python: Build Python SDK"
13-
command: "make build-python-sdk"
13+
command: "./buildkite/scripts/build_python_sdk.sh"
1414

1515
- label: ":python: Build Bacalhau Airflow Integration"
1616
command: "make build-bacalhau-airflow"

buildkite/scripts/build_python_client.sh

100644100755
+35-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
11
#!/bin/bash
22

3-
make build-python-apiclient
3+
set -e
4+
5+
setup_environment_variables() {
6+
export PYPI_TOKEN=$(buildkite-agent secret get PYPI_TOKEN)
7+
export TEST_PYPI_TOKEN=$(buildkite-agent secret get TEST_PYPI_TOKEN)
8+
export RELEASE_PYTHON_PACKAGES=1
9+
}
10+
11+
download_swagger() {
12+
cd docs
13+
rm -rf swagger.json
14+
buildkite-agent artifact download "swagger.json" . --build $BUILDKITE_BUILD_ID
15+
cd ..
16+
}
17+
18+
build_python_apiclient() {
19+
make build-python-apiclient
20+
}
21+
22+
publish_python_apiclient() {
23+
make release-python-apiclient
24+
}
25+
26+
27+
main () {
28+
setup_environment_variables
29+
download_swagger
30+
build_python_apiclient
31+
32+
if [ -n "$BUILDKITE_TAG" ]; then
33+
publish_python_apiclient
34+
fi
35+
}
36+
37+
main

buildkite/scripts/build_python_sdk.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
setup_environment_variables() {
6+
export PYPI_TOKEN=$(buildkite-agent secret get PYPI_TOKEN)
7+
export TEST_PYPI_TOKEN=$(buildkite-agent secret get TEST_PYPI_TOKEN)
8+
export RELEASE_PYTHON_PACKAGES=1
9+
}
10+
11+
build_python_sdk() {
12+
make build-python-sdk
13+
}
14+
15+
publish_python_sdk() {
16+
make release-python-sdk
17+
}
18+
19+
main() {
20+
setup_environment_variables
21+
build_python_sdk
22+
23+
if [ -n "$BUILDKITE_TAG" ]; then
24+
publish_python_sdk
25+
fi
26+
27+
}
28+
29+
main

buildkite/scripts/generate_swagger.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Call generate_swagger.sh
5+
generate_swagger() {
6+
./scripts/generate_swagger.sh
7+
}
8+
9+
upload_swagger() {
10+
cd docs
11+
buildkite-agent artifact upload "swagger.json"
12+
}
13+
14+
main() {
15+
generate_swagger
16+
upload_swagger
17+
}
18+
19+
main

clients/Earthfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,9 @@ pypi-upload:
8484
BUILD +install-twine
8585

8686
ARG RELEASE_PYTHON_PACKAGES
87-
LET REPOSITORY_FLAG = "--repository-url https://test.pypi.org/legacy/"
8887
IF [ "${RELEASE_PYTHON_PACKAGES}" = 1 ]
8988
RUN echo "Publishing to pypi.org"
90-
RUN REPOSITORY_FLAG = "" # Publish to default repository
89+
LET REPOSITORY_FLAG = "" # Publish to default repository
9190
RUN --secret PYPI_TOKEN test -n "${PYPI_TOKEN}" || (echo "PYPI_TOKEN not found" && exit 1)
9291
RUN --secret PYPI_TOKEN python3 -m twine upload \
9392
--non-interactive \
@@ -99,6 +98,7 @@ pypi-upload:
9998
${REPOSITORY_FLAG}
10099
ELSE
101100
RUN echo "Publishing to test.pypi.org"
101+
LET REPOSITORY_FLAG = "--repository-url https://test.pypi.org/legacy/"
102102
RUN --secret TEST_PYPI_TOKEN test -n "${TEST_PYPI_TOKEN}" || (echo "TEST_PYPI_TOKEN not found" && exit 1)
103103
RUN --secret TEST_PYPI_TOKEN python3 -m twine upload \
104104
--non-interactive \

clients/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ release:
1616
echo "PYPI_VERSION=$(VERSION)" > .arg
1717

1818
# Get PYPI_TOKEN from environment or .env file and push to .secret/ file
19-
python ../scripts/get_pypi_token.py
19+
python3 ../scripts/get_pypi_token.py
2020

2121
$(CP) ${SWAGGER_JSON} ./swagger.json
22-
${MAKE} clean && ${EARTHLY} +pypi-upload --PACKAGE_NAME=${PACKAGE_NAME} --SWAGGER_JSON=${SWAGGER_JSON} --VERSION=${VERSION}
22+
${MAKE} clean && ${EARTHLY} +pypi-upload --PACKAGE_NAME=${PACKAGE_NAME} --SWAGGER_JSON=${SWAGGER_JSON} --VERSION=${VERSION} --RELEASE_PYTHON_PACKAGES=${RELEASE_PYTHON_PACKAGES}
2323
@echo "Python API client released."
2424

2525
.PHONY: all

python/Earthfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ publish:
6161
FROM +install-twine
6262
BUILD +install-twine
6363
ARG RELEASE_PYTHON_PACKAGES
64-
LET REPOSITORY_FLAG = "--repository-url https://test.pypi.org/legacy/"
6564
IF [ "${RELEASE_PYTHON_PACKAGES}" = 1 ]
6665
RUN echo "Publishing to pypi.org"
67-
RUN REPOSITORY_FLAG = "" # Publish to default repository
66+
LET REPOSITORY_FLAG = "" # Publish to default repository
6867
RUN --secret PYPI_TOKEN test -n "${PYPI_TOKEN}" || (echo "PYPI_TOKEN not found" && exit 1)
6968
RUN --secret PYPI_TOKEN python3 -m twine upload \
7069
--non-interactive \
@@ -76,6 +75,7 @@ publish:
7675
${REPOSITORY_FLAG}
7776
ELSE
7877
RUN echo "Publishing to test.pypi.org"
78+
LET REPOSITORY_FLAG = "--repository-url https://test.pypi.org/legacy/"
7979
RUN --secret TEST_PYPI_TOKEN test -n "${TEST_PYPI_TOKEN}" || (echo "TEST_PYPI_TOKEN not found" && exit 1)
8080
RUN --secret TEST_PYPI_TOKEN python3 -m twine upload \
8181
--non-interactive \

python/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ publish:
6767
echo "PYPI_VERSION=$(VERSION)" > .arg
6868

6969
# Get PYPI_TOKEN from environment or .env file and push to .secret/ file
70-
python ../scripts/get_pypi_token.py
70+
python3 ../scripts/get_pypi_token.py
7171

72-
$(EARTHLY) --push +publish --PYPI_VERSION=$(VERSION)
72+
$(EARTHLY) --push +publish --RELEASE_PYTHON_PACKAGES=${RELEASE_PYTHON_PACKAGES} --PYPI_VERSION=${PYPI_VERSION}

0 commit comments

Comments
 (0)