Skip to content

Commit db0827d

Browse files
committed
feat: x-flags support
1 parent ba6ddd6 commit db0827d

File tree

4 files changed

+64
-9
lines changed

4 files changed

+64
-9
lines changed

.github/workflows/test-actions.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ jobs:
3838
uses: ./
3939
with:
4040
dir: './example'
41+
x-flags: |
42+
example/main.owner=$owner
43+
example/main.repo=$repo
44+
example/main.target=$target
45+
example/main.sha=$sha
46+
example/main.short_sha=$short_sha
47+
example/main.pr=$pr
48+
example/main.ext=$ext
49+
example/main.tag=$tag
50+
example/main.hostname=$hostname
51+
example/main.username=$username
52+
example/main.built_on=$built_on
53+
example/main.built_at=$built_at
54+
example/main.git_author=$git_author
55+
example/main.git_commit=$git_commit
56+
example/main.go_version=$go_version
4157
4258
- name: Print folder tree
4359
run: sudo apt install tree && tree ./bin
@@ -50,7 +66,7 @@ jobs:
5066

5167
- name: Set up QEMU
5268
uses: docker/setup-qemu-action@v3
53-
69+
5470
- name: Set up Docker Buildx
5571
uses: docker/setup-buildx-action@v3
5672

@@ -63,4 +79,4 @@ jobs:
6379
push: false
6480
tags: ${{ steps.meta.outputs.tags }}
6581
labels: ${{ steps.meta.outputs.labels }}
66-
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/riscv64,linux/s390x
82+
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/riscv64,linux/s390x

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ Sure, here are the inputs and outputs in table format:
6969
7070
## Inputs
7171
72-
| Input | Description | Required | Default Value |
73-
| --------- | ----------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------- |
74-
| platforms | The platforms to build for | No | 'linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/riscv64,linux/s390x' |
75-
| dir | The directory to work | No | '.' |
76-
| packages | The packages to build | No | '.' |
77-
| flags | The flags to pass to the go build command | No | '-ldflags=-w -s' |
78-
| output | The output binary name | No | '$repo' |
72+
| Input | Description | Required | Default Value |
73+
| --------- | ----------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------- |
74+
| platforms | The platforms to build for | No | 'linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/riscv64,linux/s390x' |
75+
| dir | The directory to work | No | '.' |
76+
| packages | The packages to build | No | '.' |
77+
| flags | The flags to pass to the go build command | No | '-ldflags=-w -s' |
78+
| output | The output binary name | No | '$repo' |
79+
| x-flags | Extra X ldflags to pass to the go build command | No | |
7980
8081
## Outputs
8182

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ inputs:
2525
description: 'The output binary name'
2626
required: false
2727
default: '$repo'
28+
x-flags:
29+
description: 'Extra X ldflags to pass to the go build command'
30+
required: false
31+
default: ''
2832

2933
outputs:
3034
platforms:
@@ -57,6 +61,7 @@ runs:
5761
out-dir: 'temp-bin'
5862
output: 'temp-$target'
5963
targets: ${{ steps.platform2targets.outputs.targets }}
64+
x-flags: ${{ inputs.x-flags }}
6065

6166
- name: Rename files
6267
id: rename

example/main.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,40 @@ import (
99
_ "github.com/mattn/go-sqlite3"
1010
)
1111

12+
var (
13+
owner string
14+
repo string
15+
target string
16+
sha string
17+
short_sha string
18+
pr string
19+
ext string
20+
tag string
21+
hostname string
22+
username string
23+
built_on string
24+
built_at string
25+
git_author string
26+
git_commit string
27+
go_version string
28+
)
29+
1230
func main() {
31+
fmt.Printf("owner: %s\n", owner)
32+
fmt.Printf("repo: %s\n", repo)
33+
fmt.Printf("target: %s\n", target)
34+
fmt.Printf("sha: %s\n", sha)
35+
fmt.Printf("short_sha: %s\n", short_sha)
36+
fmt.Printf("pr: %s\n", pr)
37+
fmt.Printf("ext: %s\n", ext)
38+
fmt.Printf("tag: %s\n", tag)
39+
fmt.Printf("hostname: %s\n", hostname)
40+
fmt.Printf("username: %s\n", username)
41+
fmt.Printf("built_on: %s\n", built_on)
42+
fmt.Printf("built_at: %s\n", built_at)
43+
fmt.Printf("git_author: %s\n", git_author)
44+
fmt.Printf("git_commit: %s\n", git_commit)
45+
fmt.Printf("go_version: %s\n", go_version)
1346
os.Remove("./foo.db")
1447

1548
db, err := sql.Open("sqlite3", "./foo.db")

0 commit comments

Comments
 (0)