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 8c84de6 commit 3949154
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- run: git fetch --tags origin

- name: Get Maya Devkit
id: get-devkit
uses: blurstudio/mayaModuleActions/getMayaDevkit@v1
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
36 changes: 23 additions & 13 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +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',
]

latest_tag = run_command('git', 'describe', '--tags', '--abbrev=0').stdout().strip()
if latest_tag == ''
latest_tag = 'NOTAG'
# 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
add_project_arguments('-DVERSION_STRING="' + latest_tag + '"', language: 'cpp')

outlib = shared_library(
meson.project_name(),
Expand Down
1 change: 1 addition & 0 deletions src/pluginMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ SOFTWARE.
#include "twistMultiTangentNode.h"
#include "drawOverride.h"
#include <maya/MFnPlugin.h>
#include "version.h"

MStatus initializePlugin( MObject obj ) {
MStatus 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 3949154

Please sign in to comment.