Extract release version number from tag, if applicable

This commit is contained in:
Scott Bezek
2022-03-14 21:59:03 -07:00
parent 916854c611
commit 1f7bf8a92a
7 changed files with 54 additions and 28 deletions

View File

@@ -137,7 +137,7 @@ def _pcbnew_export_3d(output_file, width, height, transforms):
time.sleep(2)
def export_3d(filename, suffix, width, height, transforms, raytrace, virtual, color_soldermask, color_silk, color_board, color_copper):
def export_3d(filename, suffix, width, height, transforms, raytrace, virtual, color_soldermask, color_silk, color_board, color_copper, release_prefix):
pcb_file = os.path.abspath(filename)
output_dir = os.path.join(electronics_root, 'build')
file_util.mkdir_p(output_dir)
@@ -167,7 +167,7 @@ def export_3d(filename, suffix, width, height, transforms, raytrace, virtual, co
apply_color('CopperColor', color_copper)
with patch_config(os.path.expanduser('~/.config/kicad/pcbnew'), settings):
with versioned_file(pcb_file):
with versioned_file(pcb_file, release_prefix):
with recorded_xvfb(screencast_output_file, width=width, height=height, colordepth=24):
with PopenContext(['pcbnew', pcb_file], close_fds=True) as pcbnew_proc:
_pcbnew_export_3d(output_file, width, height, transforms)
@@ -186,6 +186,7 @@ if __name__ == '__main__':
parser.add_argument('--color-silk', type=float, nargs=3, help='Silkscreen color as 3 floats from 0-1', default=[1, 1, 1])
parser.add_argument('--color-board', type=float, nargs=3, help='PCB substrate color as 3 floats from 0-1', default=[0.764705882, 0.729411765, 0.607843137])
parser.add_argument('--color-copper', type=float, nargs=3, help='Copper color as 3 floats from 0-1', default=[0.7, 0.7, 0.7])
parser.add_argument('--release-prefix', type=str, required=True, help='Tag prefix to check if this is a tagged/versioned release. E.g. "releases/" for tags like "releases/v1.0"')
# Use subparsers to for an optional nargs="*" choices argument (workaround for https://bugs.python.org/issue9625)
subparsers = parser.add_subparsers(dest='which')
@@ -196,4 +197,4 @@ if __name__ == '__main__':
transforms = args.transform if args.which == 'transform' else []
export_3d(args.pcb, args.suffix, args.width, args.height, transforms, not args.skip_raytrace, not args.skip_virtual, args.color_soldermask, args.color_silk, args.color_board, args.color_copper)
export_3d(args.pcb, args.suffix, args.width, args.height, transforms, not args.skip_raytrace, not args.skip_virtual, args.color_soldermask, args.color_silk, args.color_board, args.color_copper, args.release_prefix)