Skip to content

Commit

Permalink
Merge pull request #3354 from JoeKar/feature/action-nightly
Browse files Browse the repository at this point in the history
workflows: General improvements
  • Loading branch information
JoeKar authored Jun 20, 2024
2 parents a3e25e3 + 531c7d8 commit 0fa4a3a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Nightly builds
on:
workflow_dispatch: # Allows manual trigger
schedule:
- cron: '0 0 * * *'
- cron: '0 0 * * *'
jobs:
nightly:
strategy:
Expand All @@ -14,11 +15,14 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: false

- name: Checkout
uses: actions/checkout@v4
with:
ref: master
fetch-depth: 0
fetch-tags: true

- name: Build
run: tools/cross-compile.sh
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
cache: false

- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Build
run: |
Expand Down
16 changes: 10 additions & 6 deletions tools/build-version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package main

import (
"fmt"
"log"
"os/exec"
"strings"

Expand All @@ -19,29 +20,30 @@ func getTag(match ...string) (string, *semver.PRVersion) {
} else {
tagParts := strings.Split(string(tag), "-")
if len(tagParts) == 3 {
if ahead, err := semver.NewPRVersion(tagParts[1]); err == nil {
ahead, err := semver.NewPRVersion(tagParts[1])
if err == nil {
return tagParts[0], &ahead
}
log.Printf("semver.NewPRVersion(%s): %v", tagParts[1], err)
} else if len(tagParts) == 4 {
if ahead, err := semver.NewPRVersion(tagParts[2]); err == nil {
ahead, err := semver.NewPRVersion(tagParts[2])
if err == nil {
return tagParts[0] + "-" + tagParts[1], &ahead
}
log.Printf("semver.NewPRVersion(%s): %v", tagParts[2], err)
}

return string(tag), nil
}
}

func main() {
if tags, err := exec.Command("git", "tag").Output(); err != nil || len(tags) == 0 {
// no tags found -- fetch them
exec.Command("git", "fetch", "--tags").Run()
}
// Find the last vX.X.X Tag and get how many builds we are ahead of it.
versionStr, ahead := getTag("--match", "v*")
version, err := semver.ParseTolerant(versionStr)
if err != nil {
// no version tag found so just return what ever we can find.
log.Printf("semver.ParseTolerant(%s): %v", versionStr, err)
fmt.Println("0.0.0-unknown")
return
}
Expand All @@ -66,6 +68,8 @@ func main() {
if pr, err := semver.NewPRVersion(tag); err == nil {
// append the tag as pre-release name
version.Pre = append(version.Pre, pr)
} else {
log.Printf("semver.NewPRVersion(%s): %v", tag, err)
}

if ahead != nil {
Expand Down

0 comments on commit 0fa4a3a

Please sign in to comment.