Skip to content

Commit

Permalink
Merge pull request #2 from AllenInstitute/feature/DT-6858-make-packag…
Browse files Browse the repository at this point in the history
…e-public

Complete configuration of release (integrating with bump-my-version)
  • Loading branch information
rpmcginty authored Dec 3, 2024
2 parents 8149663 + 0a262ae commit cb83ee7
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 50 deletions.
48 changes: 0 additions & 48 deletions .github/scripts/release.py

This file was deleted.

6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ name: Build and Test
on:
pull_request:
branches: [ main ]
paths-ignore:
- '**/_version.py'
push:
branches: [ main ]
tags-ignore:
- 'v*'
paths-ignore:
- '**/_version.py'

jobs:
test:
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,78 @@ on:
default: true

jobs:
bump:
name: Bump version
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
outputs:
VERSION: ${{ steps.get-version-and-commit-sha.outputs.VERSION }}
SHORT_VERSION: ${{ steps.get-version-and-commit-sha.outputs.SHORT_VERSION }}
MAJOR_VERSION: ${{ steps.get-version-and-commit-sha.outputs.MAJOR_VERSION }}
MINOR_VERSION: ${{ steps.get-version-and-commit-sha.outputs.MINOR_VERSION }}
COMMIT_SHA: ${{ steps.get-version-and-commit-sha.outputs.COMMIT_SHA }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
cache: 'pip'
- name: Set up AllenInstitute Repo Authorization
uses: ./.github/actions/setup-ai-github-urls
with:
token: ${{ secrets.AI_PACKAGES_TOKEN }}
- name: Get tags
run: git fetch --tags origin
- name: Configure git for github-actions[bot]
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Run Install
run: |
make install-release
shell: bash
- name: Bump version with bumpversion
run: |
source .venv/bin/activate
bump-my-version bump ${{ github.event.inputs.part }}
- name: Commit and push with tags
if: ${{ github.event.inputs.dry-run == 'false' }}
run: |
git push --follow-tags
- name: Get version and commit SHA
id: get-version-and-commit-sha
run: |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
# remove the leading v from tag
version="${latest_tag:1}"
echo "VERSION=$version" >> $GITHUB_OUTPUT
major_version="$(cut -d '.' -f 1 <<< $version)"
echo "MAJOR_VERSION=$major_version" >> $GITHUB_OUTPUT
minor_version="$(cut -d '.' -f 2 <<< $version)"
echo "MINOR_VERSION=$minor_version" >> $GITHUB_OUTPUT
short_version="$major_version.$minor_version"
echo "SHORT_VERSION=$short_version" >> $GITHUB_OUTPUT
commit_sha=$(git rev-parse $latest_tag)
echo "COMMIT_SHA=$commit_sha" >> $GITHUB_OUTPUT
- name: Show short version
run: echo ${{ steps.get-version-and-commit-sha.outputs.SHORT_VERSION }}

build:
name: Build distribution
runs-on: ubuntu-latest
needs: bump
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.bump.outputs.COMMIT_SHA }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ $(INSTALL_STAMP): $(PYTHON) $(DEP_FILES)
$(PIP) install -e .[dev];
@touch $(INSTALL_STAMP)

install-release: clean-install-stamp $(PYTHON) $(DEP_FILES) ## Installs package for release
@. $(VENV_BIN)/activate;\
$(PIP) install .[release]


install-force: clean-install-stamp install ## Force install package dependencies

link-packages: ## Link local packages to virtualenv
Expand Down Expand Up @@ -166,9 +171,8 @@ coverage-server: $(INSTALL_STAMP) ## Run coverage server
##@ Release Commands
#####################

dist: $(PYTHON) $(DEP_FILES) ## Build source and wheel package
dist: install-release ## Build source and wheel package
@. $(VENV_BIN)/activate;\
$(PIP) install .[release];\
$(PYTHON) -m build;

reinstall: obliterate install ## Recreate environment and install
Expand Down
27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies = [

release = [
"build",
"bump-my-version",
"twine",
"wheel",
]
Expand Down Expand Up @@ -195,3 +196,29 @@ line_length = 99
profile = "black"
src_paths = ["src", "test"]

# -----------------------------------------------------------------------------
## bumpversion Configurations
# https://callowayproject.github.io/bump-my-version/
# -----------------------------------------------------------------------------

[tool.bumpversion]
allow_dirty = false
commit = true
commit_args = ""
current_version = "0.0.1"
ignore_missing_version = false
message = "Bump version: {current_version} → {new_version}"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
regex = false
replace = "{new_version}"
search = "{current_version}"
serialize = ["{major}.{minor}.{patch}"]
sign_tags = false
tag = true
tag_message = "Bump version: {current_version} → {new_version}"
tag_name = "v{new_version}"

[[tool.bumpversion.files]]
filename = "src/aibs_informatics_test_resources/__version__.py"
search = "__version__ = \"{current_version}\""
replace = "__version__ = \"{new_version}\""

0 comments on commit cb83ee7

Please sign in to comment.