-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
51 lines (37 loc) · 1.21 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"os"
"strconv"
"github.com/gandarez/semver-action/cmd/generate"
"github.com/gandarez/semver-action/pkg/actions"
"github.com/apex/log"
"github.com/apex/log/handlers/cli"
)
func main() {
log.SetHandler(cli.Default)
result, err := generate.Run()
if err != nil {
log.Fatalf("failed to generate semver version: %s\n", err)
}
outputFilepath := os.Getenv("GITHUB_OUTPUT")
// Print previous tag.
log.Infof("PREVIOUS_TAG: %s", result.PreviousTag)
if err := actions.SetOutput(outputFilepath, "PREVIOUS_TAG", result.PreviousTag); err != nil {
log.Fatalf("%s\n", err)
}
// Print ancestor tag.
log.Infof("ANCESTOR_TAG: %s", result.AncestorTag)
if err := actions.SetOutput(outputFilepath, "ANCESTOR_TAG", result.AncestorTag); err != nil {
log.Fatalf("%s\n", err)
}
// Print calculated semver tag.
log.Infof("SEMVER_TAG: %s", result.SemverTag)
if err := actions.SetOutput(outputFilepath, "SEMVER_TAG", result.SemverTag); err != nil {
log.Fatalf("%s\n", err)
}
// Print is prerelease.
log.Infof("IS_PRERELEASE: %v", result.IsPrerelease)
if err := actions.SetOutput(outputFilepath, "IS_PRERELEASE", strconv.FormatBool(result.IsPrerelease)); err != nil {
log.Fatalf("%s\n", err)
}
}