Skip to content

Commit 0fa4a3a

Browse files
authored
Merge pull request zyedidia#3354 from JoeKar/feature/action-nightly
workflows: General improvements
2 parents a3e25e3 + 531c7d8 commit 0fa4a3a

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

.github/workflows/nightly.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name: Nightly builds
22
on:
3+
workflow_dispatch: # Allows manual trigger
34
schedule:
4-
- cron: '0 0 * * *'
5+
- cron: '0 0 * * *'
56
jobs:
67
nightly:
78
strategy:
@@ -14,11 +15,14 @@ jobs:
1415
uses: actions/setup-go@v5
1516
with:
1617
go-version: ${{ matrix.go-version }}
18+
cache: false
1719

1820
- name: Checkout
1921
uses: actions/checkout@v4
2022
with:
2123
ref: master
24+
fetch-depth: 0
25+
fetch-tags: true
2226

2327
- name: Build
2428
run: tools/cross-compile.sh

.github/workflows/test.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ jobs:
88
os: [ubuntu-latest, macos-latest, windows-latest]
99
runs-on: ${{ matrix.os }}
1010
steps:
11-
- uses: actions/setup-go@v3
11+
- uses: actions/setup-go@v5
1212
with:
1313
go-version: ${{ matrix.go-version }}
14-
- uses: actions/checkout@v3
14+
cache: false
15+
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
fetch-tags: true
1520

1621
- name: Build
1722
run: |

tools/build-version.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package main
44

55
import (
66
"fmt"
7+
"log"
78
"os/exec"
89
"strings"
910

@@ -19,29 +20,30 @@ func getTag(match ...string) (string, *semver.PRVersion) {
1920
} else {
2021
tagParts := strings.Split(string(tag), "-")
2122
if len(tagParts) == 3 {
22-
if ahead, err := semver.NewPRVersion(tagParts[1]); err == nil {
23+
ahead, err := semver.NewPRVersion(tagParts[1])
24+
if err == nil {
2325
return tagParts[0], &ahead
2426
}
27+
log.Printf("semver.NewPRVersion(%s): %v", tagParts[1], err)
2528
} else if len(tagParts) == 4 {
26-
if ahead, err := semver.NewPRVersion(tagParts[2]); err == nil {
29+
ahead, err := semver.NewPRVersion(tagParts[2])
30+
if err == nil {
2731
return tagParts[0] + "-" + tagParts[1], &ahead
2832
}
33+
log.Printf("semver.NewPRVersion(%s): %v", tagParts[2], err)
2934
}
3035

3136
return string(tag), nil
3237
}
3338
}
3439

3540
func main() {
36-
if tags, err := exec.Command("git", "tag").Output(); err != nil || len(tags) == 0 {
37-
// no tags found -- fetch them
38-
exec.Command("git", "fetch", "--tags").Run()
39-
}
4041
// Find the last vX.X.X Tag and get how many builds we are ahead of it.
4142
versionStr, ahead := getTag("--match", "v*")
4243
version, err := semver.ParseTolerant(versionStr)
4344
if err != nil {
4445
// no version tag found so just return what ever we can find.
46+
log.Printf("semver.ParseTolerant(%s): %v", versionStr, err)
4547
fmt.Println("0.0.0-unknown")
4648
return
4749
}
@@ -66,6 +68,8 @@ func main() {
6668
if pr, err := semver.NewPRVersion(tag); err == nil {
6769
// append the tag as pre-release name
6870
version.Pre = append(version.Pre, pr)
71+
} else {
72+
log.Printf("semver.NewPRVersion(%s): %v", tag, err)
6973
}
7074

7175
if ahead != nil {

0 commit comments

Comments
 (0)