Skip to content

Commit

Permalink
Automatically set the version number by the latest tag
Browse files Browse the repository at this point in the history
  • Loading branch information
tbttfox committed Sep 3, 2024
1 parent aca8d20 commit ec9adc4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- run: git fetch --tags origin
- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: 0.0.1

- name: Get Maya Devkit
id: get-devkit
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ $RECYCLE.BIN/
Network Trash Folder
Temporary Items
.apdisk

# Auto-created version files
version.h
33 changes: 24 additions & 9 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,31 @@ maya_dep = dependency('maya')
maya_name_suffix = maya_dep.get_variable('name_suffix')
maya_version = maya_dep.get_variable('maya_version')

source_files = files([
'src/pluginMain.cpp',
'src/drawOverride.cpp',
'src/twistSplineData.cpp',
'src/twistSplineNode.cpp',
'src/riderConstraint.cpp',
'src/twistTangentNode.cpp',
'src/twistMultiTangentNode.cpp',
])
source_files = [
'src/pluginMain.cpp',
'src/drawOverride.cpp',
'src/twistSplineData.cpp',
'src/twistSplineNode.cpp',
'src/riderConstraint.cpp',
'src/twistTangentNode.cpp',
'src/twistMultiTangentNode.cpp',
]

# If a user-built version file exists, then just use that
# Otherwise grab the latest tag from git
fs = import('fs')
if fs.is_file('src/version.h')
message('Using existing version.h')
else
git = find_program('git', native: true, required: true)
version_h = vcs_tag(
command: [git, 'describe', '--tags', '--match', 'v[0-9]*', '--dirty=+'],
fallback: 'v0.0.1',
input: 'src/version.h.in',
output: 'version.h',
)
source_files = source_files + version_h
endif
harm_inc = include_directories(['src'])

outlib = shared_library(
Expand Down
3 changes: 2 additions & 1 deletion src/pluginMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ SOFTWARE.
#include "twistMultiTangentNode.h"
#include "drawOverride.h"
#include <maya/MFnPlugin.h>
#include "version.h"

MStatus initializePlugin( MObject obj ) {
MStatus status;
MFnPlugin plugin( obj, "BlurStudio", "1.2.1", "Any");
MFnPlugin plugin( obj, "BlurStudio", VERSION_STRING, "Any");

status = plugin.registerData("twistSplineData", TwistSplineData::id, TwistSplineData::creator);
if (!status) {
Expand Down
3 changes: 3 additions & 0 deletions src/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once
#define VERSION_STRING "@VCS_TAG@"

0 comments on commit ec9adc4

Please sign in to comment.