[CI/CD] Build / Release Pipeline Changes (#2788)

* Test

* Test

* Update windows-build.ps1

* Update windows-build.ps1

* Update windows-build.ps1

* Kill excessive warnings

* Split

* Remove 7z from build scripts

* Linux

* Update .drone.yml

* Update .drone.yml

* Update .drone.yml

* Update .drone.yml

* Test

* Update .drone.yml

* Naming

* Test upload

* Update .drone.yml

* Update .drone.yml

* Update .drone.yml

* Yolo

* Yolo

* Update .drone.yml

* Update .drone.yml

* Copy

* Yolo

* Release without bots

* Update .drone.yml

* Update .drone.yml

* Test pipeline

* Remove debug

* Update .drone.yml

* Filter pipeline stage

* Update .drone.yml

* Test

* Bots release 22.0.5 (Test)

* Release bot test #2

* Check if release

* Update .drone.yml

* Update .drone.yml

* exit 78

* Update .drone.yml

* Update .drone.yml

* Add version checks

* Update .drone.yml

* Update .drone.yml

* Test

* Update build-release.bat

* Update .drone.yml

* Update .drone.yml

* Update .drone.yml

* Update build-release.bat

* Update build-release.bat

* Test pipeline

* Update CHANGELOG.md

* Bump

* Update build-release.bat

* Update build-release.bat

* Shuffle

* Take #45354

* Update windows-build.ps1

* Update windows-build.ps1

* Update windows-build.ps1

* F

* Update windows-build.ps1

* Consolidate

* Run it

* Pop cache back in

* Update linux-build.sh

* Another release test

* Update linux-build.sh

* Update linux-build.sh

* Update CMakeLists.txt

* Trim windows assets

* Update windows-build.ps1

* Update windows-build.ps1

* Update windows-build.ps1

* Update windows-build.ps1

* [22.1.0] Release

* Crash reporting

* Add version tag injection in the build pipeline

* Update windows-build.ps1

* Test

* Test

* Update windows-build.ps1

* Update windows-build.ps1

* Update windows-build.ps1

* Kill excessive warnings

* Split

* Remove 7z from build scripts

* Linux

* Update .drone.yml

* Update .drone.yml

* Update .drone.yml

* Update .drone.yml

* Test

* Update .drone.yml

* Naming

* Test upload

* Update .drone.yml

* Update .drone.yml

* Update .drone.yml

* Yolo

* Yolo

* Update .drone.yml

* Update .drone.yml

* Copy

* Yolo

* Release without bots

* Update .drone.yml

* Update .drone.yml

* Test pipeline

* Remove debug

* Update .drone.yml

* Filter pipeline stage

* Update .drone.yml

* Test

* Bots release 22.0.5 (Test)

* Release bot test #2

* Check if release

* Update .drone.yml

* Update .drone.yml

* exit 78

* Update .drone.yml

* Update .drone.yml

* Add version checks

* Update .drone.yml

* Update .drone.yml

* Test

* Update build-release.bat

* Update .drone.yml

* Update .drone.yml

* Update .drone.yml

* Update build-release.bat

* Update build-release.bat

* Test pipeline

* Update CHANGELOG.md

* Bump

* Update build-release.bat

* Update build-release.bat

* Shuffle

* Take #45354

* Update windows-build.ps1

* Update windows-build.ps1

* Update windows-build.ps1

* F

* Update windows-build.ps1

* Consolidate

* Run it

* Pop cache back in

* Update linux-build.sh

* Another release test

* Update linux-build.sh

* Update linux-build.sh

* Update CMakeLists.txt

* Trim windows assets

* Update windows-build.ps1

* Update windows-build.ps1

* Update windows-build.ps1

* Update windows-build.ps1

* [22.1.0] Release

* Crash reporting

* Add version tag injection in the build pipeline

* Update windows-build.ps1

* Full crash report on windows.

* Update endpoint

* [22.1.1] Release

* [skip ci] update .drone.yml

* Filter

* Update .drone.yml

* Update .drone.yml

* Update .drone.yml

* Update .drone.yml

* Update .drone.yml

* Update CHANGELOG.md

Co-authored-by: KimLS <KimLS@peqtgc.com>
This commit is contained in:
Chris Miles
2023-01-24 16:37:04 -06:00
committed by GitHub
parent 8c12f7b431
commit 08c8393988
19 changed files with 1147 additions and 70 deletions
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash
set -x
sudo chown eqemu:eqemu /drone/src/ * -R
sudo chown eqemu:eqemu /home/eqemu/.ccache/ * -R
git submodule init && git submodule update
perl utils/scripts/build/tag-version.pl
mkdir -p build && cd build && cmake -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_LUA=ON -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="-Os" -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G 'Unix Makefiles' .. && make -j$((`nproc`-4))
curl https://raw.githubusercontent.com/Akkadius/eqemu-install-v2/master/eqemu_config.json --output eqemu_config.json
./bin/tests
# shellcheck disable=SC2164
cd /drone/src/
chmod +x ./utils/scripts/build/should-release/should-release
./utils/scripts/build/should-release/should-release || exit
rm ./build/bin/*.a
zip -j eqemu-server-linux-x64.zip ./build/bin/*
# shellcheck disable=SC2010
ls -lsh | grep zip
sudo apt-get update && sudo apt-get install -y rclone
rclone config create remote ftp env_auth true > /dev/null
rclone copy eqemu-server-linux-x64.zip remote:
rclone ls remote:
+24
View File
@@ -0,0 +1,24 @@
#############################################
# debian
#############################################
FROM debian:11-slim
#############################################
# basics
#############################################
RUN apt-get update && apt-get install -y \
rclone \
git \
make \
jq \
wget \
curl
#############################################
# node
#############################################
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash && \
apt-get update && apt-get install -y nodejs && rm -rf /var/lib/apt/lists/*
RUN npm install -g gh-release
+16
View 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
View 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=
@@ -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)
}
}
Binary file not shown.
Binary file not shown.
+61
View File
@@ -0,0 +1,61 @@
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
open my $fh, '<', './package.json' or die "Can't open file $!";
my $package_json = do {
local $/;
<$fh>
};
my $version = "";
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
# manually parse because we can't guarantee json module is available
# it's jank but it's quick and dirty
# this is only used in the build pipeline
foreach my $line (split("\n", $package_json)) {
if ($line =~ /version/i) {
$version = $line;
$version =~ s/version//g;
$version =~ s/://g;
$version =~ s/"//g;
$version =~ s/,//g;
$version = trim($version);
}
}
print "Version is [" . $version . "]\n";
# server version file
my $version_file_name = "./common/version.h";
open my $vfh, '<', $version_file_name or die "Can't open file $!";
my $version_file = do {
local $/;
<$vfh>
};
# write new version
my $new_version_file = "";
foreach my $line (split("\n", $version_file)) {
if ($line =~ /CURRENT_VERSION/i) {
my @s = split("\"", $line);
if ($#s == 2) {
$line =~ s/$s[1]/$version/g;
}
}
$new_version_file .= $line . "\n";
}
open(my $wfh, '>', $version_file_name) or die "Could not open file '$version_file_name' $!";
print $wfh $new_version_file;
close $wfh;
print $new_version_file;
+49
View File
@@ -0,0 +1,49 @@
try
{
$cwd = Get-Location
Set-Location -Path "$cwd"
git submodule init
git submodule update
if (![System.IO.Directory]::Exists("$cwd\win-build-x64"))
{
Write-Information -MessageData "Creating build x64 folder" -InformationAction Continue
New-Item -Path "$cwd\win-build-x64" -ItemType Directory
}
perl .\utils\scripts\build\tag-version.pl
Write-Information -MessageData "Creating build x64" -InformationAction Continue
Set-Location -Path "$cwd\win-build-x64"
cmake -Wno-dev -G "Visual Studio 17 2022" -A x64 -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_ZLIB=ON "$cwd"
cmake --build . --config RelWithDebInfo --clean-first
Set-Location -Path "$cwd"
.\utils\scripts\build\should-release\should-release.exe; if ($LASTEXITCODE -ne 0) { exit }
# trim some fat
del $cwd\win-build-x64\bin\RelWithDebInfo\export_client_files.pdb
del $cwd\win-build-x64\bin\RelWithDebInfo\import_client_files.pdb
del $cwd\win-build-x64\bin\RelWithDebInfo\shared_memory.pdb
del $cwd\win-build-x64\bin\RelWithDebInfo\queryserv.pdb
del $cwd\win-build-x64\bin\RelWithDebInfo\eqlaunch.pdb
del $cwd\win-build-x64\bin\RelWithDebInfo\cppunit.pdb
del $cwd\win-build-x64\bin\RelWithDebInfo\tests.pdb
del $cwd\win-build-x64\bin\RelWithDebInfo\tests.exe
7z a eqemu-server-windows-x64.zip $cwd\win-build-x64\bin\RelWithDebInfo\*.exe $cwd\win-build-x64\bin\RelWithDebInfo\*.dll $cwd\win-build-x64\bin\RelWithDebInfo\*.pdb $cwd\win-build-x64\libs\zlibng\RelWithDebInfo\*.dll $cwd\win-build-x64\libs\zlibng\RelWithDebInfo\*.pdb
dir *.zip
rclone config create remote ftp env_auth true
rclone copy eqemu-server-windows-x64.zip remote:
rclone ls remote:
}
catch
{
Write-Host ("Caught signal to end")
Write-Host $_
}