diff --git a/PUBLISHING.md b/PUBLISHING.md index 32bdc307a..ae322ae40 100644 --- a/PUBLISHING.md +++ b/PUBLISHING.md @@ -34,16 +34,5 @@ Only appointed team members may publish releases. `npm publish --access public`\ Project build will automatically occur before publish. 1. Create release and tag on GitHub. -1. Fetch the latest tags.\ - `git fetch --tags` -1. Check whether tag is annotated.\ - `git describe --always`\ - (expect `vN.N.N` i.e. the version tag) -1. **If** tag is **not** annotated, **then**: - 1. Annotate Github's tag:\ - `bin/annotate-tag.sh vN.N.N`\ - (where `N.N.N` is the version tag) - 1. Overwrite remote tag with annotated one:\ - `git push --tags --force` diff --git a/bin/annotate-tag.sh b/bin/annotate-tag.sh deleted file mode 100755 index 2f5dcb027..000000000 --- a/bin/annotate-tag.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -# Annotate a tag from Github -# FAQ: Github releases create annotated (not lightweight) tags -# SEE: https://github.com/orgs/community/discussions/4924 - -# Whether string is a valid SemVer version -is_valid_semver() { - local version=$1 - # SemVer regex pattern (simplified for illustration) - local semver_pattern="^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$" - [[ $version =~ $semver_pattern ]] -} - -# Is argument (string) provided? -if [ $# -ne 1 ]; then - echo "Usage: $0 " - exit 1 -fi - -# Capture arguments -version_string=$1 - -# Is string a valid SemVer version? -if ! is_valid_semver "$version_string"; then - echo "Error: Invalid SemVer format. Please provide a valid version string like '3.11.6' or 'v3.12.0-beta.3' or 'v3.6.0-8-gd1dbcab'." - exit 1 -fi - -# Annotate the tag -git fetch --tags -git checkout "$version_string" -git tag -d "$version_string" -git tag -a "$version_string" -m "chore: $version_string" - -# Report success -echo "Annotated tag \"$version_string\"." diff --git a/bin/release-publish.sh b/bin/release-publish.sh index 847379190..310afc611 100755 --- a/bin/release-publish.sh +++ b/bin/release-publish.sh @@ -41,23 +41,4 @@ else fi # Create GitHub release -echo "Please create a release on GitHub now." -echo "Visit: https://github.com/TACC/Core-Styles/releases/new" -read -p "Press Enter once you've created the release..." - -# Fetch and check tags -echo "Fetching tags..." -git fetch --tags - -echo "Checking if tag is annotated..." -if git describe --exact-match "$version_tag" >/dev/null 2>&1; then - echo "Tag $version_tag is already annotated" -else - echo "Tag $version_tag is not annotated, annotating..." - ./bin/annotate-tag.sh "$version_tag" - - echo "Force pushing annotated tag..." - git push --tags --force -fi - -echo "Release process complete!" \ No newline at end of file +echo "Create GitHub release now: https://github.com/TACC/Core-Styles/releases/new" diff --git a/src/bin/version.js b/src/bin/version.js index 4d7424b6f..207bc945d 100755 --- a/src/bin/version.js +++ b/src/bin/version.js @@ -1,22 +1,38 @@ #!/usr/bin/env node -/** Create CSS version based on lifecycle app data and given data */ +/** Create CSS version based on available data */ const package = require(process.env.npm_package_json || '../package.json'); /** - * Create version from app data and given data + * Create version from available data * @param {string} [buildId] - Any value to identify the build */ function create(buildId) { const appName = package.name; - const appVersion = buildId || package.version + '+'; + const appVersion = buildId || gitDescribeTag() || package.version + '+'; const appLicense = package.license; const appWebsite = package.homepage.replace('https://', ''); return `${appName} ${appVersion} | ${appLicense} | ${appWebsite}`; } +/** Get tag-based description from Git */ +function gitDescribeTag() { + const { execSync } = require('child_process'); + + let gitDescribe = undefined; + + try { + gitDescribe = execSync('git describe --tags', { encoding: 'utf8' }).trim(); + console.log('Output from `git describe`:', gitDescribe); + } catch (error) { + console.error('Error running `git describe`:', error.message); + } + + return gitDescribe; +} + /* Export */