Skip to content

Commit 9246b83

Browse files
suyanlongvipwzw
authored andcommitted
fix: Adjust github action
1 parent b0caccf commit 9246b83

File tree

7 files changed

+106
-52
lines changed

7 files changed

+106
-52
lines changed

.github/workflows/automake.yml

+2-9
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,14 @@ jobs:
3333
fetch-depth: 0
3434
persist-credentials: false # <--- this
3535

36-
- name: compile binary
37-
run: make all-arch
38-
39-
- name : Upload artifact bin
40-
uses: actions/upload-artifact@v2
41-
with:
42-
name: chain33-artifact
43-
path: build/*.tar
44-
4536
- name: Semantic Release
4637
uses: cycjimmy/semantic-release-action@v2
4738
id: semantic
4839
with:
4940
branch: master
5041
extra_plugins: |
42+
@google/semantic-release-replace-plugin
43+
@semantic-release/exec
5144
@semantic-release/changelog
5245
@semantic-release/git
5346
env:

.github/workflows/manual_make_bin.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This is a basic workflow that is manually triggered
2+
name: manually make bin for all branch
3+
4+
# Controls when the action will run. Workflow runs when manually triggered using the UI
5+
# or API.
6+
on: [push,pull_request]
7+
8+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
9+
jobs:
10+
automake:
11+
name: automake
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Set up Golang env
15+
uses: actions/setup-go@v2
16+
with:
17+
go-version: 1.17
18+
id: go
19+
20+
- name: checkout repo
21+
uses: actions/checkout@v2
22+
23+
- name: compile binary
24+
run: make all-arch
25+
26+
- name : Upload artifact bin
27+
uses: actions/upload-artifact@v2
28+
with:
29+
name: chain33-artifact
30+
path: |
31+
build/*.tar.gz
32+
build/*.zip

.github/workflows/release.yml

+2-9
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,14 @@ jobs:
2323
fetch-depth: 0
2424
persist-credentials: false # <--- this
2525

26-
- name: compile binary
27-
run: make all-arch
28-
29-
- name : Upload artifact bin
30-
uses: actions/upload-artifact@v2
31-
with:
32-
name: chain33-artifact
33-
path: build/*.tar
34-
3526
- name: Semantic Release
3627
uses: cycjimmy/semantic-release-action@v2
3728
id: semantic
3829
with:
3930
branch: master
4031
extra_plugins: |
32+
@google/semantic-release-replace-plugin
33+
@semantic-release/exec
4134
@semantic-release/changelog
4235
@semantic-release/git
4336
env:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ plugin/store/mpt/mpt.test
5555
system/store/mavl/1.png
5656
system/store/mavl/cpu.pprof
5757
system/store/mavl/mavl.test
58+
build/CHANGELOG.md

.releaserc.yml

+46-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,48 @@
1-
{ "branches": ["master", "next"],
1+
{ "branches": ["master", "next"],
22
"plugins": [
3-
"@semantic-release/commit-analyzer", #Default 1
4-
"@semantic-release/release-notes-generator", #Default 2
5-
[
6-
"@semantic-release/changelog",
7-
{ "changelogFile": "CHANGELOG.md", "changelogTitle": "changelog" },
8-
],
9-
# "@semantic-release/npm", #Default 3
10-
# "@semantic-release/github", #Default 4
11-
[
12-
"@semantic-release/github",
13-
{"assets": ["build/*.tar"]}
14-
],
15-
"@semantic-release/git",
16-
]
3+
"@semantic-release/commit-analyzer", #Default 1
4+
"@semantic-release/release-notes-generator", #Default 2
5+
[
6+
"@google/semantic-release-replace-plugin",
7+
{
8+
"replacements": [
9+
{
10+
"files": ["common/version/version.go"],
11+
"from": "var Version.*",
12+
"to": 'var Version = "${nextRelease.version}"',
13+
"results": [
14+
{
15+
"file": "common/version/version.go",
16+
"hasChanged": true,
17+
"numMatches": 1,
18+
"numReplacements": 1
19+
}
20+
],
21+
"countMatches": true
22+
}
23+
]
24+
}
25+
],
26+
[
27+
"@semantic-release/changelog",
28+
{ "changelogFile": "CHANGELOG.md", "changelogTitle": "changelog" },
29+
],
30+
# "@semantic-release/npm", #Default 3
31+
# "@semantic-release/github", #Default 4
32+
[
33+
"@semantic-release/github",
34+
{"assets": ["build/*.tar.gz","build/*.zip"]}
35+
],
36+
[
37+
"@semantic-release/git",
38+
{
39+
"assets": ["common/version/version.go","CHANGELOG.md"],
40+
}
41+
],
42+
[
43+
"@semantic-release/exec", {
44+
"prepareCmd": "make all-arch VERSION=${nextRelease.version}"
45+
}
46+
]
47+
]
1748
}

Makefile

+19-16
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ SIGNATORY := build/signatory-server
1414
MINER := build/miner_accounts
1515
AUTOTEST := build/autotest/autotest
1616
SRC_AUTOTEST := github.com/33cn/chain33/cmd/autotest
17-
LDFLAGS := -ldflags '-w -s'
18-
#BUILDTIME=$(shell date -u)
19-
#GitCommit=$(git rev-parse --short=8 HEAD)
20-
BUILD_FLAGS = -ldflags '-X "github.com/33cn/chain33/common/version.GitCommit=$(shell git rev-parse --short=8 HEAD)" \
21-
-X "github.com/33cn/chain33/common/version.BuildTime=[$(shell date +"%Y-%m-%d %H:%M:%S %A")]"'
17+
LDFLAGS := ' -w -s'
18+
BUILDTIME:=$(shell date +"%Y-%m-%d %H:%M:%S %A")
19+
VERSION=$(shell git describe --tags || git rev-parse --short=8 HEAD)
20+
GitCommit=$(shell git rev-parse --short=8 HEAD)
21+
BUILD_FLAGS := -ldflags '-X "github.com/33cn/chain33/common/version.GitCommit=$(GitCommit)" \
22+
-X "github.com/33cn/chain33/common/version.Version=$(VERSION)" \
23+
-X "github.com/33cn/chain33/common/version.BuildTime=[$(BUILDTIME)]"'
24+
2225
MKPATH=$(abspath $(lastword $(MAKEFILE_LIST)))
2326
MKDIR=$(dir $(MKPATH))
2427
DAPP := ""
@@ -46,8 +49,8 @@ build:cli ## Build the binary file
4649
@cp cmd/chain33/bityuan.toml build/
4750

4851
release: ## Build the binary file
49-
@go build $(BUILD_FLAGS) -v -o $(APP) $(LDFLAGS) $(SRC)
50-
@go build $(BUILD_FLAGS) -v -o $(CLI) $(LDFLAGS) $(SRC_CLI)
52+
@go build $(BUILD_FLAGS)$(LDFLAGS) -v -o $(APP) $(SRC)
53+
@go build $(BUILD_FLAGS)$(LDFLAGS) -v -o $(CLI) $(SRC_CLI)
5154
@cp cmd/chain33/chain33.toml build/
5255
@cp cmd/chain33/bityuan.toml build/
5356
# @cp cmd/chain33/chain33.para.toml build/
@@ -60,37 +63,37 @@ PLATFORM_LIST = \
6063
WINDOWS_ARCH_LIST = \
6164
windows-amd64
6265

63-
GOBUILD=go build $(BUILD_FLAGS) $(LDFLAGS)
66+
GOBUILD :=go build $(BUILD_FLAGS)$(LDFLAGS)
6467

6568
darwin-amd64:
6669
GOARCH=amd64 GOOS=darwin $(GOBUILD) -o $(APP)-$@ $(SRC)
6770
GOARCH=amd64 GOOS=darwin $(GOBUILD) -o $(CLI)-$@ $(SRC_CLI)
68-
cp cmd/chain33/chain33.toml build/ && cd build && \
71+
cp cmd/chain33/chain33.toml CHANGELOG.md build/ && cd build && \
6972
chmod +x chain33-darwin-amd64 && \
7073
chmod +x chain33-cli-darwin-amd64 && \
71-
tar -zcvf chain33-darwin-amd64.tar chain33-darwin-amd64 chain33-cli-darwin-amd64 chain33.toml
74+
tar -zcvf chain33-darwin-amd64.tar.gz chain33-darwin-amd64 chain33-cli-darwin-amd64 chain33.toml CHANGELOG.md
7275

7376
darwin-arm64:
7477
GOARCH=arm64 GOOS=darwin $(GOBUILD) -o $(APP)-$@ $(SRC)
7578
GOARCH=arm64 GOOS=darwin $(GOBUILD) -o $(CLI)-$@ $(SRC_CLI)
76-
cp cmd/chain33/chain33.toml build/ && cd build && \
79+
cp cmd/chain33/chain33.toml CHANGELOG.md build/ && cd build && \
7780
chmod +x chain33-darwin-arm64 && \
7881
chmod +x chain33-cli-darwin-arm64 && \
79-
tar -zcvf chain33-darwin-arm64.tar chain33-darwin-arm64 chain33-cli-darwin-arm64 chain33.toml
82+
tar -zcvf chain33-darwin-arm64.tar.gz chain33-darwin-arm64 chain33-cli-darwin-arm64 chain33.toml CHANGELOG.md
8083

8184
linux-amd64:
8285
GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(APP)-$@ $(SRC)
8386
GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(CLI)-$@ $(SRC_CLI)
84-
cp cmd/chain33/chain33.toml build/ && cd build && \
87+
cp cmd/chain33/chain33.toml CHANGELOG.md build/ && cd build && \
8588
chmod +x chain33-linux-amd64 && \
8689
chmod +x chain33-cli-linux-amd64 && \
87-
tar -zcvf chain33-linux-amd64.tar chain33-linux-amd64 chain33-cli-linux-amd64 chain33.toml
90+
tar -zcvf chain33-linux-amd64.tar.gz chain33-linux-amd64 chain33-cli-linux-amd64 chain33.toml CHANGELOG.md
8891

8992
windows-amd64:
9093
GOARCH=amd64 GOOS=windows $(GOBUILD) -o $(APP)-$@.exe $(SRC)
9194
GOARCH=amd64 GOOS=windows $(GOBUILD) -o $(CLI)-$@.exe $(SRC_CLI)
92-
cp cmd/chain33/chain33.toml build/ && cd build && \
93-
tar -zcvf chain33-windows-amd64.tar chain33-windows-amd64.exe chain33-cli-windows-amd64.exe chain33.toml
95+
cp cmd/chain33/chain33.toml CHANGELOG.md build/ && cd build && \
96+
zip -j chain33-windows-amd64.zip chain33-windows-amd64.exe chain33-cli-windows-amd64.exe chain33.toml CHANGELOG.md
9497

9598
all-arch: $(PLATFORM_LIST) $(WINDOWS_ARCH_LIST)
9699

common/version/version.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// Package version 软件版本号
66
package version
77

8-
const version = "1.65.4"
8+
//Version chain33 version
9+
var Version = "1.65.4"
910

1011
//var version key
1112
var (
@@ -31,9 +32,9 @@ func GetLocalDBKeyList() [][]byte {
3132
//GetVersion 获取版本信息
3233
func GetVersion() string {
3334
if GitCommit != "" {
34-
return version + "-" + GitCommit
35+
return Version + "-" + GitCommit
3536
}
36-
return version
37+
return Version
3738
}
3839

3940
//GetLocalDBVersion 数据库版本解析

0 commit comments

Comments
 (0)