From 225ba6148cf18527c35498b97a7fa43f6fbd69fd Mon Sep 17 00:00:00 2001 From: Aldo Lacuku Date: Wed, 10 Apr 2024 15:06:45 +0200 Subject: [PATCH] update(CI): change release tag format Signed-off-by: Aldo Lacuku --- .github/workflows/release.yml | 9 ++++----- build/utils/version.go | 11 ++++++++--- release.md | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) mode change 100644 => 100755 build/utils/version.go diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 24f4b897..ac943dfd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,14 +18,13 @@ jobs: package: ${{ steps.regex-match.outputs.group1 }} steps: - - name: Extract semver ℹ️ + - name: Validate tag ℹ️ uses: actions-ecosystem/action-regex-match@v2 - id: regex-match with: text: ${{ github.ref_name }} - regex: '^([a-z]+[a-z0-9_\-]*)-(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?$' - - - name: Fail on non semver tag + regex: '^plugins\/([a-z0-9_-]+)\/v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$' + + - name: Fail on invalid tag if: steps.regex-match.outputs.match == '' run: exit 1 diff --git a/build/utils/version.go b/build/utils/version.go old mode 100644 new mode 100755 index 0577840d..c7c5387c --- a/build/utils/version.go +++ b/build/utils/version.go @@ -163,13 +163,18 @@ func main() { var hash string // get last tag - tags, err := git("describe", "--tags", "--abbrev=0", "--match", name+`-[0-9].[0-9].[0-9]*`) + // It matches the old tag in "pluginName-version" or the new one "plugins/pluginName/semver" + tags, err := git("describe", "--tags", "--abbrev=0", "--match", name+`-[0-9]*`, "--match", "plugins/"+name+"/v*") if err == nil { if len(tags) == 0 { fail(errors.New("no git tag found for: " + name)) } lastTag := tags[0] - lastVer = strings.Replace(lastTag, name+"-", "", 1) + if strings.HasPrefix(lastTag, name) { + lastVer = strings.Replace(lastTag, name+"-", "", 1) + } else { + lastVer = strings.Replace(lastTag, "plugins/"+name+"/v", "", 1) + } if !rgxVersion.MatchString(lastVer) { fail(errors.New("plugin latest released version not compatible with SemVer: " + lastTag)) } @@ -200,7 +205,7 @@ func main() { } else { // stable versions MUST have a precise tag matching plugin name and version - expectedTag := name + "-" + version + expectedTag := "plugins/" + name + "/v" + version tags, err := git("--no-pager", "tag", "--points-at", "HEAD") if err != nil { fail(err) diff --git a/release.md b/release.md index cd28fb1a..a8850ae6 100644 --- a/release.md +++ b/release.md @@ -15,9 +15,9 @@ Artifacts will be published at https://download.falco.org/?prefix=plugins/. For Since the *plugins* repository is a [monorepo](https://en.wikipedia.org/wiki/Monorepo), we introduced a special convention for tagging release versions, so that we can differentiate among plugins. Git tag MUST respect the following format: -*name*-*version* +*plugins*/**name**/*v***version** e.x: plugins/cloudtrail/v1.2.3 -Where *name* is the plugin name (must match a folder under [./plugins](./plugins)) and *version* is the plugin version to be released (must match the version string declared by the plugin). +Where **name** is the plugin name (must match a folder under [./plugins](./plugins)) and **version** is the plugin version to be released (must match the version string declared by the plugin). ## Release a plugin (stable build only)