Skip to content
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
2 changes: 1 addition & 1 deletion docs/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

The sequencing of releases may change in response to client needs and other external factors.

## CURRENT: Version 4.2.0
## CURRENT: Version 4.2.1

- Profile import-selection authoring API — safer, granular control over an import's `include-controls` / `exclude-controls` and the `with-child-controls` flag:
- `set_import_with_children()` toggles `with-child-controls` on the existing include/exclude selection independently, without rebuilding it.
Expand Down
7 changes: 7 additions & 0 deletions docs/VERSION_HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,10 @@
- `preview_import_selection(href, ...)` — dry-run that returns the control ids a (committed or hypothetical) selection resolves to, so a caller can see what a `matching` glob actually selects before committing.
- All import-selection setters remain staged, metaschema-validated, and atomic (a rejected edit rolls back and returns `None`).
- CI: pinned the Python 3.9 test/lint matrix leg to `ubuntu-22.04` (`actions/setup-python` has no 3.9 build for Ubuntu ≥24.04, now the `ubuntu-latest` image). Python 3.9 support is unchanged this release; see `docs/5.0.0_PLANNING.md` for the planned drop of 3.9/3.10 and addition of 3.14.

## Version 4.2.1

- additional methods for managing profile import control inclusion and exclusion directives
- original method is still available, but only provided coarse-grain control
- new methods allow targeted adjustments

2 changes: 1 addition & 1 deletion oscal/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
so the build backend can read the literal without importing ``oscal`` (and its
dependencies).
"""
__version__ = "4.2.0"
__version__ = "4.2.1"
107 changes: 107 additions & 0 deletions scripts/tag-release.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
@echo off
setlocal enabledelayedexpansion
REM tag-release.cmd -- safely tag a release and switch back automatically.
REM
REM Encapsulates the one workflow that requires being on the release branch
REM (default: main): tagging a release. Does checkout -> tag -> push ->
REM switch back as one sequence, so "forgot to switch back to the dev
REM branch afterward" stops being a failure mode that exists at all.
REM
REM Generic by design -- copy this file (and tag-release.sh) into any
REM repo's scripts\ folder. Nothing here names a specific repo, remote, or
REM branch beyond the configurable defaults below.
REM
REM Usage:
REM scripts\tag-release.cmd <tag>
REM e.g. scripts\tag-release.cmd v2.1.0
REM
REM Configurable via environment variables (defaults shown):
REM RELEASE_BRANCH=main
REM REMOTE=origin

if "%RELEASE_BRANCH%"=="" set "RELEASE_BRANCH=main"
if "%REMOTE%"=="" set "REMOTE=origin"

if "%~1"=="" (
echo Usage: %~nx0 ^<tag^>
echo e.g. %~nx0 v2.1.0
exit /b 1
)
set "TAG=%~1"

git rev-parse --is-inside-work-tree >nul 2>&1
if errorlevel 1 (
echo error: not inside a git repository
exit /b 1
)

set "ORIGINAL_BRANCH="
for /f "delims=" %%b in ('git symbolic-ref --short HEAD 2^>nul') do set "ORIGINAL_BRANCH=%%b"
if "%ORIGINAL_BRANCH%"=="" (
echo error: not currently on a branch ^(detached HEAD^) -- aborting
exit /b 1
)

set "DIRTY="
for /f "delims=" %%s in ('git status --porcelain') do set "DIRTY=1"
if defined DIRTY (
echo error: you have uncommitted changes. Commit, stash, or discard them first.
exit /b 1
)

git rev-parse "%TAG%" >nul 2>&1
if not errorlevel 1 (
echo error: tag "%TAG%" already exists locally.
exit /b 1
)

echo -------------------------------------------------------------------
echo About to tag a release:
echo Tag : %TAG%
echo Branch : %RELEASE_BRANCH%
echo Remote : %REMOTE%
echo Returning to : %ORIGINAL_BRANCH%
echo -------------------------------------------------------------------
set "CONFIRM="
set /p CONFIRM="Continue? [y/N] "
if /i "%CONFIRM%"=="y" goto :confirmed
if /i "%CONFIRM%"=="yes" goto :confirmed
echo Aborted -- no changes made.
exit /b 1

:confirmed
git fetch %REMOTE% --quiet
if errorlevel 1 goto :fail

git checkout %RELEASE_BRANCH%
if errorlevel 1 goto :fail

git pull --ff-only %REMOTE% %RELEASE_BRANCH%
if errorlevel 1 goto :restore_and_fail

git ls-remote --exit-code %REMOTE% "refs/tags/%TAG%" >nul 2>&1
if not errorlevel 1 (
echo error: tag "%TAG%" already exists on %REMOTE%.
goto :restore_and_fail
)

git tag -a "%TAG%" -m "Release %TAG%"
if errorlevel 1 goto :restore_and_fail

git push %REMOTE% "%TAG%"
if errorlevel 1 goto :restore_and_fail

echo -------------------------------------------------------------------
echo Tagged and pushed %TAG% from %RELEASE_BRANCH%.
echo Switching back to %ORIGINAL_BRANCH%.
echo -------------------------------------------------------------------
git checkout %ORIGINAL_BRANCH%
exit /b 0

:restore_and_fail
echo Restoring original branch %ORIGINAL_BRANCH% after failure...
git checkout %ORIGINAL_BRANCH% >nul 2>&1

:fail
echo tag-release failed.
exit /b 1
91 changes: 91 additions & 0 deletions scripts/tag-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/env bash
# tag-release.sh -- safely tag a release and switch back automatically.
#
# Encapsulates the one workflow that requires being on the release branch
# (default: main): tagging a release. Does checkout -> tag -> push -> switch
# back as one sequence, so "forgot to switch back to the dev branch
# afterward" stops being a failure mode that exists at all.
#
# Generic by design -- copy this file (and tag-release.cmd) into any repo's
# scripts/ folder. Nothing here names a specific repo, remote, or branch
# beyond the configurable defaults below.
#
# Usage:
# scripts/tag-release.sh <tag>
# e.g. scripts/tag-release.sh v2.1.0
#
# Configurable via environment variables (defaults shown):
# RELEASE_BRANCH=main
# REMOTE=origin

set -euo pipefail

RELEASE_BRANCH="${RELEASE_BRANCH:-main}"
REMOTE="${REMOTE:-origin}"

if [ $# -ne 1 ]; then
echo "Usage: $0 <tag>" >&2
echo " e.g. $0 v2.1.0" >&2
exit 1
fi
TAG="$1"

if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "error: not inside a git repository" >&2
exit 1
fi

ORIGINAL_BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null || true)"
if [ -z "$ORIGINAL_BRANCH" ]; then
echo "error: not currently on a branch (detached HEAD) -- aborting" >&2
exit 1
fi

# Refuse with uncommitted changes: avoids any ambiguity about what ends up
# tagged, and avoids carrying local edits across the branch switch below.
if [ -n "$(git status --porcelain)" ]; then
echo "error: you have uncommitted changes. Commit, stash, or discard them first." >&2
exit 1
fi

if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "error: tag '$TAG' already exists locally." >&2
exit 1
fi

echo "-------------------------------------------------------------------"
echo " About to tag a release:"
echo " Tag : $TAG"
echo " Branch : $RELEASE_BRANCH"
echo " Remote : $REMOTE"
echo " Returning to : $ORIGINAL_BRANCH"
echo "-------------------------------------------------------------------"
read -r -p "Continue? [y/N] " REPLY
case "$REPLY" in
[yY]|[yY][eE][sS]) ;;
*) echo "Aborted -- no changes made."; exit 1 ;;
esac

# Whatever happens from here, try to land back on the branch we started on.
cleanup() {
git checkout "$ORIGINAL_BRANCH" >/dev/null 2>&1 || true
}
trap cleanup EXIT

git fetch "$REMOTE" --quiet
git checkout "$RELEASE_BRANCH"
git pull --ff-only "$REMOTE" "$RELEASE_BRANCH"

if git ls-remote --exit-code "$REMOTE" "refs/tags/$TAG" >/dev/null 2>&1; then
echo "error: tag '$TAG' already exists on $REMOTE." >&2
exit 1
fi

git tag -a "$TAG" -m "Release $TAG"
git push "$REMOTE" "$TAG"

echo "-------------------------------------------------------------------"
echo " Tagged and pushed $TAG from $RELEASE_BRANCH."
echo " Switching back to $ORIGINAL_BRANCH..."
echo "-------------------------------------------------------------------"
# cleanup() above (registered via trap on EXIT) performs the checkout back.
Loading