Skip to content

Commit

Permalink
update(CI): change release tag format
Browse files Browse the repository at this point in the history
Signed-off-by: Aldo Lacuku <aldo@lacuku.eu>
  • Loading branch information
alacuku authored and poiana committed Apr 12, 2024
1 parent 155732c commit 225ba61
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 8 additions & 3 deletions build/utils/version.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions release.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 225ba61

Please sign in to comment.