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 name: Nightly builds
on: on:
workflow_dispatch: # Allows manual trigger
schedule: schedule:
- cron: '0 0 * * *' - cron: '0 0 * * *'
jobs: jobs:
nightly: nightly:
strategy: strategy:
@@ -14,11 +15,14 @@ jobs:
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version: ${{ matrix.go-version }} go-version: ${{ matrix.go-version }}
cache: false
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: master ref: master
fetch-depth: 0
fetch-tags: true
- name: Build - name: Build
run: tools/cross-compile.sh run: tools/cross-compile.sh

View File

@@ -8,10 +8,15 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/setup-go@v3 - uses: actions/setup-go@v5
with: with:
go-version: ${{ matrix.go-version }} go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3 cache: false
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Build - name: Build
run: | run: |

View File

@@ -4,6 +4,7 @@ package main
import ( import (
"fmt" "fmt"
"log"
"os/exec" "os/exec"
"strings" "strings"
@@ -19,13 +20,17 @@ func getTag(match ...string) (string, *semver.PRVersion) {
} else { } else {
tagParts := strings.Split(string(tag), "-") tagParts := strings.Split(string(tag), "-")
if len(tagParts) == 3 { 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 return tagParts[0], &ahead
} }
log.Printf("semver.NewPRVersion(%s): %v", tagParts[1], err)
} else if len(tagParts) == 4 { } 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 return tagParts[0] + "-" + tagParts[1], &ahead
} }
log.Printf("semver.NewPRVersion(%s): %v", tagParts[2], err)
} }
return string(tag), nil return string(tag), nil
@@ -33,15 +38,12 @@ func getTag(match ...string) (string, *semver.PRVersion) {
} }
func main() { 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. // Find the last vX.X.X Tag and get how many builds we are ahead of it.
versionStr, ahead := getTag("--match", "v*") versionStr, ahead := getTag("--match", "v*")
version, err := semver.ParseTolerant(versionStr) version, err := semver.ParseTolerant(versionStr)
if err != nil { if err != nil {
// no version tag found so just return what ever we can find. // 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") fmt.Println("0.0.0-unknown")
return return
} }
@@ -66,6 +68,8 @@ func main() {
if pr, err := semver.NewPRVersion(tag); err == nil { if pr, err := semver.NewPRVersion(tag); err == nil {
// append the tag as pre-release name // append the tag as pre-release name
version.Pre = append(version.Pre, pr) version.Pre = append(version.Pre, pr)
} else {
log.Printf("semver.NewPRVersion(%s): %v", tag, err)
} }
if ahead != nil { if ahead != nil {