Skip to content

Setuptools scm #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 14 additions & 22 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,26 @@ jobs:
steps:
- name: clone repo
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Install virtualenv
uses: getsentry/[email protected]
with:
python-version: 3.12
venv-dir: venv
install-cmd: pip install ./hpc_provisioner
- name: Determine version
run: |
echo REL_TAG=$(awk '/version =/ {print $3}' hpc_provisioner/pyproject.toml | tr -d '"') >> $GITHUB_ENV
echo REL_TAG=$(ls -d venv/lib/python3*/site-packages/hpc_provisioner*dist-info | awk -F- '{print $3}' | sed 's/.dist//') >> $GITHUB_ENV
- name: Create and upload tag ${{ env.REL_TAG }}
if: ${{ ! contains(env.REL_TAG, 'dev') }}
run: |
git config user.name github-actions
git config user.email [email protected]
git tag -a $REL_TAG -m "${REL_TAG}"
git push origin $REL_TAG
working-directory: ${{runner.workspace}}/hpc-resource-provisioner
- name: Authenticate with ghcr
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Authenticate with docker-hub
uses: docker/[email protected]
with:
username: ${{ secrets.BBPBUILDBOT_DOCKERHUB_USER }}
password: ${{ secrets.BBPBUILDBOT_DOCKERHUB_PASSWORD }}
- name: Authenticate with AWS ECR
uses: docker/[email protected]
with:
Expand All @@ -48,19 +47,12 @@ jobs:
- name: Build and push container
run: |
SOURCE_CHECKSUM=$(find hpc_provisioner -type f -exec sha256sum {} \; | sha256sum | awk '{print $1}')
GHCR_PATH=openbraininstitute/hpc-resource-provisioner
AWS_URI=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
AWS_PATH=hpc/resource-provisioner
docker build --label "org.opencontainers.image.checksum=${SOURCE_CHECKSUM}" --label "org.opencontainers.image.software_version=${REL_TAG}" -t ${GHCR_PATH}:${REL_TAG} .
echo "Setting tags for ghcr"
docker image tag ${GHCR_PATH}:${REL_TAG} ghcr.io/${GHCR_PATH}:${REL_TAG}
docker image tag ${GHCR_PATH}:${REL_TAG} ghcr.io/${GHCR_PATH}:latest
docker build --build-arg SETUPTOOLS_SCM_PRETEND_VERSION=${REL_TAG} --label "org.opencontainers.image.checksum=${SOURCE_CHECKSUM}" --label "org.opencontainers.image.software_version=${REL_TAG}" -t ${AWS_PATH}:${REL_TAG} .
echo "Setting tags for aws ecr"
docker image tag ${GHCR_PATH}:${REL_TAG} ${AWS_URI}/${AWS_PATH}:${REL_TAG}
docker image tag ${GHCR_PATH}:${REL_TAG} ${AWS_URI}/${AWS_PATH}:latest
echo "Pushing to ghcr"
docker push ghcr.io/${GHCR_PATH}:${REL_TAG}
docker push ghcr.io/${GHCR_PATH}:latest
docker image tag ${AWS_PATH}:${REL_TAG} ${AWS_URI}/${AWS_PATH}:${REL_TAG}
docker image tag ${AWS_PATH}:${REL_TAG} ${AWS_URI}/${AWS_PATH}:latest
echo "Pushing to aws ecr"
docker push ${AWS_URI}/${AWS_PATH}:${REL_TAG}
docker push ${AWS_URI}/${AWS_PATH}:latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ coverage.xml
unittests.xml
package/
*.zip
_version.py
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM public.ecr.aws/lambda/python:3.12
LABEL org.opencontainers.image.source="https://github.com/openbraininstitute/hpc-resource-provisioner"

ARG SETUPTOOLS_SCM_PRETEND_VERSION

RUN dnf -y install nodejs findutils && python3 -m pip install aws-parallelcluster==3.9.3 awslambdaric

ADD hpc_provisioner /opt/hpc_provisioner
Expand Down
10 changes: 8 additions & 2 deletions hpc_provisioner/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[build-system]
requires = ["setuptools"]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"

[project]
name = "hpc_provisioner"
version = "0.5.9.0"
dependencies = [
"aws-parallelcluster",
"boto3",
Expand All @@ -21,6 +20,13 @@ classifiers = [
"Topic :: Scientific/Engineering",
"License :: OSI Approved :: Apache Software License",
]
dynamic = ["version"]

[tool.setuptools_scm]
version_file = "_version.py"
local_scheme = "no-local-version"
relative_to = "pyproject.toml"
root = ".."

[project.optional-dependencies]
test = ["pytest", "pytest-cov"]
Expand Down
Loading