mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-19 16:52:25 +00:00
Add version checks
This commit is contained in:
parent
f151e5fbe3
commit
b615b4d474
26
.drone.yml
26
.drone.yml
@ -35,28 +35,6 @@ trigger:
|
||||
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Check If Release
|
||||
|
||||
# Limits how many of these builds can run on the drone runner at a time, this isn't about cores
|
||||
concurrency:
|
||||
limit: 1
|
||||
|
||||
steps:
|
||||
- name: Init
|
||||
image: akkadius/eqemu-server:v11
|
||||
commands:
|
||||
- if [ $(curl -s "https://api.github.com/repos/eqemu/server/tags" | jq -r '.[0].name' | sed 's/v//') = $(cat package.json | jq -r '.version') ]; then echo "Version tag is same as latest release exiting build"; exit 1; else echo "Local version different from remote, building..."; fi
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- akkadius/build-test
|
||||
event:
|
||||
- push
|
||||
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Build Linux Binaries
|
||||
@ -74,6 +52,7 @@ steps:
|
||||
- name: Init
|
||||
image: akkadius/eqemu-server:v11
|
||||
commands:
|
||||
- ./utils/scripts/build/should-release/should-release
|
||||
- sudo chown eqemu:eqemu /drone/src/ * -R
|
||||
- sudo chown eqemu:eqemu /home/eqemu/.ccache/ * -R
|
||||
- git submodule init && git submodule update
|
||||
@ -135,6 +114,7 @@ platform:
|
||||
steps:
|
||||
- name: init
|
||||
commands:
|
||||
- ./utils/scripts/build/should-release/should-release.exe
|
||||
- git submodule init
|
||||
- git submodule update
|
||||
- name: Windows x64
|
||||
@ -185,6 +165,7 @@ steps:
|
||||
GH_RELEASE_GITHUB_API_TOKEN:
|
||||
from_secret: GH_RELEASE_GITHUB_API_TOKEN
|
||||
commands:
|
||||
- ./utils/scripts/build/should-release/should-release
|
||||
- rclone config create remote ftp env_auth true > /dev/null
|
||||
- |
|
||||
rclone copy remote: --include "eqemu-server*.zip" .
|
||||
@ -193,7 +174,6 @@ steps:
|
||||
rclone delete remote: --include "eqemu-server*.zip"
|
||||
|
||||
depends_on:
|
||||
- Check If Release
|
||||
- Build Windows Binaries
|
||||
- Build Linux Binaries
|
||||
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@ -64,5 +64,7 @@ compile_flags.txt
|
||||
# vscode generated settings
|
||||
.vscode/
|
||||
|
||||
|
||||
# Build pipeline
|
||||
!utils/scripts/build/
|
||||
!utils/scripts/build/should-release/should-release
|
||||
!utils/scripts/build/should-release/should-release.exe
|
||||
|
||||
16
utils/scripts/build/should-release/go.mod
Normal file
16
utils/scripts/build/should-release/go.mod
Normal file
@ -0,0 +1,16 @@
|
||||
module should-release
|
||||
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/google/go-github/v41 v41.0.0
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/golang/protobuf v1.3.2 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
)
|
||||
29
utils/scripts/build/should-release/go.sum
Normal file
29
utils/scripts/build/should-release/go.sum
Normal file
@ -0,0 +1,29 @@
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-github/v41 v41.0.0 h1:HseJrM2JFf2vfiZJ8anY2hqBjdfY1Vlj/K27ueww4gg=
|
||||
github.com/google/go-github/v41 v41.0.0/go.mod h1:XgmCA5H323A9rtgExdTcnDkcqp6S30AVACCBDOonIxg=
|
||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
77
utils/scripts/build/should-release/main.go
Normal file
77
utils/scripts/build/should-release/main.go
Normal file
@ -0,0 +1,77 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/google/go-github/v41/github"
|
||||
"golang.org/x/oauth2"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type PackageJson struct {
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
Repository struct {
|
||||
Type string `json:"type"`
|
||||
URL string `json:"url"`
|
||||
} `json:"repository"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
// get latest release from github
|
||||
client := github.NewClient(nil)
|
||||
if len(os.Getenv("GITHUB_TOKEN")) > 0 {
|
||||
ts := oauth2.StaticTokenSource(
|
||||
&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")},
|
||||
)
|
||||
tc := &http.Client{
|
||||
Transport: &oauth2.Transport{
|
||||
Source: ts,
|
||||
},
|
||||
}
|
||||
client = github.NewClient(tc)
|
||||
}
|
||||
|
||||
release, _, err := client.Repositories.GetLatestRelease(context.Background(), "EQEmu", "Server")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
version := strings.ReplaceAll(*release.TagName, "v", "")
|
||||
|
||||
// get current version from package.json
|
||||
currentLevel := filepath.Join("./package.json")
|
||||
packageJsonFile := currentLevel
|
||||
if _, err := os.Stat(currentLevel); errors.Is(err, os.ErrNotExist) {
|
||||
packageJsonFile = ""
|
||||
// this is only really needed when developing this binary
|
||||
walkUpToRoot := filepath.Join("../../../../package.json")
|
||||
if _, err := os.Stat(walkUpToRoot); err == nil {
|
||||
// path/to/whatever exists
|
||||
packageJsonFile = walkUpToRoot
|
||||
}
|
||||
}
|
||||
|
||||
if len(packageJsonFile) == 0 {
|
||||
fmt.Printf("Could not find package.json\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
packageJson, err := os.ReadFile(packageJsonFile)
|
||||
var p PackageJson
|
||||
_ = json.Unmarshal(packageJson, &p)
|
||||
|
||||
// version compare
|
||||
if p.Version == version {
|
||||
fmt.Printf("Version [%v] already exists. No need to release\n", version)
|
||||
fmt.Printf("Exiting code 78 to halt pipeline steps gracefully\n")
|
||||
os.Exit(78)
|
||||
}
|
||||
}
|
||||
BIN
utils/scripts/build/should-release/should-release
Executable file
BIN
utils/scripts/build/should-release/should-release
Executable file
Binary file not shown.
BIN
utils/scripts/build/should-release/should-release.exe
Executable file
BIN
utils/scripts/build/should-release/should-release.exe
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user