-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from even0306/dev
添加编译测试工作流
- Loading branch information
Showing
4 changed files
with
94 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Build Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "**/*.go" | ||
- "go.mod" | ||
- "go.sum" | ||
- ".github/workflows/*.yml" | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
paths: | ||
- "**/*.go" | ||
- "go.mod" | ||
- "go.sum" | ||
- ".github/workflows/*.yml" | ||
|
||
jobs: | ||
build: | ||
permissions: | ||
contents: write | ||
strategy: | ||
matrix: | ||
# Include amd64 on all platforms. | ||
goos: [linux] | ||
goarch: [amd64, arm64] | ||
include: | ||
# BEGIN Linux ARM64 | ||
- goos: linux | ||
goarch: arm64 | ||
# END Linux ARM64 | ||
# BEGIN Linux AMD64 | ||
- goos: linux | ||
goarch: amd64 | ||
# END Linux AMD64 | ||
fail-fast: false | ||
|
||
runs-on: ubuntu-latest | ||
env: | ||
GOOS: ${{ matrix.goos }} | ||
GOARCH: ${{ matrix.goarch }} | ||
GOARM: ${{ matrix.goarm }} | ||
CGO_ENABLED: 0 | ||
steps: | ||
- name: Checkout codebase | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
|
||
- name: Show workflow information | ||
run: | | ||
export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json) | ||
export VERSIONNUM=$(cat main.go | grep "version :=" | awk -F "\"" '{print $2}') | ||
echo "GOOS: $GOOS, GOARCH: $GOARCH, RELEASE_NAME: $_NAME" | ||
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV | ||
echo "VERSION=$VERSIONNUM" >> $GITHUB_ENV | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
check-latest: true | ||
|
||
- name: Get project dependencies | ||
run: go mod download | ||
|
||
- name: Build db_backup_go | ||
run: | | ||
go build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
var ( | ||
x byte = 1 | ||
y byte = 2 | ||
z byte = 1 | ||
) | ||
|
||
func GetVersion() { | ||
fmt.Printf("db_backup_go\nversion: %v.%v.%v", x, y, z) | ||
} |