diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dcac3e308..99d7cafdf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,12 +43,7 @@ Only appointed team members may release versions. - `poetry version N.N.N` 2. Review. Commit. Push. 3. Create release and tag on GitHub. -4. Annotate Github's tag:\ - `bin/annotate-tag.sh vN.N.N`\ - (where `N.N.N` is the version tag) -5. Overwrite remote tag with annotated one:\ - `git push --tags --force` -6. [Build & Deploy](../README.md#build--deploy-project) `main` branch.[^1] +4. [Build & Deploy](../README.md#build--deploy-project) `main` branch.[^1] [^1]: So that new CMS image is tagged `latest` and `vN.N.N`. diff --git a/Makefile b/Makefile index 04ac8de0e..e023fb43a 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ DOCKER_COMPOSE_CMD := $(shell if command -v docker-compose > /dev/null; then ech # NOTE: Special characters in `DOCKER_IMAGE_BRANCH` are replaced with dashes. DOCKER_IMAGE_BRANCH := $(DOCKERHUB_REPO):$(shell git describe --exact-match --tags 2> /dev/null || git symbolic-ref --short HEAD | sed 's/[^[:alnum:]\.\_\-]/-/g') -BUILD_ID := $(shell git describe --always) +BUILD_ID := $(shell git describe --tags) .PHONY: build build: diff --git a/bin/annotate-tag.sh b/bin/annotate-tag.sh deleted file mode 100755 index 4538a92c7..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 pull -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/build-css.js b/bin/build-css.js index 9b4efb545..37fedea3a 100755 --- a/bin/build-css.js +++ b/bin/build-css.js @@ -4,10 +4,11 @@ const buildStylesheets = require('@tacc/core-styles').buildStylesheets; const mininmist = require('minimist'); +const gitDescribe = require('./git-describe'); const ROOT = __dirname + '/..'; const ARGS = mininmist( process.argv.slice( 2 ) ); -const BUILD_ID = ARGS['build-id'] || ''; +const BUILD_ID = ARGS['build-id'] || gitDescribe(); /** Build stylesheets */ (() => { diff --git a/bin/git-describe.js b/bin/git-describe.js new file mode 100644 index 000000000..1bde0bcc3 --- /dev/null +++ b/bin/git-describe.js @@ -0,0 +1,19 @@ +#!/usr/bin/env node + +/** Get tag-based description from Git */ +function gitDescribe() { + 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; +} + +module.exports = gitDescribe;