Merge pull request #3354 from JoeKar/feature/action-nightly

workflows: General improvements
This commit is contained in:
Jöran Karl
2024-06-20 23:24:51 +02:00
committed by GitHub
3 changed files with 22 additions and 9 deletions

View File

@@ -1,7 +1,8 @@
name: Nightly builds
on:
workflow_dispatch: # Allows manual trigger
schedule:
- cron: '0 0 * * *'
- cron: '0 0 * * *'
jobs:
nightly:
strategy:
@@ -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

View File

@@ -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: |

View File

@@ -4,6 +4,7 @@ package main
import (
"fmt"
"log"
"os/exec"
"strings"
@@ -19,13 +20,17 @@ 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
@@ -33,15 +38,12 @@ func getTag(match ...string) (string, *semver.PRVersion) {
}
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
}
@@ -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 {