Compare commits

..

4 Commits

Author SHA1 Message Date
HAOYUatHZ
34c3b91fd7 feat(coordinator): print version at startup (#800)
Co-authored-by: HAOYUatHZ <HAOYUatHZ@users.noreply.github.com>
2023-08-16 12:23:36 +08:00
HAOYUatHZ
3adf077070 ci: update auto bump workflow (#798)
Co-authored-by: HAOYUatHZ <HAOYUatHZ@users.noreply.github.com>
2023-08-16 11:20:41 +08:00
yqrashawn
2a4d6e05a1 ci: auto version bump when not bumped manually (#792)
Signed-off-by: yqrashawn <namy.19@gmail.com>
Co-authored-by: yqrashawn <yqrashawn@users.noreply.github.com>
2023-08-16 11:03:24 +08:00
Péter Garamvölgyi
0ee99024bb fix: use correct format for balance check error (#795) 2023-08-15 22:44:57 +08:00
6 changed files with 109 additions and 4 deletions

37
.github/scripts/bump_version_dot_go.mjs vendored Normal file
View File

@@ -0,0 +1,37 @@
import { URL } from "url";
import { readFileSync, writeFileSync } from "fs";
const versionFilePath = new URL(
"../../common/version/version.go",
import.meta.url
).pathname;
const versionFileContent = readFileSync(versionFilePath, { encoding: "utf-8" });
const currentVersion = versionFileContent.match(
/var tag = "(?<version>v(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+))"/
);
try {
parseInt(currentVersion.groups.major);
parseInt(currentVersion.groups.minor);
parseInt(currentVersion.groups.patch);
} catch (err) {
console.error(new Error("Failed to parse version in version.go file"));
throw err;
}
// prettier-ignore
const newVersion = `v${currentVersion.groups.major}.${currentVersion.groups.minor}.${parseInt(currentVersion.groups.patch) + 1}`;
console.log(
`Bump version from ${currentVersion.groups.version} to ${newVersion}`
);
writeFileSync(
versionFilePath,
versionFileContent.replace(
`var tag = "${currentVersion.groups.version}"`,
`var tag = "${newVersion}"`
)
);

61
.github/workflows/bump_version.yml vendored Normal file
View File

@@ -0,0 +1,61 @@
name: Bump Version
on:
pull_request:
branches: [develop]
types:
- opened
- reopened
- synchronize
- ready_for_review
jobs:
check:
runs-on: ubuntu-latest
outputs:
check-result: ${{ steps.check-diff.outputs.result }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: check diff
id: check-diff
run: |
set -euo pipefail
# fetch develop branch so that we can diff against later
git fetch origin develop
echo 'checking verion changes in diff...'
# check if version changed in version.go
# note: the grep will fail if use \d instead of [0-9]
git diff HEAD..origin/develop --text --no-ext-diff --unified=0 --no-prefix common/version/version.go | grep -E '^\+var tag = "v[0-9]+\.[0-9]+\.[0-9]+"$' && true
exit_code=$?
# auto bump if version is not bumped manually
echo '> require auto version bump?'
if [ $exit_code -eq 0 ]; then
echo '> no, already bumped'
echo "result=no-bump" >> "$GITHUB_OUTPUT"
else
echo '> yes'
echo "result=bump" >> "$GITHUB_OUTPUT"
fi
bump:
runs-on: ubuntu-latest
needs: check
if: needs.check.outputs.check-result == 'bump'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: bump version in common/version/version.go
run: node .github/scripts/bump_version_dot_go.mjs
- uses: stefanzweifel/git-auto-commit-action@3ea6ae190baf489ba007f7c92608f33ce20ef04a
with:
commit_message: "chore: auto version bump[bot]"

View File

@@ -488,7 +488,7 @@ func (s *Sender) loop(ctx context.Context) {
case <-checkBalanceTicker.C:
// Check and set balance.
if err := s.checkBalance(ctx); err != nil {
log.Error("check balance, err: %w", err)
log.Error("check balance error", "err", err)
}
case <-ctx.Done():
return

View File

@@ -6,7 +6,7 @@ import (
"strings"
)
var tag = "v4.1.46"
var tag = "v4.1.49"
var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {

View File

@@ -71,6 +71,11 @@ func action(ctx *cli.Context) error {
apiSrv := apiServer(ctx, cfg, db, registry)
log.Info(
"coordinator start successfully",
"version", version.Version,
)
// Catch CTRL-C to ensure a graceful shutdown.
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, os.Interrupt)

View File

@@ -52,9 +52,11 @@ func action(ctx *cli.Context) error {
r.Start()
defer r.Stop()
log.Info("prover start successfully",
log.Info(
"prover start successfully",
"name", cfg.ProverName, "type", cfg.Core.ProofType,
"publickey", r.PublicKey(), "version", version.Version)
"publickey", r.PublicKey(), "version", version.Version,
)
// Catch CTRL-C to ensure a graceful shutdown.
interrupt := make(chan os.Signal, 1)